Undo eslint-plugin-import bump

This package must stay at 2.29.1 until a version of the
package is released that supports eslint v9.
This commit is contained in:
Andrew Eisenberg
2024-10-01 19:18:59 -07:00
parent 931cd264c2
commit 2f6cf481fd
58 changed files with 1505 additions and 2243 deletions

View File

@@ -1,7 +1,5 @@
# import/dynamic-import-chunkname
💡 This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
<!-- end auto-generated rule header -->
This rule reports any dynamic imports without a webpackChunkName specified in a leading block comment in the proper format.
@@ -17,8 +15,7 @@ You can also configure the regex format you'd like to accept for the webpackChun
{
"dynamic-import-chunkname": [2, {
importFunctions: ["dynamicImport"],
webpackChunknameFormat: "[a-zA-Z0-57-9-/_]+",
allowEmpty: false
webpackChunknameFormat: "[a-zA-Z0-57-9-/_]+"
}]
}
```
@@ -58,13 +55,6 @@ import(
// webpackChunkName: "someModule"
'someModule',
);
// chunk names are disallowed when eager mode is set
import(
/* webpackMode: "eager" */
/* webpackChunkName: "someModule" */
'someModule',
)
```
### valid
@@ -97,38 +87,6 @@ The following patterns are valid:
);
```
### `allowEmpty: true`
If you want to allow dynamic imports without a webpackChunkName, you can set `allowEmpty: true` in the rule config. This will allow dynamic imports without a leading comment, or with a leading comment that does not contain a webpackChunkName.
Given `{ "allowEmpty": true }`:
<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
### valid
The following patterns are valid:
```javascript
import('someModule');
import(
/* webpackChunkName: "someModule" */
'someModule',
);
```
<!-- markdownlint-disable-next-line MD024 -- duplicate header -->
### invalid
The following patterns are invalid:
```javascript
// incorrectly formatted comment
import(
/*webpackChunkName:"someModule"*/
'someModule',
);
```
## When Not To Use It
If you don't care that webpack will autogenerate chunk names and may blow up browser caches and bundle size reports.

View File

@@ -1,6 +1,6 @@
# 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/latest/use/core-concepts#rule-suggestions).
🔧💡 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 -->

View File

@@ -32,7 +32,7 @@ You can also use an array of globs instead of literal booleans:
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js", "**/*.spec.js"]}]
```
When using an array of globs, the setting will be set to `true` (no errors reported) if the name of the file being linted (i.e. not the imported file/module) matches a single glob in the array, and `false` otherwise.
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.

View File

@@ -29,9 +29,8 @@ This rule takes the following option:
- **`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`)
- **`ignoreUnusedTypeExports`**: if `true`, TypeScript type exports without any static usage within other modules are reported (defaults to `false` and has no effect unless `unusedExports` is `true`)
- **`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)
- `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
@@ -117,16 +116,6 @@ export function doAnything() {
export default 5 // will not be reported
```
### Unused exports with `ignoreUnusedTypeExports` set to `true`
The following will not be reported:
```ts
export type Foo = {}; // will not be reported
export interface Foo = {}; // will not be reported
export enum Foo {}; // will not be reported
```
#### 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`

View File

@@ -77,25 +77,6 @@ import foo from './foo';
var path = require('path');
```
## Limitations of `--fix`
Unbound imports are assumed to have side effects, and will never be moved/reordered. This can cause other imports to get "stuck" around them, and the fix to fail.
```javascript
import b from 'b'
import 'format.css'; // This will prevent --fix from working.
import a from 'a'
```
As a workaround, move unbound imports to be entirely above or below bound ones.
```javascript
import 'format1.css'; // OK
import b from 'b'
import a from 'a'
import 'format2.css'; // OK
```
## Options
This rule supports the following options:
@@ -193,7 +174,7 @@ Example:
### `pathGroupsExcludedImportTypes: [array]`
This defines import types that are not handled by configured pathGroups.
If you have added path groups with patterns that look like `"builtin"` or `"external"` imports, you have to remove this group (`"builtin"` and/or `"external"`) from the default exclusion list (e.g., `["builtin", "external", "object"]`, etc) to sort these path groups correctly.
This is mostly needed when you want to handle path groups that look like external imports.
Example:
@@ -212,7 +193,29 @@ Example:
}
```
[Import Type](https://github.com/import-js/eslint-plugin-import/blob/HEAD/src/core/importType.js#L90) is resolved as a fixed string in predefined set, it can't be a `patterns`(e.g., `react`, `react-router-dom`, etc). See [#2156] for details.
You can also use `patterns`(e.g., `react`, `react-router-dom`, etc).
Example:
```json
{
"import/order": [
"error",
{
"pathGroups": [
{
"pattern": "react",
"group": "builtin",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["react"]
}
]
}
```
The default value is `["builtin", "external", "object"]`.
### `newlines-between: [ignore|always|always-and-inside-groups|never]`