Skip to content

Commit

Permalink
Merge branch 'master' into feature-no-self-import
Browse files Browse the repository at this point in the history
  • Loading branch information
giodamelio authored Aug 1, 2017
2 parents 0ea3d80 + dd28130 commit 6dc8a86
Show file tree
Hide file tree
Showing 52 changed files with 840 additions and 139 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ node_modules
# generated output
lib/
**/.nyc_output/

# Only apps should have lockfiles
yarn.lock
package-lock.json
npm-shrinkwrap.json
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ language: node_js
node_js:
- 4
- 6
- 8

os:
- linux
- osx

env:
- ESLINT_VERSION=2
- ESLINT_VERSION=3
- ESLINT_VERSION=4

install:
- npm -g install npm@3
- if [ ${TRAVIS_NODE_VERSION} == "4" ]; then
npm install -g npm@3;
fi
- npm install
- npm install eslint@$ESLINT_VERSION --ignore-scripts || true
# install all resolver deps
- "for resolver in ./resolvers/*; do cd $resolver && npm install && cd ../..; done"

Expand Down
61 changes: 60 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]


## [2.7.0] - 2017-07-06
### Changed
- [`no-absolute-path`] picks up speed boost, optional AMD support ([#843], thansk [@jseminck])

## [2.6.1] - 2017-06-29
### Fixed
- update bundled node resolver dependency to latest version

## [2.6.0] - 2017-06-23
### Changed
- update tests / peerDeps for ESLint 4.0 compatibility ([#871], thanks [@mastilver])
- [`memo-parser`] updated to require `filePath` on parser options as it melts
down if it's not there, now that this plugin always provides it. (see [#863])

## [2.5.0] - 2017-06-22

Re-releasing v[2.4.0] after discovering that the memory leak is isolated to the [`memo-parser`],
which is more or less experimental anyway.

### Added
- Autofixer for newline-after-import. ([#686] + [#696], thanks [@eelyafi])

## [2.4.0] - 2017-06-02 [YANKED]

Yanked due to critical issue in eslint-module-utils with cache key resulting from [#839].

### Added
- Add `filePath` into `parserOptions` passed to `parser` ([#839], thanks [@sompylasar])
- Add `allow` option to [`no-unassigned-import`] to allow for files that match the globs ([#671], [#737], thanks [@kevin940726]).

## [2.3.0] - 2017-05-18
### Added
- [`no-anonymous-default-export`] rule: report anonymous default exports ([#712], thanks [@duncanbeevers]).
- Add new value to [`order`]'s `newlines-between` option to allow newlines inside import groups ([#627], [#628], thanks [@giodamelio])
Expand All @@ -12,9 +45,12 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

### Changed
- [`no-extraneous-dependencies`]: use `read-pkg-up` to simplify finding + loading `package.json` ([#680], thanks [@wtgtybhertgeghgtwtg])
- Add support to specify the package.json [`no-extraneous-dependencies`] ([#685], thanks [@ramasilveyra])

### Fixed
- attempt to fix crash in [`no-mutable-exports`]. ([#660])
- "default is a reserved keyword" in no-maned-default tests by locking down babylon to 6.15.0 (#756, thanks @gmathieu)
- support scoped modules containing non word characters


## [2.2.0] - 2016-11-07
Expand Down Expand Up @@ -385,9 +421,16 @@ for info on changes for earlier releases.
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md
[`no-self-import`]: ./docs/rules/no-self-import.md

[`memo-parser`]: ./memo-parser/README.md

[#843]: https://github.com/benmosher/eslint-plugin-import/pull/843
[#871]: https://github.com/benmosher/eslint-plugin-import/pull/871
[#742]: https://github.com/benmosher/eslint-plugin-import/pull/742
[#737]: https://github.com/benmosher/eslint-plugin-import/pull/737
[#727]: https://github.com/benmosher/eslint-plugin-import/pull/727
[#712]: https://github.com/benmosher/eslint-plugin-import/pull/712
[#696]: https://github.com/benmosher/eslint-plugin-import/pull/696
[#685]: https://github.com/benmosher/eslint-plugin-import/pull/685
[#680]: https://github.com/benmosher/eslint-plugin-import/pull/680
[#654]: https://github.com/benmosher/eslint-plugin-import/pull/654
[#639]: https://github.com/benmosher/eslint-plugin-import/pull/639
Expand Down Expand Up @@ -443,6 +486,10 @@ for info on changes for earlier releases.
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157
[#314]: https://github.com/benmosher/eslint-plugin-import/pull/314

[#863]: https://github.com/benmosher/eslint-plugin-import/issues/863
[#839]: https://github.com/benmosher/eslint-plugin-import/issues/839
[#686]: https://github.com/benmosher/eslint-plugin-import/issues/686
[#671]: https://github.com/benmosher/eslint-plugin-import/issues/671
[#660]: https://github.com/benmosher/eslint-plugin-import/issues/660
[#653]: https://github.com/benmosher/eslint-plugin-import/issues/653
[#627]: https://github.com/benmosher/eslint-plugin-import/issues/627
Expand Down Expand Up @@ -501,7 +548,13 @@ for info on changes for earlier releases.
[#119]: https://github.com/benmosher/eslint-plugin-import/issues/119
[#89]: https://github.com/benmosher/eslint-plugin-import/issues/89

[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.2.0...HEAD
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.7.0...HEAD
[2.7.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.1...v2.7.0
[2.6.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.0...v2.6.1
[2.6.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.5.0...v2.6.0
[2.5.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.4.0...v2.5.0
[2.4.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.3.0...v2.4.0
[2.3.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.0...v2.0.1
Expand Down Expand Up @@ -579,3 +632,9 @@ for info on changes for earlier releases.
[@duncanbeevers]: https://github.com/duncanbeevers
[@giodamelio]: https://github.com/giodamelio
[@ntdb]: https://github.com/ntdb
[@ramasilveyra]: https://github.com/ramasilveyra
[@sompylasar]: https://github.com/sompylasar
[@kevin940726]: https://github.com/kevin940726
[@eelyafi]: https://github.com/eelyafi
[@mastilver]: https://github.com/mastilver
[@jseminck]: https://github.com/jseminck
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ In the interest of supporting both of these, v0.11 introduces resolvers.
Currently [Node] and [Webpack] resolution have been implemented, but the
resolvers are just npm packages, so [third party packages are supported](https://github.com/benmosher/eslint-plugin-import/wiki/Resolvers) (and encouraged!).

You can reference resolvers in several ways(in order of precedence):
You can reference resolvers in several ways (in order of precedence):

- as a conventional `eslint-import-resolver` name, like `eslint-import-resolver-foo`:

Expand Down
3 changes: 1 addition & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
```

Generally, don't use `npm version` for this because it creates a tag, which I normally
wait until signoff from all contributors (`new Set(["@jfmengels"])`) and actually
`npm publish`-ing to snap the tag.
wait until signoff from contributors and actually `npm publish`-ing to snap the tag.

3. create pull request from `release-[x.y.z]` into `release` branch

Expand Down
11 changes: 6 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Test against this version of Node.js
environment:
matrix:
- nodejs_version: "4"
- nodejs_version: "8"
- nodejs_version: "6"
- nodejs_version: "4"

# platform:
# - x86
Expand All @@ -13,11 +14,11 @@ install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version

# update npm (only needed for Node 0.10)
- npm -g install npm@3
# - set PATH=%APPDATA%\npm;%PATH%

# install modules
- ps: >-
if ($env:nodejs_version -eq "4") {
npm install -g npm@3;
}
- npm install

# todo: learn how to do this for all .\resolvers\* on Windows
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/newline-after-import.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# newline-after-import

Enforces having one or more empty lines after the last top-level import statement or require call.
+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule.

## Rule Details

Expand Down Expand Up @@ -76,7 +77,7 @@ const FOO = 'BAR'
{
...
"rules": {
"import/newline-after-import": [{ "count": 2 }]
"import/newline-after-import": ["error", { "count": 2 }]
}
}
```
Expand Down
21 changes: 21 additions & 0 deletions docs/rules/no-absolute-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,24 @@ var _ = require('lodash');
var foo = require('foo');
var foo = require('./foo');
```

### Options

By default, only ES6 imports and CommonJS `require` calls will have this rule enforced.

You may provide an options object providing true/false for any of

- `esmodule`: defaults to `true`
- `commonjs`: defaults to `true`
- `amd`: defaults to `false`

If `{ amd: true }` is provided, dependency paths for AMD-style `define` and `require`
calls will be resolved:

```js
/*eslint import/no-absolute-path: [2, { commonjs: false, amd: true }]*/
define(['/foo'], function (foo) { /*...*/ }) // reported
require(['/foo'], function (foo) { /*...*/ }) // reported

const foo = require('/foo') // ignored because of explicit `commonjs: false`
```
12 changes: 9 additions & 3 deletions docs/rules/no-extraneous-dependencies.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Forbid the use of extraneous packages

Forbid the import of external modules that are not declared in the `package.json`'s `dependencies`, `devDependencies`, `optionalDependencies` or `peerDependencies`.
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything.
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behaviour can be changed with the rule option `packageDir`.

### Options

Expand All @@ -25,7 +25,13 @@ You can also use an array of globs instead of literal booleans:
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js", "**/*.spec.js"]}]
```

When using an array of globs, the setting will be activated if the name of the file being linted matches a single glob in the array.
When using an array of globs, the setting will be set to `true` (no errors reported) if the name of the file being linted matches a single glob in the array, and `false` otherwise.

Also there is one more option called `packageDir`, this option is to specify the path to the folder containing package.json and is relative to the current working directory.

```js
"import/no-extraneous-dependencies": ["error", {"packageDir": './some-dir/'}]
```

## Rule Details

Expand Down Expand Up @@ -83,7 +89,7 @@ var foo = require('./foo');

import test from 'ava';
import find from 'lodash.find';
import find from 'lodash.isarray';
import isArray from 'lodash.isarray';

/* eslint import/no-extraneous-dependencies: ["error", {"peerDependencies": true}] */
import react from 'react';
Expand Down
22 changes: 22 additions & 0 deletions docs/rules/no-unassigned-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@ With both CommonJS' `require` and the ES6 modules' `import` syntax, it is possib

This rule aims to remove modules with side-effects by reporting when a module is imported but not assigned.

### Options

This rule supports the following option:

`allow`: An Array of globs. The files that match any of these patterns would be ignored/allowed by the linter. This can be useful for some build environments (e.g. css-loader in webpack).

Note that the globs start from the where the linter is executed (usually project root), but not from each file that includes the source. Learn more in both the pass and fail examples below.


## Fail

```js
import 'should'
require('should')

// In <PROJECT_ROOT>/src/app.js
import '../styles/app.css'
// {"allow": ["styles/*.css"]}
```


Expand All @@ -34,4 +47,13 @@ bar(require('foo'))
require('foo').bar
require('foo').bar()
require('foo')()

// With allow option set
import './style.css' // {"allow": ["**/*.css"]}
import 'babel-register' // {"allow": ["babel-register"]}

// In <PROJECT_ROOT>/src/app.js
import './styles/app.css'
import '../scripts/register.js'
// {"allow": ["src/styles/**", "**/scripts/*.js"]}
```
5 changes: 4 additions & 1 deletion memo-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ const parserOptions = {
}

exports.parse = function parse(content, options) {
// them defaults yo
options = Object.assign({}, options, parserOptions)

if (!options.filePath) {
throw new Error("no file path provided!")
}

const keyHash = crypto.createHash('sha256')
keyHash.update(content)
hashObject(options, keyHash)
Expand Down
11 changes: 8 additions & 3 deletions memo-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "memo-parser",
"version": "0.1.0",
"engines": { "node": ">=4" },
"version": "0.2.0",
"engines": {
"node": ">=4"
},
"description": "Memoizing wrapper for any ESLint-compatible parser module.",
"main": "index.js",
"scripts": {
Expand All @@ -21,5 +23,8 @@
"bugs": {
"url": "https://github.com/benmosher/eslint-plugin-import/issues"
},
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme"
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme",
"peerDependencies": {
"eslint": ">=3.5.0"
}
}
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-import",
"version": "2.2.0",
"version": "2.7.0",
"description": "Import with sanity.",
"engines": {
"node": ">=4"
Expand Down Expand Up @@ -51,11 +51,12 @@
"babel-eslint": "next",
"babel-plugin-istanbul": "^2.0.1",
"babel-preset-es2015-argon": "latest",
"babel-register": "6.16.3",
"babel-register": "6.24.1",
"babylon": "6.15.0",
"chai": "^3.4.0",
"coveralls": "^2.11.4",
"cross-env": "^3.1.0",
"eslint": "3.x",
"cross-env": "^4.0.0",
"eslint": "2.x - 4.x",
"eslint-import-resolver-node": "file:./resolvers/node",
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
"eslint-module-utils": "file:./utils",
Expand All @@ -68,19 +69,20 @@
"nyc": "^8.3.0",
"redux": "^3.0.4",
"rimraf": "2.5.2",
"sinon": "^2.3.2",
"typescript": "^2.0.3",
"typescript-eslint-parser": "^1.0.0"
"typescript-eslint-parser": "^2.1.0"
},
"peerDependencies": {
"eslint": "2.x - 3.x"
"eslint": "2.x - 4.x"
},
"dependencies": {
"builtin-modules": "^1.1.1",
"contains-path": "^0.1.0",
"debug": "^2.2.0",
"debug": "^2.6.8",
"doctrine": "1.5.0",
"eslint-import-resolver-node": "^0.2.0",
"eslint-module-utils": "^2.0.0",
"eslint-import-resolver-node": "^0.3.1",
"eslint-module-utils": "^2.1.1",
"has": "^1.0.1",
"lodash.cond": "^4.3.0",
"minimatch": "^3.0.3",
Expand Down
4 changes: 4 additions & 0 deletions resolvers/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
## Unreleased


## v0.3.1 - 2017-06-23
### Changed
- bumped `debug` dep to match other packages

## v0.3.0 - 2016-12-15
### Changed
- bumped `resolve` to fix issues with Node builtins (thanks [@SkeLLLa] and [@ljharb])
Expand Down
Loading

0 comments on commit 6dc8a86

Please sign in to comment.