Skip to content

Commit b79e083

Browse files
authored
Merge pull request #837 from benmosher/release-2.3.0
Release 2.3.0
2 parents 90ef48b + 74425a2 commit b79e083

32 files changed

+602
-114
lines changed

CHANGELOG.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
66
## [Unreleased]
77

88

9+
## [2.3.0] - 2017-05-18
10+
### Added
11+
- [`no-anonymous-default-export`] rule: report anonymous default exports ([#712], thanks [@duncanbeevers]).
12+
- Add new value to [`order`]'s `newlines-between` option to allow newlines inside import groups ([#627], [#628], thanks [@giodamelio])
13+
- Add `count` option to the [`newline-after-import`] rule to allow configuration of number of newlines expected ([#742], thanks [@ntdb])
14+
15+
### Changed
16+
- [`no-extraneous-dependencies`]: use `read-pkg-up` to simplify finding + loading `package.json` ([#680], thanks [@wtgtybhertgeghgtwtg])
17+
- Add support to specify the package.json [`no-extraneous-dependencies`] ([#685], thanks [@ramasilveyra])
18+
19+
### Fixed
20+
- attempt to fix crash in [`no-mutable-exports`]. ([#660])
21+
- "default is a reserved keyword" in no-maned-default tests by locking down babylon to 6.15.0 (#756, thanks @gmathieu)
22+
23+
924
## [2.2.0] - 2016-11-07
1025
### Fixed
1126
- Corrected a few gaffs in the auto-ignore logic to fix major performance issues
@@ -371,10 +386,16 @@ for info on changes for earlier releases.
371386
[`no-webpack-loader-syntax`]: ./docs/rules/no-webpack-loader-syntax.md
372387
[`no-unassigned-import`]: ./docs/rules/no-unassigned-import.md
373388
[`unambiguous`]: ./docs/rules/unambiguous.md
389+
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md
374390

391+
[#742]: https://github.com/benmosher/eslint-plugin-import/pull/742
392+
[#712]: https://github.com/benmosher/eslint-plugin-import/pull/712
393+
[#685]: https://github.com/benmosher/eslint-plugin-import/pull/685
394+
[#680]: https://github.com/benmosher/eslint-plugin-import/pull/680
375395
[#654]: https://github.com/benmosher/eslint-plugin-import/pull/654
376396
[#639]: https://github.com/benmosher/eslint-plugin-import/pull/639
377397
[#630]: https://github.com/benmosher/eslint-plugin-import/pull/630
398+
[#628]: https://github.com/benmosher/eslint-plugin-import/pull/628
378399
[#596]: https://github.com/benmosher/eslint-plugin-import/pull/596
379400
[#586]: https://github.com/benmosher/eslint-plugin-import/pull/586
380401
[#578]: https://github.com/benmosher/eslint-plugin-import/pull/578
@@ -424,7 +445,9 @@ for info on changes for earlier releases.
424445
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157
425446
[#314]: https://github.com/benmosher/eslint-plugin-import/pull/314
426447

448+
[#660]: https://github.com/benmosher/eslint-plugin-import/issues/660
427449
[#653]: https://github.com/benmosher/eslint-plugin-import/issues/653
450+
[#627]: https://github.com/benmosher/eslint-plugin-import/issues/627
428451
[#609]: https://github.com/benmosher/eslint-plugin-import/issues/609
429452
[#604]: https://github.com/benmosher/eslint-plugin-import/issues/604
430453
[#602]: https://github.com/benmosher/eslint-plugin-import/issues/602
@@ -479,7 +502,8 @@ for info on changes for earlier releases.
479502
[#119]: https://github.com/benmosher/eslint-plugin-import/issues/119
480503
[#89]: https://github.com/benmosher/eslint-plugin-import/issues/89
481504

482-
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.2.0...HEAD
505+
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.3.0...HEAD
506+
[2.3.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.2.0...v2.3.0
483507
[2.2.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.1.0...v2.2.0
484508
[2.1.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.1...v2.1.0
485509
[2.0.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.0...v2.0.1
@@ -553,3 +577,8 @@ for info on changes for earlier releases.
553577
[@fson]: https://github.com/fson
554578
[@ntdb]: https://github.com/ntdb
555579
[@jakubsta]: https://github.com/jakubsta
580+
[@wtgtybhertgeghgtwtg]: https://github.com/wtgtybhertgeghgtwtg
581+
[@duncanbeevers]: https://github.com/duncanbeevers
582+
[@giodamelio]: https://github.com/giodamelio
583+
[@ntdb]: https://github.com/ntdb
584+
[@ramasilveyra]: https://github.com/ramasilveyra

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
7676
* Limit the maximum number of dependencies a module can have ([`max-dependencies`])
7777
* Forbid unassigned imports ([`no-unassigned-import`])
7878
* Forbid named default exports ([`no-named-default`])
79+
* Forbid anonymous values as default exports ([`no-anonymous-default-export`])
7980

8081
[`first`]: ./docs/rules/first.md
8182
[`no-duplicates`]: ./docs/rules/no-duplicates.md
@@ -87,6 +88,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
8788
[`max-dependencies`]: ./docs/rules/max-dependencies.md
8889
[`no-unassigned-import`]: ./docs/rules/no-unassigned-import.md
8990
[`no-named-default`]: ./docs/rules/no-named-default.md
91+
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md
9092

9193
## Installation
9294

docs/rules/named.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Redux's npm module includes this key, and thereby is lintable, for example.
1010

1111
A module path that is [ignored] or not [unambiguously an ES module] will not be reported when imported.
1212

13-
[ignored]: ../README.md#importignore
13+
[ignored]: ../../README.md#importignore
1414
[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar
1515

1616

docs/rules/newline-after-import.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# newline-after-import
22

3-
Enforces having an empty line after the last top-level import statement or require call.
3+
Enforces having one or more empty lines after the last top-level import statement or require call.
44

55
## Rule Details
66

7+
This rule has one option, `count` which sets the number of newlines that are enforced after the last top-level import statement or require call. This option defaults to `1`.
8+
79
Valid:
810

911
```js
@@ -26,7 +28,7 @@ const BAR = require('./bar')
2628
const BAZ = 1
2729
```
2830

29-
...whereas here imports will be reported:
31+
Invalid:
3032

3133
```js
3234
import * as foo from 'foo'
@@ -46,6 +48,40 @@ const BAZ = 1
4648
const BAR = require('./bar')
4749
```
4850

51+
With `count` set to `2` this will be considered valid:
52+
53+
```js
54+
import defaultExport from './foo'
55+
56+
57+
const FOO = 'BAR'
58+
```
59+
60+
With `count` set to `2` these will be considered invalid:
61+
62+
```js
63+
import defaultExport from './foo'
64+
const FOO = 'BAR'
65+
```
66+
67+
```js
68+
import defaultExport from './foo'
69+
70+
const FOO = 'BAR'
71+
```
72+
73+
74+
## Example options usage
75+
```
76+
{
77+
...
78+
"rules": {
79+
"import/newline-after-import": [{ "count": 2 }]
80+
}
81+
}
82+
```
83+
84+
4985
## When Not To Use It
5086

5187
If you like to visually group module imports with its usage, you don't want to use this rule.

docs/rules/no-amd.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# no-amd
22

3-
Reports `require([array], ...)` and `define([array], ...) function calls at the
3+
Reports `require([array], ...)` and `define([array], ...)` function calls at the
44
module scope. Will not report if !=2 arguments, or first argument is not a literal array.
55

66
Intended for temporary use when migrating to pure ES6 modules.
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# no-anonymous-default-export
2+
3+
Reports if a module's default export is unnamed. This includes several types of unnamed data types; literals, object expressions, arrays, anonymous functions, arrow functions, and anonymous class declarations.
4+
5+
Ensuring that default exports are named helps improve the grepability of the codebase by encouraging the re-use of the same identifier for the module's default export at its declaration site and at its import sites.
6+
7+
## Options
8+
9+
By default, all types of anonymous default exports are forbidden, but any types can be selectively allowed by toggling them on in the options.
10+
11+
The complete default configuration looks like this.
12+
13+
```js
14+
"import/no-anonymous-default-export": ["error", {
15+
"allowArray": false,
16+
"allowArrowFunction": false,
17+
"allowAnonymousClass": false,
18+
"allowAnonymousFunction": false,
19+
"allowLiteral": false,
20+
"allowObject": false
21+
}]
22+
```
23+
24+
## Rule Details
25+
26+
### Fail
27+
```js
28+
export default []
29+
30+
export default () => {}
31+
32+
export default class {}
33+
34+
export default function () {}
35+
36+
export default 123
37+
38+
export default {}
39+
```
40+
41+
### Pass
42+
```js
43+
const foo = 123
44+
export default foo
45+
46+
export default class MyClass() {}
47+
48+
export default function foo() {}
49+
50+
/* eslint import/no-anonymous-default-export: [2, {"allowArray": true}] */
51+
export default []
52+
53+
/* eslint import/no-anonymous-default-export: [2, {"allowArrowFunction": true}] */
54+
export default () => {}
55+
56+
/* eslint import/no-anonymous-default-export: [2, {"allowAnonymousClass": true}] */
57+
export default class {}
58+
59+
/* eslint import/no-anonymous-default-export: [2, {"allowAnonymousFunction": true}] */
60+
export default function () {}
61+
62+
/* eslint import/no-anonymous-default-export: [2, {"allowLiteral": true}] */
63+
export default 123
64+
65+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
66+
export default {}
67+
```

docs/rules/no-dynamic-require.md

-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ require(name());
1919

2020
```js
2121
require('../name');
22-
require('../name' + name);
2322
require(`../name`);
2423
```

docs/rules/no-extraneous-dependencies.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Forbid the use of extraneous packages
22

33
Forbid the import of external modules that are not declared in the `package.json`'s `dependencies`, `devDependencies`, `optionalDependencies` or `peerDependencies`.
4-
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything.
4+
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`.
55

66
### Options
77

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

28-
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.
28+
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.
29+
30+
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.
31+
32+
```js
33+
"import/no-extraneous-dependencies": ["error", {"packageDir": './some-dir/'}]
34+
```
2935

3036
## Rule Details
3137

docs/rules/no-named-as-default.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import foo from './foo.js';
2727
import bar from './foo.js';
2828
```
2929

30-
For post-ES2015 `export` extensions, this also prevents exporting the default from a referenced module as a name within than module, for the same reasons:
30+
For post-ES2015 `export` extensions, this also prevents exporting the default from a referenced module as a name within that module, for the same reasons:
3131

3232
```js
3333
// valid:

docs/rules/no-unresolved.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This rule can also optionally report on unresolved modules in CommonJS `require(
1111
To enable this, send `{ commonjs: true/false, amd: true/false }` as a rule option.
1212
Both are disabled by default.
1313

14-
If you are using Webpack, see the section on [resolver plugins](../../README.md#resolver-plugins).
14+
If you are using Webpack, see the section on [resolvers](../../README.md#resolvers).
1515

1616
## Rule Details
1717

docs/rules/order.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ You can set the options like this:
9292
"import/order": ["error", {"groups": ["index", "sibling", "parent", "internal", "external", "builtin"]}]
9393
```
9494

95-
### `newlines-between: [ignore|always|never]`:
95+
### `newlines-between: [ignore|always|always-and-inside-groups|never]`:
9696

9797

9898
Enforces or forbids new lines between import groups:
9999

100100
- If set to `ignore`, no errors related to new lines between import groups will be reported (default).
101101
- If set to `always`, at least one new line between each group will be enforced, and new lines inside a group will be forbidden. To prevent multiple lines between imports, core `no-multiple-empty-lines` rule can be used.
102+
- If set to `always-and-inside-groups`, it will act like `always` except newlines are allowed inside import groups.
102103
- If set to `never`, no new lines are allowed in the entire import section.
103104

104105
With the default group setting, the following will be invalid:
@@ -111,6 +112,15 @@ import index from './';
111112
import sibling from './foo';
112113
```
113114

115+
```js
116+
/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */
117+
import fs from 'fs';
118+
119+
import path from 'path';
120+
import index from './';
121+
import sibling from './foo';
122+
```
123+
114124
```js
115125
/* eslint import/order: ["error", {"newlines-between": "never"}] */
116126
import fs from 'fs';
@@ -133,6 +143,17 @@ import index from './';
133143
import sibling from './foo';
134144
```
135145

146+
```js
147+
/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */
148+
import fs from 'fs';
149+
150+
import path from 'path';
151+
152+
import index from './';
153+
154+
import sibling from './foo';
155+
```
156+
136157
```js
137158
/* eslint import/order: ["error", {"newlines-between": "never"}] */
138159
import fs from 'fs';

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-import",
3-
"version": "2.2.0",
3+
"version": "2.3.0",
44
"description": "Import with sanity.",
55
"engines": {
66
"node": ">=4"
@@ -51,10 +51,11 @@
5151
"babel-eslint": "next",
5252
"babel-plugin-istanbul": "^2.0.1",
5353
"babel-preset-es2015-argon": "latest",
54-
"babel-register": "6.16.3",
54+
"babel-register": "6.24.1",
55+
"babylon": "6.15.0",
5556
"chai": "^3.4.0",
5657
"coveralls": "^2.11.4",
57-
"cross-env": "^3.1.0",
58+
"cross-env": "^4.0.0",
5859
"eslint": "3.x",
5960
"eslint-import-resolver-node": "file:./resolvers/node",
6061
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
@@ -69,7 +70,7 @@
6970
"redux": "^3.0.4",
7071
"rimraf": "2.5.2",
7172
"typescript": "^2.0.3",
72-
"typescript-eslint-parser": "^0.4.0"
73+
"typescript-eslint-parser": "^2.1.0"
7374
},
7475
"peerDependencies": {
7576
"eslint": "2.x - 3.x"
@@ -84,7 +85,7 @@
8485
"has": "^1.0.1",
8586
"lodash.cond": "^4.3.0",
8687
"minimatch": "^3.0.3",
87-
"pkg-up": "^1.0.0"
88+
"read-pkg-up": "^2.0.0"
8889
},
8990
"nyc": {
9091
"require": [

resolvers/node/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
55

66
## Unreleased
7+
8+
9+
## v0.3.0 - 2016-12-15
10+
### Changed
11+
- bumped `resolve` to fix issues with Node builtins (thanks [@SkeLLLa] and [@ljharb])
12+
713
### Fixed
814
- use `files` in `package.json` to ship only `index.js` ([#531], thanks for noticing [@lukeapage])
915

@@ -31,3 +37,5 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
3137

3238
[@jasonkarns]: https://github.com/jasonkarns
3339
[@lukeapage]: https://github.com/lukeapage
40+
[@SkeLLLa]: https://github.com/SkeLLLa
41+
[@ljharb]: https://github.com/ljharb

0 commit comments

Comments
 (0)