Skip to content

Commit 9b8b490

Browse files
authored
Merge branch 'master' into flowtype-wrong-import
2 parents 11e74d1 + 4e37dbf commit 9b8b490

File tree

150 files changed

+3786
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+3786
-296
lines changed

.travis.yml

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
11
language: node_js
22
node_js:
3-
- 4
4-
- 6
5-
- 8
3+
- '8'
4+
- '6'
5+
- '4'
66

7-
os:
8-
- linux
9-
- osx
7+
os: linux
108

119
env:
12-
- ESLINT_VERSION=2
13-
- ESLINT_VERSION=3
1410
- ESLINT_VERSION=4
11+
- ESLINT_VERSION=3
12+
- ESLINT_VERSION=2
13+
14+
# osx backlog is often deep, so to be polite we can just hit these highlights
15+
matrix:
16+
include:
17+
- env: PACKAGE=resolvers/node
18+
node_js: 8
19+
- env: PACKAGE=resolvers/node
20+
node_js: 6
21+
- env: PACKAGE=resolvers/node
22+
node_js: 4
23+
- env: PACKAGE=resolvers/webpack
24+
node_js: 8
25+
- env: PACKAGE=resolvers/webpack
26+
node_js: 6
27+
- env: PACKAGE=resolvers/webpack
28+
node_js: 4
29+
- os: osx
30+
env: ESLINT_VERSION=4
31+
node_js: 8
32+
- os: osx
33+
env: ESLINT_VERSION=3
34+
node_js: 6
35+
- os: osx
36+
env: ESLINT_VERSION=2
37+
node_js: 4
1538

39+
before_install:
40+
- 'nvm install-latest-npm'
41+
- 'if [ -n "${PACKAGE-}" ]; then cd "${PACKAGE}"; fi'
1642
install:
17-
- if [ ${TRAVIS_NODE_VERSION} == "4" ]; then
18-
npm install -g npm@3;
19-
fi
2043
- npm install
21-
- npm install eslint@$ESLINT_VERSION --ignore-scripts || true
22-
# install all resolver deps
23-
- "for resolver in ./resolvers/*; do cd $resolver && npm install && cd ../..; done"
44+
- npm install --no-save eslint@$ESLINT_VERSION --ignore-scripts || true
2445

2546
script:
26-
- "npm test"
27-
- "for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done"
47+
- 'npm test'
2848

2949
after_success:
3050
- npm run coveralls

CHANGELOG.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,43 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
55

