Skip to content

Commit 911b373

Browse files
author
Spain
committed
Merge remote-tracking branch 'origin/master' into pr-794
* origin/master: (66 commits) [Fix] unescape unnecessarily escaped regex slashes [Dev Deps] dev dep ranges should match peer dep ranges docs(readme): add space (import-js#888) bump to v2.7.0 changelog note for import-js#843 upgraded no-absolute-path to use `moduleVisitor` pattern to support all module systems PR note fixes bump to v2.6.1 to bump dep on node resolver to latest 😳 Update no-extraneous-dependencies.md (import-js#878) Fix flow interface imports giving false-negative with `named` rule bump to 2.6.0, node/0.3.1, webpack/0.8.3, memo-parser/0.2.0 chore(eslint): upgrade to eslint@4 memo-parser: require eslint >= 3.5.0 (need file path always) build on node v4, again (import-js#855) bump to v2.5.0 bump `debug` version everywhere resolvers/webpack: v0.8.2 eslint-module-utils: v2.1.1 (bumping to re-publish to npm) [Tests] comment out failing (and probably invalid) test Only apps should have lockfiles. ...
2 parents 2c47c6f + dd28130 commit 911b373

Some content is hidden

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

52 files changed

+839
-140
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ node_modules
3434
# generated output
3535
lib/
3636
**/.nyc_output/
37+
38+
# Only apps should have lockfiles
39+
yarn.lock
40+
package-lock.json
41+
npm-shrinkwrap.json

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@ language: node_js
22
node_js:
33
- 4
44
- 6
5+
- 8
56

67
os:
78
- linux
89
- osx
910

11+
env:
12+
- ESLINT_VERSION=2
13+
- ESLINT_VERSION=3
14+
- ESLINT_VERSION=4
15+
1016
install:
11-
- npm -g install npm@3
17+
- if [ ${TRAVIS_NODE_VERSION} == "4" ]; then
18+
npm install -g npm@3;
19+
fi
1220
- npm install
21+
- npm install eslint@$ESLINT_VERSION --ignore-scripts || true
1322
# install all resolver deps
1423
- "for resolver in ./resolvers/*; do cd $resolver && npm install && cd ../..; done"
1524

CHANGELOG.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,54 @@ 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+
### Fixed
9+
- [`order`]: Fix interpreting some external modules being interpreted as internal modules ([#793], [#794] thanks [@ephys])
10+
11+
## [2.7.0] - 2017-07-06
12+
### Changed
13+
- [`no-absolute-path`] picks up speed boost, optional AMD support ([#843], thansk [@jseminck])
14+
15+
## [2.6.1] - 2017-06-29
16+
### Fixed
17+
- update bundled node resolver dependency to latest version
18+
19+
## [2.6.0] - 2017-06-23
20+
### Changed
21+
- update tests / peerDeps for ESLint 4.0 compatibility ([#871], thanks [@mastilver])
22+
- [`memo-parser`] updated to require `filePath` on parser options as it melts
23+
down if it's not there, now that this plugin always provides it. (see [#863])
24+
25+
## [2.5.0] - 2017-06-22
26+
27+
Re-releasing v[2.4.0] after discovering that the memory leak is isolated to the [`memo-parser`],
28+
which is more or less experimental anyway.
29+
30+
### Added
31+
- Autofixer for newline-after-import. ([#686] + [#696], thanks [@eelyafi])
32+
33+
## [2.4.0] - 2017-06-02 [YANKED]
34+
35+
Yanked due to critical issue in eslint-module-utils with cache key resulting from [#839].
36+
37+
### Added
38+
- Add `filePath` into `parserOptions` passed to `parser` ([#839], thanks [@sompylasar])
39+
- Add `allow` option to [`no-unassigned-import`] to allow for files that match the globs ([#671], [#737], thanks [@kevin940726]).
40+
41+
## [2.3.0] - 2017-05-18
742
### Added
843
- [`no-anonymous-default-export`] rule: report anonymous default exports ([#712], thanks [@duncanbeevers]).
944
- Add new value to [`order`]'s `newlines-between` option to allow newlines inside import groups ([#627], [#628], thanks [@giodamelio])
1045
- Add `count` option to the [`newline-after-import`] rule to allow configuration of number of newlines expected ([#742], thanks [@ntdb])
1146

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

1551
### Fixed
16-
- [`order`]: Fix interpreting some external modules being interpreted as internal modules ([#793], [#794] thanks [@ephys])
1752
- attempt to fix crash in [`no-mutable-exports`]. ([#660])
1853
- "default is a reserved keyword" in no-maned-default tests by locking down babylon to 6.15.0 (#756, thanks @gmathieu)
54+
- support scoped modules containing non word characters
1955

2056

2157
## [2.2.0] - 2016-11-07
@@ -384,10 +420,16 @@ for info on changes for earlier releases.
384420
[`no-unassigned-import`]: ./docs/rules/no-unassigned-import.md
385421
[`unambiguous`]: ./docs/rules/unambiguous.md
386422
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md
423+
[`memo-parser`]: ./memo-parser/README.md
387424

388425
[#794]: https://github.com/benmosher/eslint-plugin-import/pull/794
426+
[#843]: https://github.com/benmosher/eslint-plugin-import/pull/843
427+
[#871]: https://github.com/benmosher/eslint-plugin-import/pull/871
389428
[#742]: https://github.com/benmosher/eslint-plugin-import/pull/742
429+
[#737]: https://github.com/benmosher/eslint-plugin-import/pull/737
390430
[#712]: https://github.com/benmosher/eslint-plugin-import/pull/712
431+
[#696]: https://github.com/benmosher/eslint-plugin-import/pull/696
432+
[#685]: https://github.com/benmosher/eslint-plugin-import/pull/685
391433
[#680]: https://github.com/benmosher/eslint-plugin-import/pull/680
392434
[#654]: https://github.com/benmosher/eslint-plugin-import/pull/654
393435
[#639]: https://github.com/benmosher/eslint-plugin-import/pull/639
@@ -443,6 +485,10 @@ for info on changes for earlier releases.
443485
[#314]: https://github.com/benmosher/eslint-plugin-import/pull/314
444486

445487
[#793]: https://github.com/benmosher/eslint-plugin-import/issues/793
488+
[#863]: https://github.com/benmosher/eslint-plugin-import/issues/863
489+
[#839]: https://github.com/benmosher/eslint-plugin-import/issues/839
490+
[#686]: https://github.com/benmosher/eslint-plugin-import/issues/686
491+
[#671]: https://github.com/benmosher/eslint-plugin-import/issues/671
446492
[#660]: https://github.com/benmosher/eslint-plugin-import/issues/660
447493
[#653]: https://github.com/benmosher/eslint-plugin-import/issues/653
448494
[#627]: https://github.com/benmosher/eslint-plugin-import/issues/627
@@ -500,7 +546,13 @@ for info on changes for earlier releases.
500546
[#119]: https://github.com/benmosher/eslint-plugin-import/issues/119
501547
[#89]: https://github.com/benmosher/eslint-plugin-import/issues/89
502548

503-
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.2.0...HEAD
549+
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.7.0...HEAD
550+
[2.7.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.1...v2.7.0
551+
[2.6.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.0...v2.6.1
552+
[2.6.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.5.0...v2.6.0
553+
[2.5.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.4.0...v2.5.0
554+
[2.4.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.3.0...v2.4.0
555+
[2.3.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.2.0...v2.3.0
504556
[2.2.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.1.0...v2.2.0
505557
[2.1.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.1...v2.1.0
506558
[2.0.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.0...v2.0.1
@@ -578,4 +630,10 @@ for info on changes for earlier releases.
578630
[@duncanbeevers]: https://github.com/duncanbeevers
579631
[@giodamelio]: https://github.com/giodamelio
580632
[@ntdb]: https://github.com/ntdb
633+
[@ramasilveyra]: https://github.com/ramasilveyra
634+
[@sompylasar]: https://github.com/sompylasar
635+
[@kevin940726]: https://github.com/kevin940726
636+
[@eelyafi]: https://github.com/eelyafi
637+
[@mastilver]: https://github.com/mastilver
638+
[@jseminck]: https://github.com/jseminck
581639
[@ephys]: https://github.com/ephys

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ In the interest of supporting both of these, v0.11 introduces resolvers.
145145
Currently [Node] and [Webpack] resolution have been implemented, but the
146146
resolvers are just npm packages, so [third party packages are supported](https://github.com/benmosher/eslint-plugin-import/wiki/Resolvers) (and encouraged!).
147147

148-
You can reference resolvers in several ways(in order of precedence):
148+
You can reference resolvers in several ways (in order of precedence):
149149

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

RELEASE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
```
2727

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

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

appveyor.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Test against this version of Node.js
22
environment:
33
matrix:
4-
- nodejs_version: "4"
4+
- nodejs_version: "8"
55
- nodejs_version: "6"
6+
- nodejs_version: "4"
67

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

16-
# update npm (only needed for Node 0.10)
17-
- npm -g install npm@3
18-
# - set PATH=%APPDATA%\npm;%PATH%
19-
2017
# install modules
18+
- ps: >-
19+
if ($env:nodejs_version -eq "4") {
20+
npm install -g npm@3;
21+
}
2122
- npm install
2223

2324
# todo: learn how to do this for all .\resolvers\* on Windows

docs/rules/newline-after-import.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# newline-after-import
22

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

56
## Rule Details
67

@@ -76,7 +77,7 @@ const FOO = 'BAR'
7677
{
7778
...
7879
"rules": {
79-
"import/newline-after-import": [{ "count": 2 }]
80+
"import/newline-after-import": ["error", { "count": 2 }]
8081
}
8182
}
8283
```

docs/rules/no-absolute-path.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,24 @@ var _ = require('lodash');
2525
var foo = require('foo');
2626
var foo = require('./foo');
2727
```
28+
29+
### Options
30+
31+
By default, only ES6 imports and CommonJS `require` calls will have this rule enforced.
32+
33+
You may provide an options object providing true/false for any of
34+
35+
- `esmodule`: defaults to `true`
36+
- `commonjs`: defaults to `true`
37+
- `amd`: defaults to `false`
38+
39+
If `{ amd: true }` is provided, dependency paths for AMD-style `define` and `require`
40+
calls will be resolved:
41+
42+
```js
43+
/*eslint import/no-absolute-path: [2, { commonjs: false, amd: true }]*/
44+
define(['/foo'], function (foo) { /*...*/ }) // reported
45+
require(['/foo'], function (foo) { /*...*/ }) // reported
46+
47+
const foo = require('/foo') // ignored because of explicit `commonjs: false`
48+
```

docs/rules/no-extraneous-dependencies.md

Lines changed: 9 additions & 3 deletions
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

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

8490
import test from 'ava';
8591
import find from 'lodash.find';
86-
import find from 'lodash.isarray';
92+
import isArray from 'lodash.isarray';
8793

8894
/* eslint import/no-extraneous-dependencies: ["error", {"peerDependencies": true}] */
8995
import react from 'react';

docs/rules/no-unassigned-import.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@ With both CommonJS' `require` and the ES6 modules' `import` syntax, it is possib
66

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

9+
### Options
10+
11+
This rule supports the following option:
12+
13+
`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).
14+
15+
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.
16+
17+
918
## Fail
1019

1120
```js
1221
import 'should'
1322
require('should')
23+
24+
// In <PROJECT_ROOT>/src/app.js
25+
import '../styles/app.css'
26+
// {"allow": ["styles/*.css"]}
1427
```
1528

1629

@@ -34,4 +47,13 @@ bar(require('foo'))
3447
require('foo').bar
3548
require('foo').bar()
3649
require('foo')()
50+
51+
// With allow option set
52+
import './style.css' // {"allow": ["**/*.css"]}
53+
import 'babel-register' // {"allow": ["babel-register"]}
54+
55+
// In <PROJECT_ROOT>/src/app.js
56+
import './styles/app.css'
57+
import '../scripts/register.js'
58+
// {"allow": ["src/styles/**", "**/scripts/*.js"]}
3759
```

memo-parser/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ const parserOptions = {
1717
}
1818

1919
exports.parse = function parse(content, options) {
20-
// them defaults yo
2120
options = Object.assign({}, options, parserOptions)
2221

22+
if (!options.filePath) {
23+
throw new Error("no file path provided!")
24+
}
25+
2326
const keyHash = crypto.createHash('sha256')
2427
keyHash.update(content)
2528
hashObject(options, keyHash)

memo-parser/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"name": "memo-parser",
3-
"version": "0.1.0",
4-
"engines": { "node": ">=4" },
3+
"version": "0.2.0",
4+
"engines": {
5+
"node": ">=4"
6+
},
57
"description": "Memoizing wrapper for any ESLint-compatible parser module.",
68
"main": "index.js",
79
"scripts": {
@@ -21,5 +23,8 @@
2123
"bugs": {
2224
"url": "https://github.com/benmosher/eslint-plugin-import/issues"
2325
},
24-
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme"
26+
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme",
27+
"peerDependencies": {
28+
"eslint": ">=3.5.0"
29+
}
2530
}

package.json

Lines changed: 10 additions & 9 deletions
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.7.0",
44
"description": "Import with sanity.",
55
"engines": {
66
"node": ">=4"
@@ -51,12 +51,12 @@
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",
5555
"babylon": "6.15.0",
5656
"chai": "^3.4.0",
5757
"coveralls": "^2.11.4",
58-
"cross-env": "^3.1.0",
59-
"eslint": "3.x",
58+
"cross-env": "^4.0.0",
59+
"eslint": "2.x - 4.x",
6060
"eslint-import-resolver-node": "file:./resolvers/node",
6161
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
6262
"eslint-module-utils": "file:./utils",
@@ -70,19 +70,20 @@
7070
"nyc": "^8.3.0",
7171
"redux": "^3.0.4",
7272
"rimraf": "2.5.2",
73+
"sinon": "^2.3.2",
7374
"typescript": "^2.0.3",
74-
"typescript-eslint-parser": "^1.0.0"
75+
"typescript-eslint-parser": "^2.1.0"
7576
},
7677
"peerDependencies": {
77-
"eslint": "2.x - 3.x"
78+
"eslint": "2.x - 4.x"
7879
},
7980
"dependencies": {
8081
"builtin-modules": "^1.1.1",
8182
"contains-path": "^0.1.0",
82-
"debug": "^2.2.0",
83+
"debug": "^2.6.8",
8384
"doctrine": "1.5.0",
84-
"eslint-import-resolver-node": "^0.2.0",
85-
"eslint-module-utils": "^2.0.0",
85+
"eslint-import-resolver-node": "^0.3.1",
86+
"eslint-module-utils": "^2.1.1",
8687
"has": "^1.0.1",
8788
"lodash.cond": "^4.3.0",
8889
"minimatch": "^3.0.3",

0 commit comments

Comments
 (0)