Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f46dc45

Browse files
committed
Merge branch 'master' into support-ts-resolver-v2
2 parents 1ed020e + 4e8960d commit f46dc45

Some content is hidden

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

51 files changed

+1242
-144
lines changed

CHANGELOG.md

Lines changed: 86 additions & 36 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,20 @@ settings:
402402
[`eslint_d`]: https://www.npmjs.com/package/eslint_d
403403
[`eslint-loader`]: https://www.npmjs.com/package/eslint-loader
404404

405+
#### `import/internal-regex`
406+
407+
A regex for packages should be treated as internal. Useful when you are utilizing a monorepo setup or developing a set of packages that depend on each other.
408+
409+
By default, any package referenced from [`import/external-module-folders`](#importexternal-module-folders) will be considered as "external", including packages in a monorepo like yarn workspace or lerna emvironentment. If you want to mark these packages as "internal" this will be useful.
410+
411+
For example, if you pacakges in a monorepo are all in `@scope`, you can configure `import/internal-regex` like this
412+
413+
```yaml
414+
# .eslintrc.yml
415+
settings:
416+
import/internal-regex: ^@scope/
417+
```
418+
405419

406420
## SublimeLinter-eslint
407421

docs/rules/no-commonjs.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,30 @@ If `allowRequire` option is set to `true`, `require` calls are valid:
2727

2828
```js
2929
/*eslint no-commonjs: [2, { allowRequire: true }]*/
30+
var mod = require('./mod');
31+
```
32+
33+
but `module.exports` is reported as usual.
34+
35+
### Allow conditional require
36+
37+
By default, conditional requires are allowed:
38+
39+
```js
40+
var a = b && require("c")
3041

3142
if (typeof window !== "undefined") {
3243
require('that-ugly-thing');
3344
}
45+
46+
var fs = null;
47+
try {
48+
fs = require("fs")
49+
} catch (error) {}
3450
```
3551

36-
but `module.exports` is reported as usual.
52+
If the `allowConditionalRequire` option is set to `false`, they will be reported.
3753

38-
This is useful for conditional requires.
3954
If you don't rely on synchronous module loading, check out [dynamic import](https://github.com/airbnb/babel-plugin-dynamic-import-node).
4055

4156
### Allow primitive modules

docs/rules/no-duplicates.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ The motivation is that this is likely a result of two developers importing diffe
3636
names from the same module at different times (and potentially largely different
3737
locations in the file.) This rule brings both (or n-many) to attention.
3838

39+
### Query Strings
40+
41+
By default, this rule ignores query strings (i.e. paths followed by a question mark), and thus imports from `./mod?a` and `./mod?b` will be considered as duplicates. However you can use the option `considerQueryString` to handle them as different (primarily because browsers will resolve those imports differently).
42+
43+
Config:
44+
45+
```json
46+
"import/no-duplicates": ["error", {"considerQueryString": true}]
47+
```
48+
49+
And then the following code becomes valid:
50+
```js
51+
import minifiedMod from './mod?minify'
52+
import noCommentsMod from './mod?comments=0'
53+
import originalMod from './mod'
54+
```
55+
56+
It will still catch duplicates when using the same module and the exact same query string:
57+
```js
58+
import SomeDefaultClass from './mod?minify'
59+
60+
// This is invalid, assuming `./mod` and `./mod.js` are the same target:
61+
import * from './mod.js?minify'
62+
```
63+
3964
## When Not To Use It
4065

4166
If the core ESLint version is good enough (i.e. you're _not_ using Flow and you _are_ using [`import/extensions`](./extensions.md)), keep it and don't use this.

docs/rules/no-useless-path-segments.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ import "./pages/index.js"; // should be "./pages" (auto-fixable)
7373
```
7474

7575
Note: `noUselessIndex` only avoids ambiguous imports for `.js` files if you haven't specified other resolved file extensions. See [Settings: import/extensions](https://github.com/benmosher/eslint-plugin-import#importextensions) for details.
76+
77+
### commonjs
78+
79+
When set to `true`, this rule checks CommonJS imports. Default to `false`.

docs/rules/order.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,33 @@ You can set the options like this:
9494
"import/order": ["error", {"groups": ["index", "sibling", "parent", "internal", "external", "builtin"]}]
9595
```
9696

97-
### `newlines-between: [ignore|always|always-and-inside-groups|never]`:
97+
### `pathGroups: [array of objects]`:
98+
99+
To be able so group by paths mostly needed with aliases pathGroups can be defined.
100+
101+
Properties of the objects
102+
103+
| property | required | type | description |
104+
|----------------|:--------:|--------|---------------|
105+
| pattern | x | string | minimatch pattern for the paths to be in this group (will not be used for builtins or externals) |
106+
| patternOptions | | object | options for minimatch, default: { nocomment: true } |
107+
| group | x | string | one of the allowed groups, the pathGroup will be positioned relative to this group |
108+
| position | | string | defines where around the group the pathGroup will be positioned, can be 'after' or 'before', if not provided pathGroup will be positioned like the group |
109+
110+
```json
111+
{
112+
"import/order": ["error", {
113+
"pathGroups": [
114+
{
115+
"pattern": "~/**",
116+
"group": "external"
117+
}
118+
]
119+
}]
120+
}
121+
```
98122

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

100125
Enforces or forbids new lines between import groups:
101126

@@ -164,8 +189,45 @@ import index from './';
164189
import sibling from './foo';
165190
```
166191

192+
### `alphabetize: {order: asc|desc|ignore}`:
193+
194+
Sort the order within each group in alphabetical manner based on **import path**:
195+
196+
- `order`: use `asc` to sort in ascending order, and `desc` to sort in descending order (default: `ignore`).
197+
198+
Example setting:
199+
```js
200+
alphabetize: {
201+
order: 'asc', /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */
202+
}
203+
```
204+
205+
This will fail the rule check:
206+
207+
```js
208+
/* eslint import/order: ["error", {"alphabetize": true}] */
209+
import React, { PureComponent } from 'react';
210+
import aTypes from 'prop-types';
211+
import { compose, apply } from 'xcompose';
212+
import * as classnames from 'classnames';
213+
```
214+
215+
While this will pass:
216+
217+
```js
218+
/* eslint import/order: ["error", {"alphabetize": true}] */
219+
import * as classnames from 'classnames';
220+
import aTypes from 'prop-types';
221+
import React, { PureComponent } from 'react';
222+
import { compose, apply } from 'xcompose';
223+
```
224+
167225
## Related
168226

169227
- [`import/external-module-folders`] setting
170228

229+
- [`import/internal-regex`] setting
230+
171231
[`import/external-module-folders`]: ../../README.md#importexternal-module-folders
232+
233+
[`import/internal-regex`]: ../../README.md#importinternal-regex

memo-parser/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme",
2727
"peerDependencies": {
2828
"eslint": ">=3.5.0"
29+
},
30+
"dependencies": {
31+
"eslint-module-utils": "^2.5.0"
2932
}
3033
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-import",
3-
"version": "2.18.2",
3+
"version": "2.19.1",
44
"description": "Import with sanity.",
55
"engines": {
66
"node": ">=4"

resolvers/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"homepage": "https://github.com/benmosher/eslint-plugin-import",
3030
"dependencies": {
3131
"debug": "^2.6.9",
32-
"resolve": "^1.10.0"
32+
"resolve": "^1.13.1"
3333
},
3434
"devDependencies": {
3535
"chai": "^3.5.0",

resolvers/webpack/CHANGELOG.md

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

66
## Unreleased
77

8+
## 0.12.0 - 2019-12-07
9+
10+
### Added
11+
- [New] enable passing cwd as an option to `eslint-import-resolver-webpack` ([#1503], thanks [@Aghassi])
12+
813
## 0.11.1 - 2019-04-13
914

1015
### Fixed
@@ -117,6 +122,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
117122
- `interpret` configs (such as `.babel.js`).
118123
Thanks to [@gausie] for the initial PR ([#164], ages ago! 😅) and [@jquense] for tests ([#278]).
119124

125+
[#1503]: https://github.com/benmosher/eslint-plugin-import/pull/1503
120126
[#1297]: https://github.com/benmosher/eslint-plugin-import/pull/1297
121127
[#1261]: https://github.com/benmosher/eslint-plugin-import/pull/1261
122128
[#1220]: https://github.com/benmosher/eslint-plugin-import/pull/1220
@@ -166,3 +172,4 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
166172
[@mattkrick]: https://github.com/mattkrick
167173
[@idudinov]: https://github.com/idudinov
168174
[@keann]: https://github.com/keann
175+
[@Aghassi]: https://github.com/Aghassi

0 commit comments

Comments
 (0)