66
## [Unreleased]
77
### Added
8+
- Ignore type imports for [`named`] rule ([#931], thanks [@mattijsbliek])
9+
- Add documentation for [`no-useless-path-segments`] rule ([#1068], thanks [@manovotny])
10+
11+
12+
# [2.11.0] - 2018-04-09
13+
### Added
14+
- Fixer for [`first`] ([#1046], thanks [@fengkfengk])
15+
- `allow-require` option for [`no-commonjs`] rule ([#880], thanks [@futpib])
16+
17+
### Fixed
18+
- memory/CPU regression where ASTs were held in memory ([#1058], thanks [@klimashkin]/[@lukeapage])
19+
20+
## [2.10.0] - 2018-03-29
21+
### Added
22+
- Autofixer for [`order`] rule ([#908], thanks [@tihonove])
23+
- Add [`no-cycle`] rule: reports import cycles.
24+
25+
## [2.9.0] - 2018-02-21
26+
### Added
27+
- Add [`group-exports`] rule: style-guide rule to report use of multiple named exports ([#721], thanks [@robertrossmann])
28+
- Add [`no-self-import`] rule: forbids a module from importing itself. ([#727], [#449], [#447], thanks [@giodamelio]).
29+
- Add [`no-default-export`] rule ([#889], thanks [@isiahmeadows])
30+
- Add [`no-useless-path-segments`] rule ([#912], thanks [@graingert] and [@danny-andrews])
31+
- ... and more! check the commits for v[2.9.0]
32+
33+
## [2.8.0] - 2017-10-18
34+
### Added
835
- [`exports-last`] rule ([#620] + [#632], thanks [@k15a])
936

1037
### Changed
1138
- Case-sensitivity checking ignores working directory and ancestors. ([#720] + [#858], thanks [@laysent])
1239

40+
### Fixed
41+
- support scoped modules containing hyphens ([#744], thanks [@rosswarren])
42+
- core-modules now resolves files inside declared modules ([#886] / [#891], thanks [@mplewis])
43+
- TypeError for missing AST fields from TypeScript ([#842] / [#944], thanks [@alexgorbatchev])
44+
1345
## [2.7.0] - 2017-07-06
1446
### Changed
1547
- [`no-absolute-path`] picks up speed boost, optional AMD support ([#843], thanks [@jseminck])
@@ -423,14 +455,29 @@ for info on changes for earlier releases.
423455
[`unambiguous`]: ./docs/rules/unambiguous.md
424456
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md
425457
[`exports-last`]: ./docs/rules/exports-last.md
458+
[`group-exports`]: ./docs/rules/group-exports.md
459+
[`no-self-import`]: ./docs/rules/no-self-import.md
460+
[`no-default-export`]: ./docs/rules/no-default-export.md
461+
[`no-useless-path-segments`]: ./docs/rules/no-useless-path-segments.md
462+
[`no-cycle`]: ./docs/rules/no-cycle.md
426463

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

466+
[#1068]: https://github.com/benmosher/eslint-plugin-import/pull/1068
467+
[#1046]: https://github.com/benmosher/eslint-plugin-import/pull/1046
468+
[#944]: https://github.com/benmosher/eslint-plugin-import/pull/944
469+
[#908]: https://github.com/benmosher/eslint-plugin-import/pull/908
470+
[#891]: https://github.com/benmosher/eslint-plugin-import/pull/891
471+
[#889]: https://github.com/benmosher/eslint-plugin-import/pull/889
472+
[#880]: https://github.com/benmosher/eslint-plugin-import/pull/880
429473
[#858]: https://github.com/benmosher/eslint-plugin-import/pull/858
430474
[#843]: https://github.com/benmosher/eslint-plugin-import/pull/843
431475
[#871]: https://github.com/benmosher/eslint-plugin-import/pull/871
476+
[#744]: https://github.com/benmosher/eslint-plugin-import/pull/744
432477
[#742]: https://github.com/benmosher/eslint-plugin-import/pull/742
433478
[#737]: https://github.com/benmosher/eslint-plugin-import/pull/737
479+
[#727]: https://github.com/benmosher/eslint-plugin-import/pull/727
480+
[#721]: https://github.com/benmosher/eslint-plugin-import/pull/721
434481
[#712]: https://github.com/benmosher/eslint-plugin-import/pull/712
435482
[#696]: https://github.com/benmosher/eslint-plugin-import/pull/696
436483
[#685]: https://github.com/benmosher/eslint-plugin-import/pull/685
@@ -454,6 +501,7 @@ for info on changes for earlier releases.
454501
[#489]: https://github.com/benmosher/eslint-plugin-import/pull/489
455502
[#485]: https://github.com/benmosher/eslint-plugin-import/pull/485
456503
[#461]: https://github.com/benmosher/eslint-plugin-import/pull/461
504+
[#449]: https://github.com/benmosher/eslint-plugin-import/pull/449
457505
[#444]: https://github.com/benmosher/eslint-plugin-import/pull/444
458506
[#428]: https://github.com/benmosher/eslint-plugin-import/pull/428
459507
[#395]: https://github.com/benmosher/eslint-plugin-import/pull/395
@@ -488,8 +536,13 @@ for info on changes for earlier releases.
488536
[#164]: https://github.com/benmosher/eslint-plugin-import/pull/164
489537
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157
490538
[#314]: https://github.com/benmosher/eslint-plugin-import/pull/314
539+
[#912]: https://github.com/benmosher/eslint-plugin-import/pull/912
491540

541+
[#1058]: https://github.com/benmosher/eslint-plugin-import/issues/1058
542+
[#931]: https://github.com/benmosher/eslint-plugin-import/issues/931
543+
[#886]: https://github.com/benmosher/eslint-plugin-import/issues/886
492544
[#863]: https://github.com/benmosher/eslint-plugin-import/issues/863
545+
[#842]: https://github.com/benmosher/eslint-plugin-import/issues/842
493546
[#839]: https://github.com/benmosher/eslint-plugin-import/issues/839
494547
[#720]: https://github.com/benmosher/eslint-plugin-import/issues/720
495548
[#686]: https://github.com/benmosher/eslint-plugin-import/issues/686
@@ -517,6 +570,7 @@ for info on changes for earlier releases.
517570
[#456]: https://github.com/benmosher/eslint-plugin-import/issues/456
518571
[#453]: https://github.com/benmosher/eslint-plugin-import/issues/453
519572
[#452]: https://github.com/benmosher/eslint-plugin-import/issues/452
573+
[#447]: https://github.com/benmosher/eslint-plugin-import/issues/447
520574
[#441]: https://github.com/benmosher/eslint-plugin-import/issues/441
521575
[#423]: https://github.com/benmosher/eslint-plugin-import/issues/423
522576
[#416]: https://github.com/benmosher/eslint-plugin-import/issues/416
@@ -552,7 +606,11 @@ for info on changes for earlier releases.
552606
[#119]: https://github.com/benmosher/eslint-plugin-import/issues/119
553607
[#89]: https://github.com/benmosher/eslint-plugin-import/issues/89
554608

555-
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.7.0...HEAD
609+
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.11.0...HEAD
610+
[2.11.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.10.0...v2.11.0
611+
[2.10.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.9.0...v2.10.0
612+
[2.9.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.8.0...v2.9.0
613+
[2.8.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.7.0...v2.8.0
556614
[2.7.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.1...v2.7.0
557615
[2.6.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.0...v2.6.1
558616
[2.6.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.5.0...v2.6.0
@@ -644,3 +702,17 @@ for info on changes for earlier releases.
644702
[@jseminck]: https://github.com/jseminck
645703
[@laysent]: https://github.com/laysent
646704
[@k15a]: https://github.com/k15a
705+
[@mplewis]: https://github.com/mplewis
706+
[@rosswarren]: https://github.com/rosswarren
707+
[@alexgorbatchev]: https://github.com/alexgorbatchev
708+
[@tihonove]: https://github.com/tihonove
709+
[@robertrossmann]: https://github.com/robertrossmann
710+
[@isiahmeadows]: https://github.com/isiahmeadows
711+
[@graingert]: https://github.com/graingert
712+
[@danny-andrews]: https://github.com/dany-andrews
713+
[@fengkfengk]: https://github.com/fengkfengk
714+
[@futpib]: https://github.com/futpib
715+
[@klimashkin]: https://github.com/klimashkin
716+
[@lukeapage]: https://github.com/lukeapage
717+
[@manovotny]: https://github.com/manovotny
718+
[@mattijsbliek]: https://github.com/mattijsbliek

README.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
1212

1313
## Rules
1414

15-
**Static analysis:**
15+
### Static analysis
1616

1717
* Ensure imports point to a file/module that can be resolved. ([`no-unresolved`])
1818
* Ensure named imports correspond to a named export in the remote file. ([`named`])
@@ -22,7 +22,10 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
2222
* Forbid import of modules using absolute paths ([`no-absolute-path`])
2323
* Forbid `require()` calls with expressions ([`no-dynamic-require`])
2424
* Prevent importing the submodules of other modules ([`no-internal-modules`])
25-
* Forbid Webpack loader syntax in imports ([`no-webpack-loader-syntax`])
25+
* Forbid webpack loader syntax in imports ([`no-webpack-loader-syntax`])
26+
* Forbid a module from importing itself ([`no-self-import`])
27+
* Forbid a module from importing a module with a dependency path back to itself ([`no-cycle`])
28+
* Prevent unnecessary path segemnts in import and require statements ([`no-useless-path-segments`])
2629

2730
[`no-unresolved`]: ./docs/rules/no-unresolved.md
2831
[`named`]: ./docs/rules/named.md
@@ -33,8 +36,11 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
3336
[`no-dynamic-require`]: ./docs/rules/no-dynamic-require.md
3437
[`no-internal-modules`]: ./docs/rules/no-internal-modules.md
3538
[`no-webpack-loader-syntax`]: ./docs/rules/no-webpack-loader-syntax.md
39+
[`no-self-import`]: ./docs/rules/no-self-import.md
40+
[`no-cycle`]: ./docs/rules/no-cycle.md
41+
[`no-useless-path-segments`]: ./docs/rules/no-useless-path-segments.md
3642

37-
**Helpful warnings:**
43+
### Helpful warnings
3844

3945

4046
* Report any invalid exports, i.e. re-export of the same name ([`export`])
@@ -51,7 +57,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
5157
[`no-extraneous-dependencies`]: ./docs/rules/no-extraneous-dependencies.md
5258
[`no-mutable-exports`]: ./docs/rules/no-mutable-exports.md
5359

54-
**Module systems:**
60+
### Module systems
5561

5662
* Report potentially ambiguous parse goal (`script` vs. `module`) ([`unambiguous`])
5763
* Report CommonJS `require` calls and `module.exports` or `exports.*`. ([`no-commonjs`])
@@ -64,7 +70,7 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
6470
[`no-nodejs-modules`]: ./docs/rules/no-nodejs-modules.md
6571

6672

67-
**Style guide:**
73+
### Style guide
6874

6975
* Ensure all imports appear before other statements ([`first`])
7076
* Ensure all exports appear after other statements ([`exports-last`])
@@ -77,7 +83,10 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
7783
* Limit the maximum number of dependencies a module can have ([`max-dependencies`])
7884
* Forbid unassigned imports ([`no-unassigned-import`])
7985
* Forbid named default exports ([`no-named-default`])
86+
* Forbid default exports ([`no-default-export`])
8087
* Forbid anonymous values as default exports ([`no-anonymous-default-export`])
88+
* Prefer named exports to be grouped together in a single export declaration ([`group-exports`])
89+
* Enforce a leading comment with the webpackChunkName for dynamic imports ([`dynamic-import-chunkname`])
8190

8291
[`first`]: ./docs/rules/first.md
8392
[`exports-last`]: ./docs/rules/exports-last.md
@@ -91,6 +100,9 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
91100
[`no-unassigned-import`]: ./docs/rules/no-unassigned-import.md
92101
[`no-named-default`]: ./docs/rules/no-named-default.md
93102
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md
103+
[`group-exports`]: ./docs/rules/group-exports.md
104+
[`no-default-export`]: ./docs/rules/no-default-export.md
105+
[`dynamic-import-chunkname`]: ./docs/rules/dynamic-import-chunkname.md
94106

95107
## Installation
96108

@@ -137,14 +149,14 @@ to find the file behind `module`.
137149
Up through v0.10ish, this plugin has directly used substack's [`resolve`] plugin,
138150
which implements Node's import behavior. This works pretty well in most cases.
139151

140-
However, Webpack allows a number of things in import module source strings that
152+
However, webpack allows a number of things in import module source strings that
141153
Node does not, such as loaders (`import 'file!./whatever'`) and a number of
142154
aliasing schemes, such as [`externals`]: mapping a module id to a global name at
143155
runtime (allowing some modules to be included more traditionally via script tags).
144156

145157
In the interest of supporting both of these, v0.11 introduces resolvers.
146158

147-
Currently [Node] and [Webpack] resolution have been implemented, but the
159+
Currently [Node] and [webpack] resolution have been implemented, but the
148160
resolvers are just npm packages, so [third party packages are supported](https://github.com/benmosher/eslint-plugin-import/wiki/Resolvers) (and encouraged!).
149161

150162
You can reference resolvers in several ways (in order of precedence):
@@ -210,7 +222,7 @@ If you are interesting in writing a resolver, see the [spec](./resolvers/README.
210222
[`externals`]: http://webpack.github.io/docs/library-and-externals.html
211223

212224
[Node]: https://www.npmjs.com/package/eslint-import-resolver-node
213-
[Webpack]: https://www.npmjs.com/package/eslint-import-resolver-webpack
225+
[webpack]: https://www.npmjs.com/package/eslint-import-resolver-webpack
214226

215227
# Settings
216228

@@ -224,6 +236,19 @@ A list of file extensions that will be parsed as modules and inspected for
224236
This defaults to `['.js']`, unless you are using the `react` shared config,
225237
in which case it is specified as `['.js', '.jsx']`.
226238

239+
```js
240+
"settings": {
241+
"import/resolver": {
242+
"node": {
243+
"extensions": [
244+
".js",
245+
".jsx"
246+
]
247+
}
248+
}
249+
}
250+
```
251+
227252
Note that this is different from (and likely a subset of) any `import/resolver`
228253
extensions settings, which may include `.json`, `.coffee`, etc. which will still
229254
factor into the `no-unresolved` rule.
@@ -282,7 +307,7 @@ An array of folders. Resolved modules only from those folders will be considered
282307
A map from parsers to file extension arrays. If a file extension is matched, the
283308
dependency parser will require and use the map key as the parser instead of the
284309
configured ESLint parser. This is useful if you're inter-op-ing with TypeScript
285-
directly using Webpack, for example:
310+
directly using webpack, for example:
286311

287312
```yaml
288313
# .eslintrc.yml

appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ install:
2121
}
2222
- npm install
2323

24+
# fix symlinks
25+
- cmd: git config core.symlinks true
26+
- cmd: git reset --hard
27+
2428
# todo: learn how to do this for all .\resolvers\* on Windows
2529
- cd .\resolvers\webpack && npm install && cd ..\..
2630
- cd .\resolvers\node && npm install && cd ..\..

config/recommended.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* @type {Object}
44
*/
55
module.exports = {
6+
plugins: ['import'],
7+
68
rules: {
79
// analysis/correctness
810
'import/no-unresolved': 'error',
@@ -14,8 +16,7 @@ module.exports = {
1416
// red flags (thus, warnings)
1517
'import/no-named-as-default': 'warn',
1618
'import/no-named-as-default-member': 'warn',
17-
'import/no-duplicates': 'warn',
18-
'import/unambiguous': 'warn',
19+
'import/no-duplicates': 'warn'
1920
},
2021

2122
// need all these for parsing dependencies (even if _your_ code doesn't need

docs/rules/default.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# default
1+
# import/default
22

33
If a default import is requested, this rule will report if there is no default
44
export in the imported module.

0 commit comments

Comments
 (0)