Bump eslint-plugin-import to avoid vulnerability in dependency
This commit is contained in:
parent
10695e6a20
commit
ed9506bbaf
1660 changed files with 67726 additions and 27926 deletions
91
node_modules/eslint-plugin-import/docs/rules/consistent-type-specifier-style.md
generated
vendored
Normal file
91
node_modules/eslint-plugin-import/docs/rules/consistent-type-specifier-style.md
generated
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# import/consistent-type-specifier-style
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
In both Flow and TypeScript you can mark an import as a type-only import by adding a "kind" marker to the import. Both languages support two positions for marker.
|
||||
|
||||
**At the top-level** which marks all names in the import as type-only and applies to named, default, and namespace (for TypeScript) specifiers:
|
||||
|
||||
```ts
|
||||
import type Foo from 'Foo';
|
||||
import type {Bar} from 'Bar';
|
||||
// ts only
|
||||
import type * as Bam from 'Bam';
|
||||
// flow only
|
||||
import typeof Baz from 'Baz';
|
||||
```
|
||||
|
||||
**Inline** with to the named import, which marks just the specific name in the import as type-only. An inline specifier is only valid for named specifiers, and not for default or namespace specifiers:
|
||||
|
||||
```ts
|
||||
import {type Foo} from 'Foo';
|
||||
// flow only
|
||||
import {typeof Bar} from 'Bar';
|
||||
```
|
||||
|
||||
## Rule Details
|
||||
|
||||
This rule either enforces or bans the use of inline type-only markers for named imports.
|
||||
|
||||
This rule includes a fixer that will automatically convert your specifiers to the correct form - however the fixer will not respect your preferences around de-duplicating imports. If this is important to you, consider using the [`import/no-duplicates`] rule.
|
||||
|
||||
[`import/no-duplicates`]: ./no-duplicates.md
|
||||
|
||||
## Options
|
||||
|
||||
The rule accepts a single string option which may be one of:
|
||||
|
||||
- `'prefer-inline'` - enforces that named type-only specifiers are only ever written with an inline marker; and never as part of a top-level, type-only import.
|
||||
- `'prefer-top-level'` - enforces that named type-only specifiers only ever written as part of a top-level, type-only import; and never with an inline marker.
|
||||
|
||||
By default the rule will use the `prefer-inline` option.
|
||||
|
||||
## Examples
|
||||
|
||||
### `prefer-top-level`
|
||||
|
||||
❌ Invalid with `["error", "prefer-top-level"]`
|
||||
|
||||
```ts
|
||||
import {type Foo} from 'Foo';
|
||||
import Foo, {type Bar} from 'Foo';
|
||||
// flow only
|
||||
import {typeof Foo} from 'Foo';
|
||||
```
|
||||
|
||||
✅ Valid with `["error", "prefer-top-level"]`
|
||||
|
||||
```ts
|
||||
import type {Foo} from 'Foo';
|
||||
import type Foo, {Bar} from 'Foo';
|
||||
// flow only
|
||||
import typeof {Foo} from 'Foo';
|
||||
```
|
||||
|
||||
### `prefer-inline`
|
||||
|
||||
❌ Invalid with `["error", "prefer-inline"]`
|
||||
|
||||
```ts
|
||||
import type {Foo} from 'Foo';
|
||||
import type Foo, {Bar} from 'Foo';
|
||||
// flow only
|
||||
import typeof {Foo} from 'Foo';
|
||||
```
|
||||
|
||||
✅ Valid with `["error", "prefer-inline"]`
|
||||
|
||||
```ts
|
||||
import {type Foo} from 'Foo';
|
||||
import Foo, {type Bar} from 'Foo';
|
||||
// flow only
|
||||
import {typeof Foo} from 'Foo';
|
||||
```
|
||||
|
||||
## When Not To Use It
|
||||
|
||||
If you aren't using Flow or TypeScript 4.5+, then this rule does not apply and need not be used.
|
||||
|
||||
If you don't care about, and don't want to standardize how named specifiers are imported then you should not use this rule.
|
||||
4
node_modules/eslint-plugin-import/docs/rules/default.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/default.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/default
|
||||
|
||||
💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
If a default import is requested, this rule will report if there is no default
|
||||
export in the imported module.
|
||||
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/dynamic-import-chunkname.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/dynamic-import-chunkname.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# dynamic imports require a leading comment with a webpackChunkName (dynamic-import-chunkname)
|
||||
# import/dynamic-import-chunkname
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
This rule reports any dynamic imports without a webpackChunkName specified in a leading block comment in the proper format.
|
||||
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/export.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/export.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/export
|
||||
|
||||
💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports funny business with exports, like repeated exports of names or defaults.
|
||||
|
||||
## Rule Details
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/exports-last.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/exports-last.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/exports-last
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
This rule enforces that all exports are declared at the bottom of the file. This rule will report any export declarations that comes before any non-export statements.
|
||||
|
||||
|
||||
|
|
|
|||
13
node_modules/eslint-plugin-import/docs/rules/extensions.md
generated
vendored
13
node_modules/eslint-plugin-import/docs/rules/extensions.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# import/extensions - Ensure consistent use of file extension within the import path
|
||||
# import/extensions
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Some file resolve algorithms allow you to omit the file extension within the import source path. For example the `node` resolver can resolve `./foo/bar` to the absolute path `/User/someone/foo/bar.js` because the `.js` extension is resolved automatically by default. Depending on the resolver you can configure more extensions to get resolved automatically.
|
||||
|
||||
|
|
@ -37,6 +39,7 @@ By providing both a string and an object, the string will set the default settin
|
|||
For example, `["error", "never", { "svg": "always" }]` would require that all extensions are omitted, except for "svg".
|
||||
|
||||
`ignorePackages` can be set as a separate boolean option like this:
|
||||
|
||||
```
|
||||
"import/extensions": [
|
||||
<severity>,
|
||||
|
|
@ -49,10 +52,10 @@ For example, `["error", "never", { "svg": "always" }]` would require that all ex
|
|||
}
|
||||
]
|
||||
```
|
||||
|
||||
In that case, if you still want to specify extensions, you can do so inside the **pattern** property.
|
||||
Default value of `ignorePackages` is `false`.
|
||||
|
||||
|
||||
### Exception
|
||||
|
||||
When disallowing the use of certain extensions this rule makes an exception and allows the use of extension when the file would not be resolvable without extension.
|
||||
|
|
@ -109,6 +112,8 @@ import foo from './foo';
|
|||
import bar from './bar';
|
||||
|
||||
import Component from './Component';
|
||||
|
||||
import foo from '@/foo';
|
||||
```
|
||||
|
||||
The following patterns are not considered problems when configuration set to "always":
|
||||
|
|
@ -121,6 +126,8 @@ import bar from './bar.json';
|
|||
import Component from './Component.jsx';
|
||||
|
||||
import * as path from 'path';
|
||||
|
||||
import foo from '@/foo.js';
|
||||
```
|
||||
|
||||
The following patterns are considered problems when configuration set to "ignorePackages":
|
||||
|
|
@ -145,6 +152,7 @@ import Component from './Component.jsx';
|
|||
|
||||
import express from 'express';
|
||||
|
||||
import foo from '@/foo'
|
||||
```
|
||||
|
||||
The following patterns are not considered problems when configuration set to `['error', 'always', {ignorePackages: true} ]`:
|
||||
|
|
@ -156,6 +164,7 @@ import baz from 'foo/baz.js';
|
|||
|
||||
import express from 'express';
|
||||
|
||||
import foo from '@/foo';
|
||||
```
|
||||
|
||||
## When Not To Use It
|
||||
|
|
|
|||
6
node_modules/eslint-plugin-import/docs/rules/first.md
generated
vendored
6
node_modules/eslint-plugin-import/docs/rules/first.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/first
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
This rule reports any imports that come after non-import
|
||||
statements.
|
||||
|
||||
|
|
@ -45,7 +49,7 @@ A directive in this case is assumed to be a single statement that contains only
|
|||
a literal string-valued expression.
|
||||
|
||||
`'use strict'` would be a good example, except that [modules are always in strict
|
||||
mode](http://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-code) so it would be surprising to see a `'use strict'` sharing a file with `import`s and
|
||||
mode](https://262.ecma-international.org/6.0/#sec-strict-mode-code) so it would be surprising to see a `'use strict'` sharing a file with `import`s and
|
||||
`export`s.
|
||||
|
||||
Given that, see [#255] for the reasoning.
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/group-exports.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/group-exports.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/group-exports
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports when named exports are not grouped together in a single `export` declaration or when multiple assignments to CommonJS `module.exports` or `exports` object are present in a single file.
|
||||
|
||||
**Rationale:** An `export` declaration or `module.exports` assignment can appear anywhere in the code. By requiring a single export declaration all your exports will remain at one place, making it easier to see what exports a module provides.
|
||||
|
|
|
|||
10
node_modules/eslint-plugin-import/docs/rules/imports-first.md
generated
vendored
10
node_modules/eslint-plugin-import/docs/rules/imports-first.md
generated
vendored
|
|
@ -1,3 +1,9 @@
|
|||
# imports-first
|
||||
# import/imports-first
|
||||
|
||||
This rule was **deprecated** in eslint-plugin-import v2.0.0. Please use the corresponding rule [`first`](https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/first.md).
|
||||
❌ This rule is deprecated.
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
This rule was **deprecated** in eslint-plugin-import v2.0.0. Please use the corresponding rule [`first`](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/first.md).
|
||||
|
|
|
|||
40
node_modules/eslint-plugin-import/docs/rules/max-dependencies.md
generated
vendored
40
node_modules/eslint-plugin-import/docs/rules/max-dependencies.md
generated
vendored
|
|
@ -1,25 +1,27 @@
|
|||
# import/max-dependencies
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Forbid modules to have too many dependencies (`import` or `require` statements).
|
||||
|
||||
This is a useful rule because a module with too many dependencies is a code smell, and usually indicates the module is doing too much and/or should be broken up into smaller modules.
|
||||
|
||||
Importing multiple named exports from a single module will only count once (e.g. `import {x, y, z} from './foo'` will only count as a single dependency).
|
||||
|
||||
### Options
|
||||
## Options
|
||||
|
||||
This rule takes the following option:
|
||||
|
||||
`max`: The maximum number of dependencies allowed. Anything over will trigger the rule. **Default is 10** if the rule is enabled and no `max` is specified.
|
||||
|
||||
You can set the option like this:
|
||||
This rule has the following options, with these defaults:
|
||||
|
||||
```js
|
||||
"import/max-dependencies": ["error", {"max": 10}]
|
||||
"import/max-dependencies": ["error", {
|
||||
"max": 10,
|
||||
"ignoreTypeImports": false,
|
||||
}]
|
||||
```
|
||||
|
||||
### `max`
|
||||
|
||||
## Example
|
||||
This option sets the maximum number of dependencies allowed. Anything over will trigger the rule. **Default is 10** if the rule is enabled and no `max` is specified.
|
||||
|
||||
Given a max value of `{"max": 2}`:
|
||||
|
||||
|
|
@ -39,6 +41,28 @@ const anotherA = require('./a'); // still 1
|
|||
import {x, y, z} from './foo'; // 2
|
||||
```
|
||||
|
||||
### `ignoreTypeImports`
|
||||
|
||||
Ignores `type` imports. Type imports are a feature released in TypeScript 3.8, you can [read more here](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export). Defaults to `false`.
|
||||
|
||||
Given `{"max": 2, "ignoreTypeImports": true}`:
|
||||
|
||||
### Fail
|
||||
|
||||
```ts
|
||||
import a from './a';
|
||||
import b from './b';
|
||||
import c from './c';
|
||||
```
|
||||
|
||||
### Pass
|
||||
|
||||
```ts
|
||||
import a from './a';
|
||||
import b from './b';
|
||||
import type c from './c'; // Doesn't count against max
|
||||
```
|
||||
|
||||
## When Not To Use It
|
||||
|
||||
If you don't care how many dependencies a module has.
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/named.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/named.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/named
|
||||
|
||||
💼🚫 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`. This rule is _disabled_ in the ⌨️ `typescript` config.
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Verifies that all named imports are part of the set of named exports in the referenced module.
|
||||
|
||||
For `export`, verifies that all named exports exist in the referenced module.
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/namespace.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/namespace.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/namespace
|
||||
|
||||
💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Enforces names exist at the time they are dereferenced, when imported as a full namespace (i.e. `import * as foo from './foo'; foo.bar();` will report if `bar` is not exported by `./foo`.).
|
||||
|
||||
Will report at the import declaration if there are _no_ exported names found.
|
||||
|
|
|
|||
33
node_modules/eslint-plugin-import/docs/rules/newline-after-import.md
generated
vendored
33
node_modules/eslint-plugin-import/docs/rules/newline-after-import.md
generated
vendored
|
|
@ -1,11 +1,18 @@
|
|||
# import/newline-after-import
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
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
|
||||
|
||||
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`.
|
||||
This rule supports the following options:
|
||||
- `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`.
|
||||
|
||||
- `considerComments` which enforces the rule on comments after the last import-statement as well when set to true. This option defaults to `false`.
|
||||
|
||||
Valid:
|
||||
|
||||
|
|
@ -71,6 +78,30 @@ import defaultExport from './foo'
|
|||
const FOO = 'BAR'
|
||||
```
|
||||
|
||||
With `considerComments` set to `false` this will be considered valid:
|
||||
|
||||
```js
|
||||
import defaultExport from './foo'
|
||||
// some comment here.
|
||||
const FOO = 'BAR'
|
||||
```
|
||||
|
||||
With `considerComments` set to `true` this will be considered valid:
|
||||
|
||||
```js
|
||||
import defaultExport from './foo'
|
||||
|
||||
// some comment here.
|
||||
const FOO = 'BAR'
|
||||
```
|
||||
|
||||
With `considerComments` set to `true` this will be considered invalid:
|
||||
|
||||
```js
|
||||
import defaultExport from './foo'
|
||||
// some comment here.
|
||||
const FOO = 'BAR'
|
||||
```
|
||||
|
||||
## Example options usage
|
||||
```json
|
||||
|
|
|
|||
8
node_modules/eslint-plugin-import/docs/rules/no-absolute-path.md
generated
vendored
8
node_modules/eslint-plugin-import/docs/rules/no-absolute-path.md
generated
vendored
|
|
@ -1,7 +1,13 @@
|
|||
# import/no-absolute-path: Forbid import of modules using absolute paths
|
||||
# import/no-absolute-path
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Node.js allows the import of modules using an absolute path such as `/home/xyz/file.js`. That is a bad practice as it ties the code using it to your computer, and therefore makes it unusable in packages distributed on `npm` for instance.
|
||||
|
||||
This rule forbids the import of modules using absolute paths.
|
||||
|
||||
## Rule Details
|
||||
|
||||
### Fail
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/no-amd.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/no-amd.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-amd
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports `require([array], ...)` and `define([array], ...)` function calls at the
|
||||
module scope. Will not report if !=2 arguments, or first argument is not a literal array.
|
||||
|
||||
|
|
|
|||
8
node_modules/eslint-plugin-import/docs/rules/no-anonymous-default-export.md
generated
vendored
8
node_modules/eslint-plugin-import/docs/rules/no-anonymous-default-export.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-anonymous-default-export
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
@ -17,6 +19,7 @@ The complete default configuration looks like this.
|
|||
"allowAnonymousClass": false,
|
||||
"allowAnonymousFunction": false,
|
||||
"allowCallExpression": true, // The true value here is for backward compatibility
|
||||
"allowNew": false,
|
||||
"allowLiteral": false,
|
||||
"allowObject": false
|
||||
}]
|
||||
|
|
@ -40,6 +43,8 @@ export default foo(bar)
|
|||
export default 123
|
||||
|
||||
export default {}
|
||||
|
||||
export default new Foo()
|
||||
```
|
||||
|
||||
### Pass
|
||||
|
|
@ -70,4 +75,7 @@ export default 123
|
|||
|
||||
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
|
||||
export default {}
|
||||
|
||||
/* eslint import/no-anonymous-default-export: [2, {"allowNew": true}] */
|
||||
export default new Foo()
|
||||
```
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/no-commonjs.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/no-commonjs.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-commonjs
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports `require([string])` function calls. Will not report if >1 argument,
|
||||
or single argument is not a literal string.
|
||||
|
||||
|
|
|
|||
20
node_modules/eslint-plugin-import/docs/rules/no-cycle.md
generated
vendored
20
node_modules/eslint-plugin-import/docs/rules/no-cycle.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-cycle
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Ensures that there is no resolvable path back to this module via its dependencies.
|
||||
|
||||
This includes cycles of depth 1 (imported module imports me) to `"∞"` (or `Infinity`), if the
|
||||
|
|
@ -20,6 +22,8 @@ import { b } from './dep-b.js' // reported: Dependency cycle detected.
|
|||
This rule does _not_ detect imports that resolve directly to the linted module;
|
||||
for that, see [`no-self-import`].
|
||||
|
||||
This rule ignores type-only imports in Flow and TypeScript syntax (`import type` and `import typeof`), which have no runtime effect.
|
||||
|
||||
|
||||
## Rule Details
|
||||
|
||||
|
|
@ -75,6 +79,22 @@ import { a } from './dep-a.js' // not reported as this module is external
|
|||
|
||||
Its value is `false` by default, but can be set to `true` for reducing total project lint time, if needed.
|
||||
|
||||
#### `allowUnsafeDynamicCyclicDependency`
|
||||
|
||||
This option disable reporting of errors if a cycle is detected with at least one dynamic import.
|
||||
|
||||
```js
|
||||
// bar.js
|
||||
import { foo } from './foo';
|
||||
export const bar = foo;
|
||||
|
||||
// foo.js
|
||||
export const foo = 'Foo';
|
||||
export function getBar() { return import('./bar'); }
|
||||
```
|
||||
|
||||
> Cyclic dependency are **always** a dangerous anti-pattern as discussed extensively in [#2265](https://github.com/import-js/eslint-plugin-import/issues/2265). Please be extra careful about using this option.
|
||||
|
||||
## When Not To Use It
|
||||
|
||||
This rule is comparatively computationally expensive. If you are pressed for lint
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-default-export.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-default-export.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# `import/no-default-export`
|
||||
# import/no-default-export
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Prohibit default exports. Mostly an inverse of [`prefer-default-export`].
|
||||
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-deprecated.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-deprecated.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# `import/no-deprecated`
|
||||
# import/no-deprecated
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports use of a deprecated name, as indicated by a JSDoc block with a `@deprecated`
|
||||
tag or TomDoc `Deprecated: ` comment.
|
||||
|
|
|
|||
35
node_modules/eslint-plugin-import/docs/rules/no-duplicates.md
generated
vendored
35
node_modules/eslint-plugin-import/docs/rules/no-duplicates.md
generated
vendored
|
|
@ -1,9 +1,15 @@
|
|||
# import/no-duplicates
|
||||
|
||||
⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports if a resolved path is imported more than once.
|
||||
+(fixable) The `--fix` option on the [command line] automatically fixes some problems reported by this rule.
|
||||
|
||||
ESLint core has a similar rule ([`no-duplicate-imports`](http://eslint.org/docs/rules/no-duplicate-imports)), but this version
|
||||
ESLint core has a similar rule ([`no-duplicate-imports`](https://eslint.org/docs/rules/no-duplicate-imports)), but this version
|
||||
is different in two key ways:
|
||||
|
||||
1. the paths in the source code don't have to exactly match, they just have to point to the same module on the filesystem. (i.e. `./foo` and `./foo.js`)
|
||||
|
|
@ -61,6 +67,33 @@ import SomeDefaultClass from './mod?minify'
|
|||
import * from './mod.js?minify'
|
||||
```
|
||||
|
||||
### Inline Type imports
|
||||
|
||||
TypeScript 4.5 introduced a new [feature](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#type-on-import-names) that allows mixing of named value and type imports. In order to support fixing to an inline type import when duplicate imports are detected, `prefer-inline` can be set to true.
|
||||
|
||||
Config:
|
||||
|
||||
```json
|
||||
"import/no-duplicates": ["error", {"prefer-inline": true}]
|
||||
```
|
||||
|
||||
<!--tabs-->
|
||||
|
||||
❌ Invalid `["error", "prefer-inline"]`
|
||||
|
||||
```js
|
||||
import { AValue, type AType } from './mama-mia'
|
||||
import type { BType } from './mama-mia'
|
||||
```
|
||||
|
||||
✅ Valid with `["error", "prefer-inline"]`
|
||||
|
||||
```js
|
||||
import { AValue, type AType, type BType } from './mama-mia'
|
||||
```
|
||||
|
||||
<!--tabs-->
|
||||
|
||||
## When Not To Use It
|
||||
|
||||
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.
|
||||
|
|
|
|||
6
node_modules/eslint-plugin-import/docs/rules/no-dynamic-require.md
generated
vendored
6
node_modules/eslint-plugin-import/docs/rules/no-dynamic-require.md
generated
vendored
|
|
@ -1,8 +1,10 @@
|
|||
# import/no-dynamic-require: Forbid `require()` calls with expressions
|
||||
# import/no-dynamic-require
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
The `require` method from CommonJS is used to import modules from different files. Unlike the ES6 `import` syntax, it can be given expressions that will be resolved at runtime. While this is sometimes necessary and useful, in most cases it isn't. Using expressions (for instance, concatenating a path and variable) as the argument makes it harder for tools to do static code analysis, or to find where in the codebase a module is used.
|
||||
|
||||
This rule checks every call to `require()` that uses expressions for the module name argument.
|
||||
This rule forbids every call to `require()` that uses expressions for the module name argument.
|
||||
|
||||
## Rule Details
|
||||
|
||||
|
|
|
|||
43
node_modules/eslint-plugin-import/docs/rules/no-empty-named-blocks.md
generated
vendored
Normal file
43
node_modules/eslint-plugin-import/docs/rules/no-empty-named-blocks.md
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# import/no-empty-named-blocks
|
||||
|
||||
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports the use of empty named import blocks.
|
||||
|
||||
## Rule Details
|
||||
|
||||
### Valid
|
||||
```js
|
||||
import { mod } from 'mod'
|
||||
import Default, { mod } from 'mod'
|
||||
```
|
||||
|
||||
When using typescript
|
||||
```js
|
||||
import type { mod } from 'mod'
|
||||
```
|
||||
|
||||
When using flow
|
||||
```js
|
||||
import typeof { mod } from 'mod'
|
||||
```
|
||||
|
||||
### Invalid
|
||||
```js
|
||||
import {} from 'mod'
|
||||
import Default, {} from 'mod'
|
||||
```
|
||||
|
||||
When using typescript
|
||||
```js
|
||||
import type Default, {} from 'mod'
|
||||
import type {} from 'mod'
|
||||
```
|
||||
|
||||
When using flow
|
||||
```js
|
||||
import typeof {} from 'mod'
|
||||
import typeof Default, {} from 'mod'
|
||||
```
|
||||
20
node_modules/eslint-plugin-import/docs/rules/no-extraneous-dependencies.md
generated
vendored
20
node_modules/eslint-plugin-import/docs/rules/no-extraneous-dependencies.md
generated
vendored
|
|
@ -1,7 +1,9 @@
|
|||
# import/no-extraneous-dependencies: Forbid the use of extraneous packages
|
||||
# import/no-extraneous-dependencies
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Forbid the import of external modules that are not declared in the `package.json`'s `dependencies`, `devDependencies`, `optionalDependencies`, `peerDependencies`, or `bundledDependencies`.
|
||||
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behavior can be changed with the rule option `packageDir`.
|
||||
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behavior can be changed with the rule option `packageDir`. Normally ignores imports of modules marked internal, but this can be changed with the rule option `includeInternal`. Type imports can be verified by specifying `includeTypes`.
|
||||
|
||||
Modules have to be installed for this rule to work.
|
||||
|
||||
|
|
@ -31,6 +33,12 @@ You can also use an array of globs instead of literal booleans:
|
|||
|
||||
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.
|
||||
|
||||
There are 2 boolean options to opt into checking extra imports that are normally ignored: `includeInternal`, which enables the checking of internal modules, and `includeTypes`, which enables checking of type imports in TypeScript.
|
||||
|
||||
```js
|
||||
"import/no-extraneous-dependencies": ["error", {"includeInternal": true, "includeTypes": true}]
|
||||
```
|
||||
|
||||
Also there is one more option called `packageDir`, this option is to specify the path to the folder containing package.json.
|
||||
|
||||
If provided as a relative path string, will be computed relative to the current working directory at linter execution time. If this is not ideal (does not work with some editor integrations), consider using `__dirname` to provide a path relative to your configuration.
|
||||
|
|
@ -99,6 +107,13 @@ var isArray = require('lodash.isarray');
|
|||
/* eslint import/no-extraneous-dependencies: ["error", {"bundledDependencies": false}] */
|
||||
import foo from '"@generated/foo"';
|
||||
var foo = require('"@generated/foo"');
|
||||
|
||||
/* eslint import/no-extraneous-dependencies: ["error", {"includeInternal": true}] */
|
||||
import foo from './foo';
|
||||
var foo = require('./foo');
|
||||
|
||||
/* eslint import/no-extraneous-dependencies: ["error", {"includeTypes": true}] */
|
||||
import type { MyType } from 'foo';
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -113,6 +128,7 @@ import test from 'ava';
|
|||
import find from 'lodash.find';
|
||||
import isArray from 'lodash.isarray';
|
||||
import foo from '"@generated/foo"';
|
||||
import type { MyType } from 'foo';
|
||||
|
||||
/* eslint import/no-extraneous-dependencies: ["error", {"peerDependencies": true}] */
|
||||
import react from 'react';
|
||||
|
|
|
|||
6
node_modules/eslint-plugin-import/docs/rules/no-import-module-exports.md
generated
vendored
6
node_modules/eslint-plugin-import/docs/rules/no-import-module-exports.md
generated
vendored
|
|
@ -1,4 +1,8 @@
|
|||
# no-import-module-exports
|
||||
# import/no-import-module-exports
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports the use of import declarations with CommonJS exports in any module
|
||||
except for the [main module](https://docs.npmjs.com/files/package.json#main).
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/no-internal-modules.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/no-internal-modules.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-internal-modules
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Use this rule to prevent importing the submodules of other modules.
|
||||
|
||||
## Rule Details
|
||||
|
|
|
|||
6
node_modules/eslint-plugin-import/docs/rules/no-mutable-exports.md
generated
vendored
6
node_modules/eslint-plugin-import/docs/rules/no-mutable-exports.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-mutable-exports
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Forbids the use of mutable exports with `var` or `let`.
|
||||
|
||||
## Rule Details
|
||||
|
|
@ -44,8 +46,8 @@ want to enable the following core ESLint rules:
|
|||
- [no-func-assign]
|
||||
- [no-class-assign]
|
||||
|
||||
[no-func-assign]: http://eslint.org/docs/rules/no-func-assign
|
||||
[no-class-assign]: http://eslint.org/docs/rules/no-class-assign
|
||||
[no-func-assign]: https://eslint.org/docs/rules/no-func-assign
|
||||
[no-class-assign]: https://eslint.org/docs/rules/no-class-assign
|
||||
|
||||
## When Not To Use It
|
||||
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/no-named-as-default-member
|
||||
|
||||
⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports use of an exported name as a property on the default export.
|
||||
|
||||
Rationale: Accessing a property that has a name that is shared by an exported
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/no-named-as-default
|
||||
|
||||
⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports use of an exported name as the locally imported name of a default export.
|
||||
|
||||
Rationale: using an exported name as the name of the default export is likely...
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/no-named-default.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/no-named-default.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-named-default
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports use of a default export as a locally named import.
|
||||
|
||||
Rationale: the syntax exists to import default exports expressively, let's use it.
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-named-export.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-named-export.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# `import/no-named-export`
|
||||
# import/no-named-export
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Prohibit named exports. Mostly an inverse of [`no-default-export`].
|
||||
|
||||
|
|
|
|||
6
node_modules/eslint-plugin-import/docs/rules/no-namespace.md
generated
vendored
6
node_modules/eslint-plugin-import/docs/rules/no-namespace.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/no-namespace
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Enforce a convention of not using namespace (a.k.a. "wildcard" `*`) imports.
|
||||
|
||||
+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule, provided that the namespace object is only used for direct member access, e.g. `namespace.a`.
|
||||
|
|
@ -22,7 +26,7 @@ import defaultExport, { a, b } from './foobar'
|
|||
```
|
||||
|
||||
```js
|
||||
/* eslint import/no-namespace: ["error", {ignore: ['*.ext']] */
|
||||
/* eslint import/no-namespace: ["error", {ignore: ['*.ext']}] */
|
||||
import * as bar from './ignored-module.ext';
|
||||
```
|
||||
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-nodejs-modules.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-nodejs-modules.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# import/no-nodejs-modules: No Node.js builtin modules
|
||||
# import/no-nodejs-modules
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Forbid the use of Node.js builtin modules. Can be useful for client-side web projects that do not have access to those modules.
|
||||
|
||||
|
|
|
|||
5
node_modules/eslint-plugin-import/docs/rules/no-relative-packages.md
generated
vendored
5
node_modules/eslint-plugin-import/docs/rules/no-relative-packages.md
generated
vendored
|
|
@ -1,10 +1,15 @@
|
|||
# import/no-relative-packages
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Use this rule to prevent importing packages through relative paths.
|
||||
|
||||
It's useful in Yarn/Lerna workspaces, were it's possible to import a sibling
|
||||
package using `../package` relative path, while direct `package` is the correct one.
|
||||
|
||||
+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule.
|
||||
|
||||
### Examples
|
||||
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/no-relative-parent-imports.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/no-relative-parent-imports.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-relative-parent-imports
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Use this rule to prevent imports to folders in relative parent paths.
|
||||
|
||||
This rule is useful for enforcing tree-like folder structures instead of complex graph-like folder structures. While this restriction might be a departure from Node's default resolution style, it can lead large, complex codebases to be easier to maintain. If you've ever had debates over "where to put files" this rule is for you.
|
||||
|
|
|
|||
124
node_modules/eslint-plugin-import/docs/rules/no-restricted-paths.md
generated
vendored
124
node_modules/eslint-plugin-import/docs/rules/no-restricted-paths.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# import/no-restricted-paths: Restrict which files can be imported in a given folder
|
||||
# import/no-restricted-paths
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Some projects contain files which are not always meant to be executed in the same environment.
|
||||
For example consider a web application that contains specific code for the server and some specific code for the browser/client. In this case you don’t want to import server-only files in your client code.
|
||||
|
|
@ -9,8 +11,21 @@ In order to prevent such scenarios this rule allows you to define restricted zon
|
|||
|
||||
This rule has one option. The option is an object containing the definition of all restricted `zones` and the optional `basePath` which is used to resolve relative paths within.
|
||||
The default value for `basePath` is the current working directory.
|
||||
Each zone consists of the `target` path and a `from` path. The `target` is the path where the restricted imports should be applied. The `from` path defines the folder that is not allowed to be used in an import. An optional `except` may be defined for a zone, allowing exception paths that would otherwise violate the related `from`. Note that `except` is relative to `from` and cannot backtrack to a parent directory.
|
||||
You may also specify an optional `message` for a zone, which will be displayed in case of the rule violation.
|
||||
|
||||
Each zone consists of the `target` paths, a `from` paths, and an optional `except` and `message` attribute.
|
||||
- `target` contains the paths where the restricted imports should be applied. It can be expressed by
|
||||
- directory string path that matches all its containing files
|
||||
- glob pattern matching all the targeted files
|
||||
- an array of multiple of the two types above
|
||||
- `from` paths define the folders that are not allowed to be used in an import. It can be expressed by
|
||||
- directory string path that matches all its containing files
|
||||
- glob pattern matching all the files restricted to be imported
|
||||
- an array of multiple directory string path
|
||||
- an array of multiple glob patterns
|
||||
- `except` may be defined for a zone, allowing exception paths that would otherwise violate the related `from`. Note that it does not alter the behaviour of `target` in any way.
|
||||
- in case `from` contains only glob patterns, `except` must be an array of glob patterns as well
|
||||
- in case `from` contains only directory path, `except` is relative to `from` and cannot backtrack to a parent directory
|
||||
- `message` - will be displayed in case of the rule violation.
|
||||
|
||||
### Examples
|
||||
|
||||
|
|
@ -77,4 +92,107 @@ The following pattern is not considered a problem:
|
|||
|
||||
```js
|
||||
import b from './b'
|
||||
|
||||
```
|
||||
|
||||
---------------
|
||||
|
||||
Given the following folder structure:
|
||||
|
||||
```
|
||||
my-project
|
||||
├── client
|
||||
└── foo.js
|
||||
└── sub-module
|
||||
└── bar.js
|
||||
└── baz.js
|
||||
|
||||
```
|
||||
|
||||
and the current configuration is set to:
|
||||
|
||||
```
|
||||
{ "zones": [ {
|
||||
"target": "./tests/files/restricted-paths/client/!(sub-module)/**/*",
|
||||
"from": "./tests/files/restricted-paths/client/sub-module/**/*",
|
||||
} ] }
|
||||
```
|
||||
|
||||
The following import is considered a problem in `my-project/client/foo.js`:
|
||||
|
||||
```js
|
||||
import a from './sub-module/baz'
|
||||
```
|
||||
|
||||
The following import is not considered a problem in `my-project/client/sub-module/bar.js`:
|
||||
|
||||
```js
|
||||
import b from './baz'
|
||||
```
|
||||
|
||||
---------------
|
||||
|
||||
Given the following folder structure:
|
||||
|
||||
```
|
||||
my-project
|
||||
└── one
|
||||
└── a.js
|
||||
└── b.js
|
||||
└── two
|
||||
└── a.js
|
||||
└── b.js
|
||||
└── three
|
||||
└── a.js
|
||||
└── b.js
|
||||
```
|
||||
|
||||
and the current configuration is set to:
|
||||
|
||||
```
|
||||
{
|
||||
"zones": [
|
||||
{
|
||||
"target": ["./tests/files/restricted-paths/two/*", "./tests/files/restricted-paths/three/*"],
|
||||
"from": ["./tests/files/restricted-paths/one", "./tests/files/restricted-paths/three"],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are not considered a problem in `my-project/one/b.js`:
|
||||
|
||||
```js
|
||||
import a from '../three/a'
|
||||
```
|
||||
|
||||
```js
|
||||
import a from './a'
|
||||
```
|
||||
|
||||
The following pattern is not considered a problem in `my-project/two/b.js`:
|
||||
|
||||
```js
|
||||
import a from './a'
|
||||
```
|
||||
|
||||
The following patterns are considered a problem in `my-project/two/a.js`:
|
||||
|
||||
```js
|
||||
import a from '../one/a'
|
||||
```
|
||||
|
||||
```js
|
||||
import a from '../three/a'
|
||||
```
|
||||
|
||||
The following patterns are considered a problem in `my-project/three/b.js`:
|
||||
|
||||
```js
|
||||
import a from '../one/a'
|
||||
```
|
||||
|
||||
```js
|
||||
import a from './a'
|
||||
```
|
||||
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-self-import.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-self-import.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# Forbid a module from importing itself (`import/no-self-import`)
|
||||
# import/no-self-import
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Forbid a module from importing itself. This can sometimes happen during refactoring.
|
||||
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-unassigned-import.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-unassigned-import.md
generated
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# import/no-unassigned-import: Forbid unassigned imports
|
||||
# import/no-unassigned-import
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
With both CommonJS' `require` and the ES6 modules' `import` syntax, it is possible to import a module but not to use its result. This can be done explicitly by not assigning the module to as variable. Doing so can mean either of the following things:
|
||||
- The module is imported but not used
|
||||
|
|
|
|||
29
node_modules/eslint-plugin-import/docs/rules/no-unresolved.md
generated
vendored
29
node_modules/eslint-plugin-import/docs/rules/no-unresolved.md
generated
vendored
|
|
@ -1,12 +1,16 @@
|
|||
# import/no-unresolved
|
||||
|
||||
💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Ensures an imported module can be resolved to a module on the local filesystem,
|
||||
as defined by standard Node `require.resolve` behavior.
|
||||
|
||||
See [settings](../../README.md#settings) for customization options for the resolution (i.e.
|
||||
additional filetypes, `NODE_PATH`, etc.)
|
||||
|
||||
This rule can also optionally report on unresolved modules in CommonJS `require('./foo')` calls and AMD `require(['./foo'], function (foo){...})` and `define(['./foo'], function (foo){...})`.
|
||||
This rule can also optionally report on unresolved modules in CommonJS `require('./foo')` calls and AMD `require(['./foo'], function (foo) {...})` and `define(['./foo'], function (foo) {...})`.
|
||||
|
||||
To enable this, send `{ commonjs: true/false, amd: true/false }` as a rule option.
|
||||
Both are disabled by default.
|
||||
|
|
@ -60,7 +64,7 @@ This rule has its own ignore list, separate from [`import/ignore`]. This is beca
|
|||
To suppress errors from files that may not be properly resolved by your [resolver settings](../../README.md#resolver-plugins), you may add an `ignore` key with an array of `RegExp` pattern strings:
|
||||
|
||||
```js
|
||||
/*eslint import/no-unresolved: [2, { ignore: ['\.img$'] }]*/
|
||||
/*eslint import/no-unresolved: [2, { ignore: ['\\.img$'] }]*/
|
||||
|
||||
import { x } from './mod' // may be reported, if not resolved to a module
|
||||
|
||||
|
|
@ -76,14 +80,29 @@ By default, this rule will report paths whose case do not match the underlying f
|
|||
const { default: x } = require('./foo') // reported if './foo' is actually './Foo' and caseSensitive: true
|
||||
```
|
||||
|
||||
#### `caseSensitiveStrict`
|
||||
|
||||
The `caseSensitive` option does not detect case for the current working directory. The `caseSensitiveStrict` option allows checking `cwd` in resolved path. By default, the option is disabled.
|
||||
|
||||
|
||||
```js
|
||||
/*eslint import/no-unresolved: [2, { caseSensitiveStrict: true }]*/
|
||||
|
||||
// Absolute paths
|
||||
import Foo from `/Users/fOo/bar/file.js` // reported, /Users/foo/bar/file.js
|
||||
import Foo from `d:/fOo/bar/file.js` // reported, d:/foo/bar/file.js
|
||||
|
||||
// Relative paths, cwd is Users/foo/
|
||||
import Foo from `./../fOo/bar/file.js` // reported
|
||||
```
|
||||
|
||||
## When Not To Use It
|
||||
|
||||
If you're using a module bundler other than Node or Webpack, you may end up with
|
||||
a lot of false positive reports of missing dependencies.
|
||||
If you're using a module bundler other than Node or Webpack, you may end up with a lot of false positive reports of missing dependencies.
|
||||
|
||||
## Further Reading
|
||||
|
||||
- [Resolver plugins](../../README.md#resolver-plugins)
|
||||
- [Resolver plugins](../../README.md#resolvers)
|
||||
- [Node resolver](https://npmjs.com/package/eslint-import-resolver-node) (default)
|
||||
- [Webpack resolver](https://npmjs.com/package/eslint-import-resolver-webpack)
|
||||
- [`import/ignore`] global setting
|
||||
|
|
|
|||
4
node_modules/eslint-plugin-import/docs/rules/no-unused-modules.md
generated
vendored
4
node_modules/eslint-plugin-import/docs/rules/no-unused-modules.md
generated
vendored
|
|
@ -1,10 +1,12 @@
|
|||
# import/no-unused-modules
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Reports:
|
||||
- modules without any exports
|
||||
- individual exports not being statically `import`ed or `require`ed from other modules in the same project
|
||||
- dynamic imports are supported if argument is a literal string
|
||||
|
||||
Note: dynamic imports are currently not supported.
|
||||
|
||||
## Rule Details
|
||||
|
||||
|
|
|
|||
13
node_modules/eslint-plugin-import/docs/rules/no-useless-path-segments.md
generated
vendored
13
node_modules/eslint-plugin-import/docs/rules/no-useless-path-segments.md
generated
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# import/no-useless-path-segments
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Use this rule to prevent unnecessary path segments in import and require statements.
|
||||
|
||||
## Rule Details
|
||||
|
|
@ -14,6 +18,7 @@ my-project
|
|||
└── helpers.js
|
||||
└── helpers
|
||||
└── index.js
|
||||
├── index.js
|
||||
└── pages
|
||||
├── about.js
|
||||
├── contact.js
|
||||
|
|
@ -27,10 +32,10 @@ The following patterns are considered problems:
|
|||
* in my-project/app.js
|
||||
*/
|
||||
|
||||
import "./../pages/about.js"; // should be "./pages/about.js"
|
||||
import "./../pages/about"; // should be "./pages/about"
|
||||
import "../pages/about.js"; // should be "./pages/about.js"
|
||||
import "../pages/about"; // should be "./pages/about"
|
||||
import "./../my-project/pages/about.js"; // should be "./pages/about.js"
|
||||
import "./../my-project/pages/about"; // should be "./pages/about"
|
||||
import "../my-project/pages/about.js"; // should be "./pages/about.js"
|
||||
import "../my-project/pages/about"; // should be "./pages/about"
|
||||
import "./pages//about"; // should be "./pages/about"
|
||||
import "./pages/"; // should be "./pages"
|
||||
import "./pages/index"; // should be "./pages" (except if there is a ./pages.js file)
|
||||
|
|
|
|||
2
node_modules/eslint-plugin-import/docs/rules/no-webpack-loader-syntax.md
generated
vendored
2
node_modules/eslint-plugin-import/docs/rules/no-webpack-loader-syntax.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/no-webpack-loader-syntax
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Forbid Webpack loader syntax in imports.
|
||||
|
||||
[Webpack](https://webpack.js.org) allows specifying the [loaders](https://webpack.js.org/concepts/loaders/) to use in the import source string using a special syntax like this:
|
||||
|
|
|
|||
90
node_modules/eslint-plugin-import/docs/rules/order.md
generated
vendored
90
node_modules/eslint-plugin-import/docs/rules/order.md
generated
vendored
|
|
@ -1,11 +1,15 @@
|
|||
# import/order: Enforce a convention in module import order
|
||||
# import/order
|
||||
|
||||
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Enforce a convention in the order of `require()` / `import` statements.
|
||||
+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule.
|
||||
|
||||
With the [`groups`](#groups-array) option set to `["builtin", "external", "internal", "parent", "sibling", "index", "object"]` the order is as shown in the following example:
|
||||
With the [`groups`](#groups-array) option set to `["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"]` the order is as shown in the following example:
|
||||
|
||||
```js
|
||||
```ts
|
||||
// 1. node "builtin" modules
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
@ -36,7 +40,7 @@ Statements using the ES6 `import` syntax must appear before any `require()` stat
|
|||
|
||||
## Fail
|
||||
|
||||
```js
|
||||
```ts
|
||||
import _ from 'lodash';
|
||||
import path from 'path'; // `path` import should occur before import of `lodash`
|
||||
|
||||
|
|
@ -54,7 +58,7 @@ import foo from './foo'; // `import` statements must be before `require` stateme
|
|||
|
||||
## Pass
|
||||
|
||||
```js
|
||||
```ts
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
|
||||
|
|
@ -85,7 +89,7 @@ This rule supports the following options:
|
|||
How groups are defined, and the order to respect. `groups` must be an array of `string` or [`string`]. The only allowed `string`s are:
|
||||
`"builtin"`, `"external"`, `"internal"`, `"unknown"`, `"parent"`, `"sibling"`, `"index"`, `"object"`, `"type"`.
|
||||
The enforced order is the same as the order of each element in a group. Omitted types are implicitly grouped together as the last element. Example:
|
||||
```js
|
||||
```ts
|
||||
[
|
||||
'builtin', // Built-in types are first
|
||||
['sibling', 'parent'], // Then sibling and parent types. They can be mingled together
|
||||
|
|
@ -98,8 +102,22 @@ The default value is `["builtin", "external", "parent", "sibling", "index"]`.
|
|||
|
||||
You can set the options like this:
|
||||
|
||||
```js
|
||||
"import/order": ["error", {"groups": ["index", "sibling", "parent", "internal", "external", "builtin", "object", "type"]}]
|
||||
```ts
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
"groups": [
|
||||
"index",
|
||||
"sibling",
|
||||
"parent",
|
||||
"internal",
|
||||
"external",
|
||||
"builtin",
|
||||
"object",
|
||||
"type"
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### `pathGroups: [array of objects]`:
|
||||
|
|
@ -128,6 +146,31 @@ Properties of the objects
|
|||
}
|
||||
```
|
||||
|
||||
### `distinctGroup: [boolean]`:
|
||||
|
||||
This changes how `pathGroups[].position` affects grouping. The property is most useful when `newlines-between` is set to `always` and at least 1 `pathGroups` entry has a `position` property set.
|
||||
|
||||
By default, in the context of a particular `pathGroup` entry, when setting `position`, a new "group" will silently be created. That is, even if the `group` is specified, a newline will still separate imports that match that `pattern` with the rest of the group (assuming `newlines-between` is `always`). This is undesirable if your intentions are to use `position` to position _within_ the group (and not create a new one). Override this behavior by setting `distinctGroup` to `false`; this will keep imports within the same group as intended.
|
||||
|
||||
Note that currently, `distinctGroup` defaults to `true`. However, in a later update, the default will change to `false`
|
||||
|
||||
Example:
|
||||
```json
|
||||
{
|
||||
"import/order": ["error", {
|
||||
"newlines-between": "always",
|
||||
"pathGroups": [
|
||||
{
|
||||
"pattern": "@app/**",
|
||||
"group": "external",
|
||||
"position": "after"
|
||||
}
|
||||
],
|
||||
"distinctGroup": false
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
### `pathGroupsExcludedImportTypes: [array]`:
|
||||
|
||||
This defines import types that are not handled by configured pathGroups.
|
||||
|
|
@ -169,20 +212,22 @@ Example:
|
|||
]
|
||||
}
|
||||
```
|
||||
The default value is `["builtin", "external"]`.
|
||||
The default value is `["builtin", "external", "object"]`.
|
||||
|
||||
### `newlines-between: [ignore|always|always-and-inside-groups|never]`:
|
||||
|
||||
Enforces or forbids new lines between import groups:
|
||||
|
||||
- If set to `ignore`, no errors related to new lines between import groups will be reported (default).
|
||||
- If set to `ignore`, no errors related to new lines between import groups will be reported.
|
||||
- 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.
|
||||
- If set to `always-and-inside-groups`, it will act like `always` except newlines are allowed inside import groups.
|
||||
- If set to `never`, no new lines are allowed in the entire import section.
|
||||
|
||||
The default value is `"ignore"`.
|
||||
|
||||
With the default group setting, the following will be invalid:
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"newlines-between": "always"}] */
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
@ -190,7 +235,7 @@ import index from './';
|
|||
import sibling from './foo';
|
||||
```
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */
|
||||
import fs from 'fs';
|
||||
|
||||
|
|
@ -199,7 +244,7 @@ import index from './';
|
|||
import sibling from './foo';
|
||||
```
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"newlines-between": "never"}] */
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
@ -211,7 +256,7 @@ import sibling from './foo';
|
|||
|
||||
while those will be valid:
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"newlines-between": "always"}] */
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
@ -221,7 +266,7 @@ import index from './';
|
|||
import sibling from './foo';
|
||||
```
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */
|
||||
import fs from 'fs';
|
||||
|
||||
|
|
@ -232,7 +277,7 @@ import index from './';
|
|||
import sibling from './foo';
|
||||
```
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"newlines-between": "never"}] */
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
@ -240,15 +285,16 @@ import index from './';
|
|||
import sibling from './foo';
|
||||
```
|
||||
|
||||
### `alphabetize: {order: asc|desc|ignore, caseInsensitive: true|false}`:
|
||||
### `alphabetize: {order: asc|desc|ignore, orderImportKind: asc|desc|ignore, caseInsensitive: true|false}`:
|
||||
|
||||
Sort the order within each group in alphabetical manner based on **import path**:
|
||||
|
||||
- `order`: use `asc` to sort in ascending order, and `desc` to sort in descending order (default: `ignore`).
|
||||
- `orderImportKind`: use `asc` to sort in ascending order various import kinds, e.g. imports prefixed with `type` or `typeof`, with same import path. Use `desc` to sort in descending order (default: `ignore`).
|
||||
- `caseInsensitive`: use `true` to ignore case, and `false` to consider case (default: `false`).
|
||||
|
||||
Example setting:
|
||||
```js
|
||||
```ts
|
||||
alphabetize: {
|
||||
order: 'asc', /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */
|
||||
caseInsensitive: true /* ignore case. Options: [true, false] */
|
||||
|
|
@ -257,7 +303,7 @@ alphabetize: {
|
|||
|
||||
This will fail the rule check:
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"alphabetize": {"order": "asc", "caseInsensitive": true}}] */
|
||||
import React, { PureComponent } from 'react';
|
||||
import aTypes from 'prop-types';
|
||||
|
|
@ -268,7 +314,7 @@ import blist from 'BList';
|
|||
|
||||
While this will pass:
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"alphabetize": {"order": "asc", "caseInsensitive": true}}] */
|
||||
import blist from 'BList';
|
||||
import * as classnames from 'classnames';
|
||||
|
|
@ -288,7 +334,7 @@ way that is safe.
|
|||
|
||||
This will fail the rule check:
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"warnOnUnassignedImports": true}] */
|
||||
import fs from 'fs';
|
||||
import './styles.css';
|
||||
|
|
@ -297,7 +343,7 @@ import path from 'path';
|
|||
|
||||
While this will pass:
|
||||
|
||||
```js
|
||||
```ts
|
||||
/* eslint import/order: ["error", {"warnOnUnassignedImports": true}] */
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
|
|
|||
132
node_modules/eslint-plugin-import/docs/rules/prefer-default-export.md
generated
vendored
132
node_modules/eslint-plugin-import/docs/rules/prefer-default-export.md
generated
vendored
|
|
@ -1,9 +1,45 @@
|
|||
# import/prefer-default-export
|
||||
|
||||
When there is only a single export from a module, prefer using default export over named export.
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
In exporting files, this rule checks if there is default export or not.
|
||||
|
||||
## Rule Details
|
||||
|
||||
##### rule schema:
|
||||
|
||||
```javascript
|
||||
"import/prefer-default-export": [
|
||||
( "off" | "warn" | "error" ),
|
||||
{ "target": "single" | "any" } // default is "single"
|
||||
]
|
||||
```
|
||||
|
||||
### Config Options
|
||||
|
||||
There are two options available: `single` and `any`. By default, if you do not specify the option, rule will assume it is `single`.
|
||||
|
||||
#### single
|
||||
|
||||
**Definition**: When there is only a single export from a module, prefer using default export over named export.
|
||||
|
||||
How to setup config file for this rule:
|
||||
|
||||
```javascript
|
||||
// you can manually specify it
|
||||
"rules": {
|
||||
"import/prefer-default-export": [
|
||||
( "off" | "warn" | "error" ),
|
||||
{ "target": "single" }
|
||||
]
|
||||
}
|
||||
|
||||
// config setup below will also work
|
||||
"rules": {
|
||||
"import/prefer-default-export": "off" | "warn" | "error"
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```javascript
|
||||
|
|
@ -22,7 +58,7 @@ The following patterns are not warnings:
|
|||
// There is a default export.
|
||||
export const foo = 'foo';
|
||||
const bar = 'bar';
|
||||
export default 'bar';
|
||||
export default bar;
|
||||
```
|
||||
|
||||
```javascript
|
||||
|
|
@ -56,3 +92,95 @@ export { foo as default }
|
|||
// Any batch export will disable this rule. The remote module is not inspected.
|
||||
export * from './other-module'
|
||||
```
|
||||
|
||||
#### any
|
||||
|
||||
**Definition**: any exporting file must contain a default export.
|
||||
|
||||
How to setup config file for this rule:
|
||||
|
||||
```javascript
|
||||
// you have to manually specify it
|
||||
"rules": {
|
||||
"import/prefer-default-export": [
|
||||
( "off" | "warn" | "error" ),
|
||||
{ "target": "any" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```javascript
|
||||
// good1.js
|
||||
|
||||
//has default export
|
||||
export default function bar() {};
|
||||
```
|
||||
|
||||
```javascript
|
||||
// good2.js
|
||||
|
||||
// has default export
|
||||
let foo;
|
||||
export { foo as default }
|
||||
```
|
||||
|
||||
```javascript
|
||||
// good3.js
|
||||
|
||||
//contains multiple exports AND default export
|
||||
export const a = 5;
|
||||
export function bar(){};
|
||||
let foo;
|
||||
export { foo as default }
|
||||
```
|
||||
|
||||
```javascript
|
||||
// good4.js
|
||||
|
||||
// does not contain any exports => file is not checked by the rule
|
||||
import * as foo from './foo';
|
||||
```
|
||||
|
||||
```javascript
|
||||
// export-star.js
|
||||
|
||||
// Any batch export will disable this rule. The remote module is not inspected.
|
||||
export * from './other-module'
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```javascript
|
||||
// bad1.js
|
||||
|
||||
//has 2 named exports, but no default export
|
||||
export const foo = 'foo';
|
||||
export const bar = 'bar';
|
||||
```
|
||||
|
||||
```javascript
|
||||
// bad2.js
|
||||
|
||||
// does not have default export
|
||||
let foo, bar;
|
||||
export { foo, bar }
|
||||
```
|
||||
|
||||
```javascript
|
||||
// bad3.js
|
||||
|
||||
// does not have default export
|
||||
export { a, b } from "foo.js"
|
||||
```
|
||||
|
||||
```javascript
|
||||
// bad4.js
|
||||
|
||||
// does not have default export
|
||||
let item;
|
||||
export const foo = item;
|
||||
export { item };
|
||||
```
|
||||
|
|
|
|||
6
node_modules/eslint-plugin-import/docs/rules/unambiguous.md
generated
vendored
6
node_modules/eslint-plugin-import/docs/rules/unambiguous.md
generated
vendored
|
|
@ -1,5 +1,7 @@
|
|||
# import/unambiguous
|
||||
|
||||
<!-- end auto-generated rule header -->
|
||||
|
||||
Warn if a `module` could be mistakenly parsed as a `script` by a consumer leveraging
|
||||
[Unambiguous JavaScript Grammar] to determine correct parsing goal.
|
||||
|
||||
|
|
@ -50,5 +52,5 @@ a `module`.
|
|||
- [`parserOptions.sourceType`]
|
||||
- [node-eps#13](https://github.com/nodejs/node-eps/issues/13)
|
||||
|
||||
[`parserOptions.sourceType`]: http://eslint.org/docs/user-guide/configuring#specifying-parser-options
|
||||
[Unambiguous JavaScript Grammar]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md#32-determining-if-source-is-an-es-module
|
||||
[`parserOptions.sourceType`]: https://eslint.org/docs/user-guide/configuring#specifying-parser-options
|
||||
[Unambiguous JavaScript Grammar]: https://github.com/nodejs/node-eps/blob/HEAD/002-es-modules.md#32-determining-if-source-is-an-es-module
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue