Socket
Socket
Sign inDemoInstall

eslint-plugin-import

Package Overview
Dependencies
Maintainers
3
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-import - npm Package Compare versions

Comparing version 2.28.0 to 2.28.1

20

CONTRIBUTING.md

@@ -9,11 +9,11 @@ # Contributing

- [ ] search open/closed issues
- [ ] discuss bug/enhancement in new or old issue
- [ ] search open/closed issues
- [ ] discuss bug/enhancement in new or old issue
[PR](#prs) time:
- [ ] write tests
- [ ] implement feature/fix bug
- [ ] update docs
- [ ] make a note in change log
- [ ] write tests
- [ ] implement feature/fix bug
- [ ] update docs
- [ ] make a note in change log

@@ -26,6 +26,6 @@ Remember, you don't need to do it all yourself; any of these are helpful! 😎

- Watch [this presentation](https://www.youtube.com/watch?v=2W9tUnALrLg) to learn the fundamental concept of Abstract Syntax Trees (AST) and the way `eslint` works under the hood.
- Familiarize yourself with the [AST explorer](https://astexplorer.net/) tool. Look into rules in `docs/rules`, create patterns in the rules, then analyze its AST.
- Explore the blog posts on how to create a custom rule. [One blog post](https://blog.yonatan.dev/writing-a-custom-eslint-rule-to-spot-undeclared-props/). [Second blog post](https://betterprogramming.pub/creating-custom-eslint-rules-cdc579694608).
- Read the official `eslint` [developer guide](https://eslint.org/docs/latest/developer-guide/architecture/).
- Watch [this presentation](https://www.youtube.com/watch?v=2W9tUnALrLg) to learn the fundamental concept of Abstract Syntax Trees (AST) and the way `eslint` works under the hood.
- Familiarize yourself with the [AST explorer](https://astexplorer.net/) tool. Look into rules in `docs/rules`, create patterns in the rules, then analyze its AST.
- Explore the blog posts on how to create a custom rule. [One blog post](https://blog.yonatan.dev/writing-a-custom-eslint-rule-to-spot-undeclared-props/). [Second blog post](https://betterprogramming.pub/creating-custom-eslint-rules-cdc579694608).
- Read the official `eslint` [developer guide](https://eslint.org/docs/latest/developer-guide/architecture/).

@@ -32,0 +32,0 @@ ## Issues

@@ -40,4 +40,4 @@ # import/consistent-type-specifier-style

- `'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.
- `'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.

@@ -44,0 +44,0 @@ By default the rule will use the `prefer-inline` option.

@@ -22,3 +22,2 @@ # import/default

## Rule Details

@@ -58,3 +57,2 @@

## When Not To Use It

@@ -70,9 +68,8 @@

- Lee Byron's [ES7] export proposal
- [`import/ignore`] setting
- [`jsnext:main`] (Rollup)
- Lee Byron's [ES7] export proposal
- [`import/ignore`] setting
- [`jsnext:main`] (Rollup)
[ES7]: https://github.com/leebyron/ecmascript-more-export-from
[`import/ignore`]: ../../README.md#importignore
[`jsnext:main`]: https://github.com/rollup/rollup/wiki/jsnext:main

@@ -10,4 +10,6 @@ # import/dynamic-import-chunkname

## Rule Details
This rule runs against `import()` by default, but can be configured to also run against an alternative dynamic-import function, e.g. 'dynamicImport.'
You can also configure the regex format you'd like to accept for the webpackChunkName - for example, if we don't want the number 6 to show up in our chunk names:
```javascript

@@ -23,2 +25,3 @@ {

### invalid
The following patterns are invalid:

@@ -58,3 +61,5 @@

```
### valid
The following patterns are valid:

@@ -61,0 +66,0 @@

@@ -20,2 +20,3 @@ # import/export

or
```js

@@ -35,4 +36,4 @@ export const foo = function () { /*...*/ } // Multiple exports of name 'foo'.

- Lee Byron's [ES7] export proposal
- Lee Byron's [ES7] export proposal
[ES7]: https://github.com/leebyron/ecmascript-more-export-from

@@ -7,3 +7,2 @@ # import/exports-last

## This will be reported

@@ -49,3 +48,3 @@

#### ES6 exports only
### ES6 exports only

@@ -52,0 +51,0 @@ The exports-last rule is currently only working on ES6 exports. You may not want to enable this rule if you're using CommonJS exports.

@@ -13,3 +13,3 @@ # import/extensions

```
```json
"import/extensions": [<severity>, "never" | "always" | "ignorePackages"]

@@ -20,3 +20,3 @@ ```

```
```json
"import/extensions": [<severity>, {

@@ -31,3 +31,3 @@ <extension>: "never" | "always" | "ignorePackages"

```
```json
"import/extensions": [

@@ -46,3 +46,3 @@ <severity>,

```
```json
"import/extensions": [

@@ -69,3 +69,3 @@ <severity>,

```
```pt
├── foo

@@ -72,0 +72,0 @@ │   ├── bar.js

@@ -60,2 +60,3 @@ # import/first

This rule contains a fixer to reorder in-body import to top, the following criteria applied:
1. Never re-order relative to each other, even if `absolute-first` is set.

@@ -71,6 +72,6 @@ 2. If an import creates an identifier, and that identifier is referenced at module level *before* the import itself, that won't be re-ordered.

- [`import/order`]: a major step up from `absolute-first`
- Issue [#255]
- [`import/order`]: a major step up from `absolute-first`
- Issue [#255]
[`import/order`]: ./order.md
[#255]: https://github.com/import-js/eslint-plugin-import/issues/255

@@ -74,3 +74,2 @@ # import/group-exports

### Invalid

@@ -77,0 +76,0 @@

@@ -50,2 +50,3 @@ # import/max-dependencies

<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
### Fail

@@ -59,2 +60,3 @@

<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
### Pass

@@ -61,0 +63,0 @@

@@ -21,3 +21,2 @@ # import/named

## Rule Details

@@ -98,9 +97,8 @@

- [`import/ignore`] setting
- [`jsnext:main`] deprecation
- [`pkg.module`] (Rollup)
- [`import/ignore`] setting
- [`jsnext:main`] deprecation
- [`pkg.module`] (Rollup)
[`jsnext:main`]: https://github.com/jsforum/jsforum/issues/5
[`pkg.module`]: https://github.com/rollup/rollup/wiki/pkg.module
[`import/ignore`]: ../../README.md#importignore

@@ -33,2 +33,3 @@ # import/namespace

Given:
```js

@@ -48,3 +49,5 @@ // @module ./named-exports

```
and:
```js

@@ -99,5 +102,5 @@ // @module ./deep

- Lee Byron's [ES7] export proposal
- [`import/ignore`] setting
- [`jsnext:main`](Rollup)
- Lee Byron's [ES7] export proposal
- [`import/ignore`] setting
- [`jsnext:main`](Rollup)

@@ -104,0 +107,0 @@ [ES7]: https://github.com/leebyron/ecmascript-more-export-from

@@ -8,11 +8,11 @@ # import/newline-after-import

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 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`.
This rule supports the following options:
- `considerComments` which enforces the rule on comments after the last import-statement as well when set to true. This option defaults to `false`.
- `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:

@@ -108,2 +108,3 @@

## Example options usage
```json

@@ -117,5 +118,4 @@ {

## When Not To Use It
If you like to visually group module imports with its usage, you don't want to use this rule.

@@ -41,5 +41,5 @@ # import/no-absolute-path

- `esmodule`: defaults to `true`
- `commonjs`: defaults to `true`
- `amd`: defaults to `false`
- `esmodule`: defaults to `true`
- `commonjs`: defaults to `true`
- `amd`: defaults to `false`

@@ -46,0 +46,0 @@ If `{ amd: true }` is provided, dependency paths for AMD-style `define` and `require`

@@ -36,3 +36,3 @@ # import/no-amd

- [`no-commonjs`](./no-commonjs.md): report CommonJS `require` and `exports`
- Source: https://github.com/xjamundx/eslint-plugin-modules
- [`no-commonjs`](./no-commonjs.md): report CommonJS `require` and `exports`
- Source: <https://github.com/xjamundx/eslint-plugin-modules>

@@ -31,2 +31,3 @@ # import/no-anonymous-default-export

### Fail
```js

@@ -52,2 +53,3 @@ export default []

### Pass
```js

@@ -54,0 +56,0 @@ const foo = 123

@@ -89,3 +89,2 @@ # import/no-commonjs

## Contributors

@@ -97,3 +96,3 @@

- [`no-amd`](./no-amd.md): report on AMD `require`, `define`
- Source: https://github.com/xjamundx/eslint-plugin-modules
- [`no-amd`](./no-amd.md): report on AMD `require`, `define`
- Source: <https://github.com/xjamundx/eslint-plugin-modules>

@@ -27,3 +27,2 @@ # import/no-cycle

## Rule Details

@@ -107,5 +106,5 @@

- [Original inspiring issue](https://github.com/import-js/eslint-plugin-import/issues/941)
- Rule to detect that module imports itself: [`no-self-import`]
- [`import/external-module-folders`] setting
- [Original inspiring issue](https://github.com/import-js/eslint-plugin-import/issues/941)
- Rule to detect that module imports itself: [`no-self-import`]
- [`import/external-module-folders`] setting

@@ -112,0 +111,0 @@ [`no-self-import`]: ./no-self-import.md

@@ -6,3 +6,3 @@ # import/no-deprecated

Reports use of a deprecated name, as indicated by a JSDoc block with a `@deprecated`
tag or TomDoc `Deprecated: ` comment.
tag or TomDoc `Deprecated:` comment.

@@ -49,3 +49,2 @@ using a JSDoc `@deprecated` tag:

```yaml

@@ -57,10 +56,10 @@ # .eslintrc.yml

### Worklist
## Worklist
- [x] report explicit imports on the import node
- [x] support namespaces
- [x] should bubble up through deep namespaces (#157)
- [x] report explicit imports at reference time (at the identifier) similar to namespace
- [x] mark module deprecated if file JSDoc has a @deprecated tag?
- [ ] don't flag redeclaration of imported, deprecated names
- [ ] flag destructuring
- [x] report explicit imports on the import node
- [x] support namespaces
- [x] should bubble up through deep namespaces (#157)
- [x] report explicit imports at reference time (at the identifier) similar to namespace
- [x] mark module deprecated if file JSDoc has a @deprecated tag?
- [ ] don't flag redeclaration of imported, deprecated names
- [ ] flag destructuring

@@ -10,3 +10,2 @@ # import/no-duplicates

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.

@@ -22,2 +21,3 @@ ESLint core has a similar rule ([`no-duplicate-imports`](https://eslint.org/docs/rules/no-duplicate-imports)), but this version

Valid:
```js

@@ -58,2 +58,3 @@ import SomeDefaultClass, * as names from './mod'

And then the following code becomes valid:
```js

@@ -66,2 +67,3 @@ import minifiedMod from './mod?minify'

It will still catch duplicates when using the same module and the exact same query string:
```js

@@ -68,0 +70,0 @@ import SomeDefaultClass from './mod?minify'

@@ -12,2 +12,3 @@ # import/no-empty-named-blocks

### Valid
```js

@@ -19,2 +20,3 @@ import { mod } from 'mod'

When using typescript
```js

@@ -25,2 +27,3 @@ import type { mod } from 'mod'

When using flow
```js

@@ -31,2 +34,3 @@ import typeof { mod } from 'mod'

### Invalid
```js

@@ -38,2 +42,3 @@ import {} from 'mod'

When using typescript
```js

@@ -45,5 +50,6 @@ import type Default, {} from 'mod'

When using flow
```js
import typeof {} from 'mod'
import typeof Default, {} from 'mod'
```
```

@@ -10,3 +10,3 @@ # import/no-extraneous-dependencies

### Options
## Options

@@ -64,2 +64,3 @@ This rule supports the following options:

Given the following `package.json`:
```json

@@ -93,3 +94,2 @@ {

## Fail

@@ -123,3 +123,2 @@

## Pass

@@ -142,5 +141,4 @@

## When Not To Use It
If you do not have a `package.json` file in your project.

@@ -15,3 +15,4 @@ # import/no-import-module-exports

#### `exceptions`
### `exceptions`
- An array of globs. The rule will be omitted from any file that matches a glob

@@ -47,2 +48,3 @@ in the options array. For example, the following setting will omit the rule

### Pass
Given the following package.json:

@@ -80,2 +82,3 @@

### Further Reading
- [webpack issue #4039](https://github.com/webpack/webpack/issues/4039)

@@ -11,4 +11,4 @@ # import/no-internal-modules

- `allow` that include paths and import statements that can be imported with reaching.
- `forbid` that exclude paths and import statements that can be imported with reaching.
- `allow` that include paths and import statements that can be imported with reaching.
- `forbid` that exclude paths and import statements that can be imported with reaching.

@@ -19,3 +19,3 @@ ### Examples

```
```pt
my-project

@@ -38,3 +38,4 @@ ├── actions

And the .eslintrc file:
```
```json
{

@@ -82,3 +83,3 @@ ...

```
```pt
my-project

@@ -101,3 +102,4 @@ ├── actions

And the .eslintrc file:
```
```json
{

@@ -104,0 +106,0 @@ ...

@@ -46,4 +46,4 @@ # import/no-mutable-exports

- [no-func-assign]
- [no-class-assign]
- [no-func-assign]
- [no-class-assign]

@@ -50,0 +50,0 @@ [no-func-assign]: https://eslint.org/docs/rules/no-func-assign

@@ -20,9 +20,8 @@ # import/no-named-as-default-member

[blog]: https://kentcdodds.com/blog/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution
## Rule Details
Given:
```js

@@ -35,2 +34,3 @@ // foo.js

...this would be valid:
```js

@@ -41,2 +41,3 @@ import foo, {bar} from './foo.js';

...and the following would be reported:
```js

@@ -43,0 +44,0 @@ // Caution: `foo` also has a named export `bar`.

@@ -11,4 +11,4 @@ # import/no-named-as-default

- *misleading*: others familiar with `foo.js` probably expect the name to be `foo`
- *a mistake*: only needed to import `bar` and forgot the brackets (the case that is prompting this)
- _misleading_: others familiar with `foo.js` probably expect the name to be `foo`
- _a mistake_: only needed to import `bar` and forgot the brackets (the case that is prompting this)

@@ -18,2 +18,3 @@ ## Rule Details

Given:
```js

@@ -26,2 +27,3 @@ // foo.js

...this would be valid:
```js

@@ -32,2 +34,3 @@ import foo from './foo.js';

...and this would be reported:
```js

@@ -50,6 +53,6 @@ // message: Using exported name 'bar' as identifier for default export.

- ECMAScript Proposal: [export ns from]
- ECMAScript Proposal: [export default from]
- ECMAScript Proposal: [export ns from]
- ECMAScript Proposal: [export default from]
[export ns from]: https://github.com/leebyron/ecmascript-export-ns-from
[export default from]: https://github.com/leebyron/ecmascript-export-default-from

@@ -16,2 +16,3 @@ # import/no-named-default

Given:
```js

@@ -24,2 +25,3 @@ // foo.js

...these would be valid:
```js

@@ -31,2 +33,3 @@ import foo from './foo.js';

...and these would be reported:
```js

@@ -33,0 +36,0 @@ // message: Using exported name 'bar' as identifier for default export.

@@ -9,10 +9,9 @@ # import/no-namespace

+(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`.
The `--fix` functionality for this rule requires ESLint 5 or newer.
The rule is auto-fixable when the namespace object is only used for direct member access, e.g. `namespace.a`.
### Options
## Options
This rule supports the following options:
- `ignore`: array of glob strings for modules that should be ignored by the rule.
- `ignore`: array of glob strings for modules that should be ignored by the rule.

@@ -19,0 +18,0 @@ ## Rule Details

@@ -7,7 +7,7 @@ # import/no-nodejs-modules

### Options
## Options
This rule supports the following options:
- `allow`: Array of names of allowed modules. Defaults to an empty array.
- `allow`: Array of names of allowed modules. Defaults to an empty array.

@@ -14,0 +14,0 @@ ## Rule Details

@@ -12,9 +12,7 @@ # import/no-relative-packages

+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule.
## Examples
### Examples
Given the following folder structure:
```
```pt
my-project

@@ -32,3 +30,4 @@ ├── packages

And the .eslintrc file:
```
```json
{

@@ -35,0 +34,0 @@ ...

@@ -11,3 +11,3 @@ # import/no-relative-parent-imports

```
```pt
numbers

@@ -36,47 +36,47 @@ └── three.js

`three.js` could be be in the same folder as `add.js`:
`three.js` could be be in the same folder as `add.js`:
```
three.js
add.js
```
```pt
three.js
add.js
```
or since `add` doesn't have any imports, it could be in it's own directory (namespace):
or since `add` doesn't have any imports, it could be in it's own directory (namespace):
```
math
└── add.js
three.js
```
```pt
math
└── add.js
three.js
```
2. Pass the dependency as an argument at runtime (dependency injection)
```js
// three.js
export default function three(add) {
return add([1, 2]);
}
```js
// three.js
export default function three(add) {
return add([1, 2]);
}
// somewhere else when you use `three.js`:
import add from './add';
import three from './numbers/three';
console.log(three(add));
```
// somewhere else when you use `three.js`:
import add from './add';
import three from './numbers/three';
console.log(three(add));
```
3. Make the dependency a package so it's globally available to all files in your project:
```js
import add from 'add'; // from https://www.npmjs.com/package/add
export default function three() {
return add([1,2]);
}
```
```js
import add from 'add'; // from https://www.npmjs.com/package/add
export default function three() {
return add([1,2]);
}
```
These are (respectively) static, dynamic & global solutions to graph-like dependency resolution.
### Examples
## Examples
Given the following folder structure:
```
```pt
my-project

@@ -90,3 +90,4 @@ ├── lib

And the .eslintrc file:
```
```json
{

@@ -93,0 +94,0 @@ ...

@@ -16,16 +16,17 @@ # import/no-restricted-paths

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.
- `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

@@ -35,3 +36,3 @@

```
```pt
my-project

@@ -63,3 +64,3 @@ ├── client

```
```pt
my-project

@@ -80,3 +81,3 @@ ├── client

```
```json
{ "zones": [ {

@@ -106,3 +107,3 @@ "target": "./tests/files/restricted-paths/server/one",

```
```pt
my-project

@@ -119,3 +120,3 @@ ├── client

```
```json
{ "zones": [ {

@@ -143,3 +144,3 @@ "target": "./tests/files/restricted-paths/client/!(sub-module)/**/*",

```
```pt
my-project

@@ -159,3 +160,3 @@ └── one

```
```json
{

@@ -206,2 +207,1 @@ "zones": [

```

@@ -6,8 +6,9 @@ # import/no-unassigned-import

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
- The module has side-effects (like [`should`](https://www.npmjs.com/package/should)). Having side-effects, makes it hard to know whether the module is actually used or can be removed. It can also make it harder to test or mock parts of your application.
- The module is imported but not used
- The module has side-effects (like [`should`](https://www.npmjs.com/package/should)). Having side-effects, makes it hard to know whether the module is actually used or can be removed. It can also make it harder to test or mock parts of your application.
This rule aims to remove modules with side-effects by reporting when a module is imported but not assigned.
### Options
## Options

@@ -20,3 +21,2 @@ This rule supports the following option:

## Fail

@@ -33,3 +33,2 @@

## Pass

@@ -36,0 +35,0 @@

@@ -53,2 +53,3 @@ # import/no-unresolved

Both may be provided, too:
```js

@@ -88,3 +89,2 @@ /*eslint import/no-unresolved: [2, { commonjs: true, amd: true }]*/

```js

@@ -107,7 +107,7 @@ /*eslint import/no-unresolved: [2, { caseSensitiveStrict: true }]*/

- [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
- [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
[`import/ignore`]: ../../README.md#importignore

@@ -6,6 +6,6 @@ # import/no-unused-modules

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
- 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

@@ -16,6 +16,7 @@ ## Rule Details

In order for this plugin to work, at least one of the options `missingExports` or `unusedExports` must be enabled (see "Options" section below). In the future, these options will be enabled by default (see https://github.com/import-js/eslint-plugin-import/issues/1324)
In order for this plugin to work, at least one of the options `missingExports` or `unusedExports` must be enabled (see "Options" section below). In the future, these options will be enabled by default (see <https://github.com/import-js/eslint-plugin-import/issues/1324>)
Example:
```
```json
"rules: {

@@ -31,10 +32,11 @@ ...otherRules,

- **`missingExports`**: if `true`, files without any exports are reported (defaults to `false`)
- **`unusedExports`**: if `true`, exports without any static usage within other modules are reported (defaults to `false`)
- `src`: an array with files/paths to be analyzed. It only applies to unused exports. Defaults to `process.cwd()`, if not provided
- `ignoreExports`: an array with files/paths for which unused exports will not be reported (e.g module entry points in a published package)
- **`missingExports`**: if `true`, files without any exports are reported (defaults to `false`)
- **`unusedExports`**: if `true`, exports without any static usage within other modules are reported (defaults to `false`)
- `src`: an array with files/paths to be analyzed. It only applies to unused exports. Defaults to `process.cwd()`, if not provided
- `ignoreExports`: an array with files/paths for which unused exports will not be reported (e.g module entry points in a published package)
### Example for missing exports
### Example for missing exports
#### The following will be reported
```js

@@ -51,8 +53,11 @@ const class MyClass { /*...*/ }

```
```js
export const foo = function () { /*...*/ }
```
```js
export { foo, bar }
```
```js

@@ -63,3 +68,5 @@ export { foo as bar }

### Example for unused exports
given file-f:
```js

@@ -73,3 +80,5 @@ import { e } from 'file-a'

```
and file-d:
```js

@@ -80,3 +89,5 @@ export const i0 = 9 // will not be reported

```
and file-c:
```js

@@ -86,3 +97,5 @@ export const h = 8 // will not be reported

```
and file-b:
```js

@@ -93,3 +106,5 @@ import two, { b, c, doAnything } from 'file-a'

```
and file-a:
```js

@@ -114,2 +129,3 @@ const b = 2

#### Important Note
Exports from files listed as a main file (`main`, `browser`, or `bin` fields in `package.json`) will be ignored by default. This only applies if the `package.json` is not set to `private: true`

@@ -116,0 +132,0 @@

@@ -13,3 +13,3 @@ # import/no-useless-path-segments

```
```pt
my-project

@@ -66,2 +66,3 @@ ├── app.js

If you want to detect unnecessary `/index` or `/index.js` (depending on the specified file extensions, see below) imports in your paths, you can enable the option `noUselessIndex`. By default it is set to `false`:
```js

@@ -68,0 +69,0 @@ "import/no-useless-path-segments": ["error", {

@@ -8,2 +8,3 @@ # import/no-webpack-loader-syntax

[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:
```js

@@ -10,0 +11,0 @@ var moduleWithOneLoader = require("my-loader!./my-awesome-module");

@@ -8,3 +8,2 @@ # import/order

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.

@@ -41,3 +40,2 @@ 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:

## Fail

@@ -60,3 +58,2 @@

## Pass

@@ -90,3 +87,3 @@

### `groups: [array]`:
### `groups: [array]`

@@ -96,2 +93,3 @@ How groups are defined, and the order to respect. `groups` must be an array of `string` or [`string`]. The only allowed `string`s are:

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:
```ts

@@ -106,2 +104,3 @@ [

```
The default value is `["builtin", "external", "parent", "sibling", "index"]`.

@@ -129,3 +128,3 @@

### `pathGroups: [array of objects]`:
### `pathGroups: [array of objects]`

@@ -156,3 +155,3 @@ To be able to group by paths mostly needed with aliases pathGroups can be defined.

### `distinctGroup: [boolean]`:
### `distinctGroup: [boolean]`

@@ -166,2 +165,3 @@ 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.

Example:
```json

@@ -183,3 +183,3 @@ {

### `pathGroupsExcludedImportTypes: [array]`:
### `pathGroupsExcludedImportTypes: [array]`

@@ -190,2 +190,3 @@ This defines import types that are not handled by configured pathGroups.

Example:
```json

@@ -209,2 +210,3 @@ {

Example:
```json

@@ -227,12 +229,13 @@ {

```
The default value is `["builtin", "external", "object"]`.
### `newlines-between: [ignore|always|always-and-inside-groups|never]`:
### `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.
- 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.
- 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.

@@ -301,11 +304,12 @@ The default value is `"ignore"`.

### `alphabetize: {order: asc|desc|ignore, orderImportKind: 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`).
- `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:
```ts

@@ -340,5 +344,5 @@ alphabetize: {

### `warnOnUnassignedImports: true|false`:
### `warnOnUnassignedImports: true|false`
* default: `false`
- default: `false`

@@ -370,5 +374,5 @@ Warns when unassigned imports are out of order. These warning will not be fixed

- [`import/external-module-folders`] setting
- [`import/external-module-folders`] setting
- [`import/internal-regex`] setting
- [`import/internal-regex`] setting

@@ -375,0 +379,0 @@ [`import/external-module-folders`]: ../../README.md#importexternal-module-folders

@@ -9,3 +9,3 @@ # import/prefer-default-export

##### rule schema:
### rule schema

@@ -15,3 +15,3 @@ ```javascript

( "off" | "warn" | "error" ),
{ "target": "single" | "any" } // default is "single"
{ "target": "single" | "any" } // default is "single"
]

@@ -114,3 +114,2 @@ ```

The following patterns are *not* considered warnings:

@@ -117,0 +116,0 @@

@@ -35,2 +35,3 @@ # import/unambiguous

...whereas the following file would be reported:
```js

@@ -52,7 +53,7 @@ (function x() { return 42 })()

- [Unambiguous JavaScript Grammar]
- [`parserOptions.sourceType`]
- [node-eps#13](https://github.com/nodejs/node-eps/issues/13)
- [Unambiguous JavaScript Grammar]
- [`parserOptions.sourceType`]
- [node-eps#13](https://github.com/nodejs/node-eps/issues/13)
[`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
# eslint-plugin-import/memo-parser
## NOTE
## NOTE!
This used to improve performance, but as of ESLint 5 and v2 of this plugin, it seems to just consume a bunch of memory and slightly increase lint times.

@@ -10,3 +9,2 @@

This parser is just a memoizing wrapper around some actual parser.

@@ -13,0 +11,0 @@

{
"name": "eslint-plugin-import",
"version": "2.28.0",
"version": "2.28.1",
"description": "Import with sanity.",

@@ -27,3 +27,3 @@ "engines": {

"pretest": "linklocal",
"posttest": "eslint . && npm run update:eslint-docs -- --check",
"posttest": "eslint . && npm run update:eslint-docs -- --check && markdownlint \"**/*.md\"",
"mocha": "cross-env BABEL_ENV=test nyc mocha",

@@ -89,4 +89,6 @@ "tests-only": "npm run mocha tests/src",

"in-publish": "^2.0.1",
"jackspeak": "=2.1.1",
"linklocal": "^2.8.2",
"lodash.isarray": "^4.0.0",
"markdownlint-cli": "^0.35.0",
"mocha": "^3.5.3",

@@ -115,3 +117,3 @@ "npm-which": "^3.0.1",

"has": "^1.0.3",
"is-core-module": "^2.12.1",
"is-core-module": "^2.13.0",
"is-glob": "^4.0.3",

@@ -122,3 +124,2 @@ "minimatch": "^3.1.2",

"object.values": "^1.1.6",
"resolve": "^1.22.3",
"semver": "^6.3.1",

@@ -125,0 +126,0 @@ "tsconfig-paths": "^3.14.2"

@@ -134,3 +134,3 @@ # eslint-plugin-import

# TypeScript
## TypeScript

@@ -158,3 +158,3 @@ You may use the following snippet or assemble your own config using the granular settings described below it.

# Resolvers
## Resolvers

@@ -180,3 +180,3 @@ With the advent of module bundlers and the current state of modules and module

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

@@ -201,3 +201,3 @@ ```yaml

- with a full npm module name, like `my-awesome-npm-module`:
- with a full npm module name, like `my-awesome-npm-module`:

@@ -221,3 +221,3 @@ ```yaml

- with a filesystem path to resolver, defined in this example as a `computed property` name:
- with a filesystem path to resolver, defined in this example as a `computed property` name:

@@ -344,7 +344,7 @@ ```js

- `jspm_modules` will match any file or folder named `jspm_modules` or which has a direct or non-direct parent named `jspm_modules`, e.g. `/home/me/project/jspm_modules` or `/home/me/project/jspm_modules/some-pkg/index.js`.
- `jspm_modules` will match any file or folder named `jspm_modules` or which has a direct or non-direct parent named `jspm_modules`, e.g. `/home/me/project/jspm_modules` or `/home/me/project/jspm_modules/some-pkg/index.js`.
- `packages/core` will match any path that contains these two segments, for example `/home/me/project/packages/core/src/utils.js`.
- `packages/core` will match any path that contains these two segments, for example `/home/me/project/packages/core/src/utils.js`.
- `/home/me/project/packages` will only match files and directories inside this directory, and the directory itself.
- `/home/me/project/packages` will only match files and directories inside this directory, and the directory itself.

@@ -351,0 +351,0 @@ Please note that incomplete names are not allowed here so `components` won't match `bower_components` and `packages/ui` won't match `packages/ui-utils` (but will match `packages/ui/utils`).

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc