Skip to content

Commit c69fdac

Browse files
fasttimemdjermanovicnzakas
authored
feat!: remove eslintrc support (#20037)
* feat!: remove eslintrc support from CLI * remove link * remove `null` * remove unnecessary check * remove warning about using eslint.config.js * update `docs/src/use/command-line-interface.md` * add `--parser` and `--plugin` tests * Update lib/options.js Co-authored-by: Milos Djermanovic <[email protected]> * Update lib/options.js Co-authored-by: Milos Djermanovic <[email protected]> * feat: Remove eslintrc methods from Linter closes #13481 * Fix linter warnings * Remove eslintrc references * Fix failing tests * Fix failing test * Fix types test * Remove unnecessary dependencies * Clean up loadESLint types * Remove parserPath/parserOptions * Update loadESLint() docs * Update docs/src/integrate/nodejs-api.md Co-authored-by: Francesco Trotta <[email protected]> * Remove unneeded types and code * Update tests/lib/types/types.test.ts Co-authored-by: Francesco Trotta <[email protected]> * Fix types * fix linter and tests * fix format * fix knip * Update lib/linter/linter.js Co-authored-by: Milos Djermanovic <[email protected]> * update migration guide --------- Co-authored-by: Milos Djermanovic <[email protected]> Co-authored-by: Nicholas C. Zakas <[email protected]>
1 parent 0439794 commit c69fdac

Some content is hidden

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

45 files changed

+2527
-35360
lines changed

bin/eslint.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ ${getErrorMessage(error)}`;
174174
const cli = require("../lib/cli");
175175
const exitCode = await cli.execute(
176176
process.argv,
177-
process.argv.includes("--stdin") ? await readStdin() : null,
178-
true,
177+
process.argv.includes("--stdin") ? await readStdin() : void 0,
179178
);
180179

181180
/*

conf/default-cli-options.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

docs/src/integrate/nodejs-api.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ The `LoadedFormatter` value is the object to convert the [LintResult] objects to
552552
553553
## loadESLint()
554554
555-
The `loadESLint()` function is used for integrations that wish to support both the current configuration system (flat config) and the old configuration system (eslintrc). This function returns the correct `ESLint` class implementation based on the arguments provided:
555+
The `loadESLint()` function is used for integrations that wish to support different ESLint versions. This function returns the correct `ESLint` class implementation based on the arguments provided:
556556
557557
```js
558558
const { loadESLint } = require("eslint");
@@ -563,7 +563,7 @@ const DefaultESLint = await loadESLint();
563563
// loads the flat config version specifically
564564
const FlatESLint = await loadESLint({ useFlatConfig: true });
565565

566-
// loads the legacy version specifically
566+
// loads the legacy version specifically if possible, otherwise falls back to flat config version
567567
const LegacyESLint = await loadESLint({ useFlatConfig: false });
568568
```
569569
@@ -586,9 +586,7 @@ if (DefaultESLint.configType === "flat") {
586586
}
587587
```
588588
589-
If you don't need to support both the old and new configuration systems, then it's recommended to just use the `ESLint` constructor directly.
590-
591-
---
589+
**If you don't need to support both the old and new configuration systems, then it's recommended to just use the `ESLint` constructor directly.**
592590
593591
## SourceCode
594592

docs/src/use/command-line-interface.md

Lines changed: 9 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Please note that when passing a glob as a parameter, it is expanded by your shel
4646
args: ["\"lib/**\""]
4747
}) }}
4848

49-
If you are using a [flat configuration file](./configure/configuration-files) (`eslint.config.js`), you can also omit the file arguments and ESLint will use `.`. For instance, these two lines perform the same operation:
49+
You can also omit the file arguments and ESLint will use `.`. For instance, these two lines perform the same operation:
5050

5151
{{ npx_tabs ({
5252
package: "eslint",
@@ -58,8 +58,6 @@ If you are using a [flat configuration file](./configure/configuration-files) (`
5858
args: []
5959
}) }}
6060

61-
If you are not using a flat configuration file, running ESLint without file arguments results in an error.
62-
6361
**Note:** You can also use alternative package managers such as [Yarn](https://yarnpkg.com/) or [pnpm](https://pnpm.io/) to run ESLint. For pnpm use `pnpm dlx eslint` and for Yarn use `yarn dlx eslint`.
6462

6563
## Pass Multiple Values to an Option
@@ -162,7 +160,7 @@ Miscellaneous:
162160

163161
#### `--no-config-lookup`
164162

165-
**Flat Config Mode Only.** Disables use of configuration from files.
163+
Disables use of configuration from files.
166164

167165
- **Argument Type**: No argument.
168166

@@ -173,19 +171,6 @@ Miscellaneous:
173171
args: ["--no-config-lookup", "file.js"]
174172
}) }}
175173

176-
#### `--no-eslintrc`
177-
178-
**eslintrc Mode Only.** Disables use of configuration from `.eslintrc.*` and `package.json` files. For flat config mode, use [`--no-config-lookup`](#--no-config-lookup) instead.
179-
180-
- **Argument Type**: No argument.
181-
182-
##### `--no-eslintrc` example
183-
184-
{{ npx_tabs ({
185-
package: "eslint",
186-
args: ["--no-eslintrc", "file.js"]
187-
}) }}
188-
189174
#### `-c`, `--config`
190175

191176
This option allows you to specify an additional configuration file for ESLint (see [Configure ESLint](configure/) for more).
@@ -204,7 +189,7 @@ This example uses the configuration file at `~/my.eslint.config.js`, which is us
204189

205190
#### `--inspect-config`
206191

207-
**Flat Config Mode Only.** This option runs `npx @eslint/config-inspector@latest` to start the [config inspector](https://github.com/eslint/config-inspector). You can use the config inspector to better understand what your configuration is doing and which files it applies to. When you use this flag, the CLI does not perform linting.
192+
This option runs `npx @eslint/config-inspector@latest` to start the [config inspector](https://github.com/eslint/config-inspector). You can use the config inspector to better understand what your configuration is doing and which files it applies to. When you use this flag, the CLI does not perform linting.
208193

209194
- **Argument Type**: No argument.
210195

@@ -215,27 +200,6 @@ This example uses the configuration file at `~/my.eslint.config.js`, which is us
215200
args: ["--inspect-config"]
216201
}) }}
217202

218-
#### `--env`
219-
220-
**eslintrc Mode Only.** This option enables specific environments.
221-
222-
- **Argument Type**: String. One of the available environments.
223-
- **Multiple Arguments**: Yes
224-
225-
Details about the global variables defined by each environment are available in the [Specifying Environments](configure/language-options-deprecated#specifying-environments) documentation. This option only enables environments. It does not disable environments set in other configuration files. To specify multiple environments, separate them using commas, or use the option multiple times.
226-
227-
##### `--env` example
228-
229-
{{ npx_tabs ({
230-
package: "eslint",
231-
args: ["--env", "browser,node", "file.js"]
232-
}) }}
233-
234-
{{ npx_tabs ({
235-
package: "eslint",
236-
args: ["--env", "browser", "--env", "node", "file.js"]
237-
}) }}
238-
239203
#### `--ext`
240204

241205
This option allows you to specify additional file extensions to lint.
@@ -324,28 +288,6 @@ This option allows you to specify parser options to be used by ESLint. The avail
324288
previousCommands: ["echo \'3 ** 4\'"]
325289
}) }}
326290

327-
#### `--resolve-plugins-relative-to`
328-
329-
**eslintrc Mode Only.** Changes the directory where plugins are resolved from.
330-
331-
- **Argument Type**: String. Path to directory.
332-
- **Multiple Arguments**: No
333-
- **Default Value**: By default, plugins are resolved from the directory in which your configuration file is found.
334-
335-
This option should be used when plugins were installed by someone other than the end user. It should be set to the project directory of the project that has a dependency on the necessary plugins.
336-
337-
For example:
338-
339-
- When using a config file that is located outside of the current project (with the `--config` flag), if the config uses plugins which are installed locally to itself, `--resolve-plugins-relative-to` should be set to the directory containing the config file.
340-
- If an integration has dependencies on ESLint and a set of plugins, and the tool invokes ESLint on behalf of the user with a preset configuration, the tool should set `--resolve-plugins-relative-to` to the top-level directory of the tool.
341-
342-
##### `--resolve-plugins-relative-to` example
343-
344-
{{ npx_tabs ({
345-
package: "eslint",
346-
args: ["--config", "~/personal-eslintrc.js", "--resolve-plugins-relative-to", "/usr/local/lib/"]
347-
}) }}
348-
349291
### Specify Rules and Plugins
350292

351293
#### `--plugin`
@@ -406,29 +348,6 @@ To ignore rules in configuration files and only run rules specified in the comma
406348
comment: "Only apply rule from the command line"
407349
}) }}
408350

409-
#### `--rulesdir`
410-
411-
**Deprecated**: Use [rules from custom plugins](https://eslint.org/blog/2022/08/new-config-system-part-2/#from---rulesdir-to-runtime-plugins) instead.
412-
413-
**eslintrc Mode Only.** This option allows you to specify another directory from which to load rules files. This allows you to dynamically load new rules at run time. This is useful when you have custom rules that aren't suitable for being bundled with ESLint.
414-
415-
- **Argument Type**: String. Path to directory. The rules in your custom rules directory must follow the same format as bundled rules to work properly.
416-
- **Multiple Arguments**: Yes
417-
418-
Note that, as with core rules and plugin rules, you still need to enable the rules in configuration or via the `--rule` CLI option in order to actually run those rules during linting. Specifying a rules directory with `--rulesdir` does not automatically enable the rules within that directory.
419-
420-
##### `--rulesdir` example
421-
422-
{{ npx_tabs ({
423-
package: "eslint",
424-
args: ["--rulesdir", "my-rules/", "file.js"]
425-
}) }}
426-
427-
{{ npx_tabs ({
428-
package: "eslint",
429-
args: ["--rulesdir", "my-rules/", "--rulesdir", "my-other-rules/", "file.js"]
430-
}) }}
431-
432351
### Fix Problems
433352

434353
#### `--fix`
@@ -501,31 +420,9 @@ This option is helpful if you are using another program to format your code, but
501420

502421
### Ignore Files
503422

504-
#### `--ignore-path`
505-
506-
**eslintrc Mode Only.** This option allows you to specify the file to use as your `.eslintignore`.
507-
508-
- **Argument Type**: String. Path to file.
509-
- **Multiple Arguments**: No
510-
- **Default Value**: By default, ESLint looks for `.eslintignore` in the current working directory.
511-
512-
**Note:** `--ignore-path` is only supported when using [deprecated configuration](./configure/configuration-files-deprecated). If you want to include patterns from a `.gitignore` file in your `eslint.config.js` file, please see [including `.gitignore` files](./configure/ignore#including-gitignore-files).
513-
514-
##### `--ignore-path` example
515-
516-
{{ npx_tabs ({
517-
package: "eslint",
518-
args: ["--ignore-path", "tmp/.eslintignore", "file.js"]
519-
}) }}
520-
521-
{{ npx_tabs ({
522-
package: "eslint",
523-
args: ["--ignore-path", ".gitignore", "file.js"]
524-
}) }}
525-
526423
#### `--no-ignore`
527424

528-
Disables excluding of files from [`--ignore-pattern`](#--ignore-pattern) flags and the `ignores` property in configuration. In eslintrc mode, `.eslintignore` files, [`--ignore-path`](#--ignore-path) flags, and the `ignorePatterns` property in configuration are also disabled.
425+
Disables excluding of files from [`--ignore-pattern`](#--ignore-pattern) flags and the `ignores` property in configuration.
529426

530427
- **Argument Type**: No argument.
531428

@@ -538,9 +435,9 @@ Disables excluding of files from [`--ignore-pattern`](#--ignore-pattern) flags a
538435

539436
#### `--ignore-pattern`
540437

541-
This option allows you to specify patterns of files to ignore. In eslintrc mode, these are in addition to `.eslintignore`.
438+
This option allows you to specify patterns of files to ignore.
542439

543-
- **Argument Type**: String. The supported syntax is the same as for [`ignores` patterns](configure/configuration-files#excluding-files-with-ignores), which use [minimatch](https://www.npmjs.com/package/minimatch) syntax. In eslintrc mode, the syntax is the same as for [`.eslintignore` files](configure/ignore-deprecated#the-eslintignore-file), which use the same patterns as the [`.gitignore` specification](https://git-scm.com/docs/gitignore). You should quote your patterns in order to avoid shell interpretation of glob patterns.
440+
- **Argument Type**: String. The supported syntax is the same as for [`ignores` patterns](configure/configuration-files#excluding-files-with-ignores), which use [minimatch](https://www.npmjs.com/package/minimatch) syntax. You should quote your patterns in order to avoid shell interpretation of glob patterns.
544441
- **Multiple Arguments**: Yes
545442

546443
##### `--ignore-pattern` example
@@ -727,7 +624,6 @@ This allows you to set an ESLint config without files modifying it. All inline c
727624
- `/*eslint-enable*/`
728625
- `/*global*/`
729626
- `/*eslint*/`
730-
- `/*eslint-env*/`
731627
- `// eslint-disable-line`
732628
- `// eslint-disable-next-line`
733629

@@ -963,7 +859,7 @@ The ESLint team may ask for this information to help solve bugs. When you use th
963859

964860
#### `--no-error-on-unmatched-pattern`
965861

966-
This option prevents errors when a quoted glob pattern or `--ext` is unmatched. This does not prevent errors when your shell can't match a glob.
862+
This option prevents errors when a quoted glob pattern is unmatched. This does not prevent errors when your shell can't match a glob.
967863

968864
- **Argument Type**: No argument.
969865

@@ -989,7 +885,7 @@ This option causes ESLint to exit with exit code 2 if one or more fatal parsing
989885

990886
#### `--no-warn-ignored`
991887

992-
**Flat Config Mode Only.** This option suppresses both `File ignored by default` and `File ignored because of a matching ignore pattern` warnings when an ignored filename is passed explicitly. It is useful when paired with `--max-warnings 0` as it will prevent exit code 1 due to the aforementioned warning.
888+
This option suppresses both `File ignored by default` and `File ignored because of a matching ignore pattern` warnings when an ignored filename is passed explicitly. It is useful when paired with `--max-warnings 0` as it will prevent exit code 1 due to the aforementioned warning.
993889

994890
- **Argument Type**: No argument.
995891

@@ -1002,7 +898,7 @@ This option causes ESLint to exit with exit code 2 if one or more fatal parsing
1002898

1003899
#### `--pass-on-no-patterns`
1004900

1005-
This option allows ESLint to exit with code 0 when no file or directory patterns are passed. Without this option, ESLint assumes you want to use `.` as the pattern. (When running in legacy eslintrc mode, ESLint will exit with code 1.)
901+
This option allows ESLint to exit with code 0 when no file or directory patterns are passed. Without this option, ESLint assumes you want to use `.` as the pattern.
1006902

1007903
- **Argument Type**: No argument.
1008904

docs/src/use/configure/configuration-files-deprecated.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The second way to use configuration files is to save the file wherever you would
3939
eslint -c myconfig.json myfiletotest.js
4040
```
4141

42-
If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use [`--no-eslintrc`](../command-line-interface#--no-eslintrc) along with the [`--config`](../../use/command-line-interface#-c---config) flag.
42+
If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use `--no-eslintrc` along with the [`--config`](../../use/command-line-interface#-c---config) flag.
4343

4444
Here's an example JSON configuration file that uses the `typescript-eslint` parser to support TypeScript syntax:
4545

@@ -432,4 +432,4 @@ If `eslint` could find configuration files in the project, `eslint` ignores `~/.
432432

433433
`~/.eslintrc.*` files load shareable configs and custom parsers from `~/node_modules/` – similarly to `require()` – in the user's home directory. Please note that it doesn't load global-installed packages.
434434

435-
`~/.eslintrc.*` files load plugins from `$CWD/node_modules` by default in order to identify plugins uniquely. If you want to use plugins with `~/.eslintrc.*` files, plugins must be installed locally per project. Alternatively, you can use the [`--resolve-plugins-relative-to` CLI option](../command-line-interface#--resolve-plugins-relative-to) to change the location from which ESLint loads plugins.
435+
`~/.eslintrc.*` files load plugins from `$CWD/node_modules` by default in order to identify plugins uniquely. If you want to use plugins with `~/.eslintrc.*` files, plugins must be installed locally per project. Alternatively, you can use the `--resolve-plugins-relative-to` CLI option to change the location from which ESLint loads plugins.

docs/src/use/migrate-to-10.0.0.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The lists below are ordered roughly by the number of users each change is expect
1717

1818
- [Node.js < v20.19, v21, v23 are no longer supported](#drop-old-node)
1919
- [New configuration file lookup algorithm](#config-lookup-from-file)
20+
- [Old config format no longer supported](#remove-eslintrc)
2021
- [Deprecated options of the `radix` rule](#radix)
2122
- [`no-shadow-restricted-names` now reports `globalThis` by default](#no-shadow-restricted-names)
2223
- [`eslint:recommended` has been updated](#eslint-recommended)
@@ -28,6 +29,7 @@ The lists below are ordered roughly by the number of users each change is expect
2829
### Breaking changes for plugin developers
2930

3031
- [Node.js < v20.19, v21, v23 are no longer supported](#drop-old-node)
32+
- [Old config format no longer supported](#remove-eslintrc)
3133
- [Removal of `type` property in errors of invalid `RuleTester` cases](#ruletester-type-removed)
3234
- [Fixer methods now require string `text` arguments](#fixer-text-must-be-string)
3335
- [`Program` AST node range spans entire source text](#program-node-range)
@@ -37,6 +39,7 @@ The lists below are ordered roughly by the number of users each change is expect
3739

3840
- [Node.js < v20.19, v21, v23 are no longer supported](#drop-old-node)
3941
- [New configuration file lookup algorithm](#config-lookup-from-file)
42+
- [Old config format no longer supported](#remove-eslintrc)
4043
- [Removal of `nodeType` property in `LintMessage` objects](#lintmessage-nodetype-removed)
4144
- [`Program` AST node range spans entire source text](#program-node-range)
4245

@@ -68,6 +71,20 @@ In ESLint v9, the alternate config lookup behavior could be enabled with the `v1
6871

6972
**Related issue(s):** [#19967](https://github.com/eslint/eslint/issues/19967)
7073

74+
## <a name="remove-eslintrc"></a> Old config format no longer supported
75+
76+
ESLint v9 introduced a [new default configuration format](./configure/configuration-files) based on the `eslint.config.js` file. The [old format](./configure/configuration-files-deprecated), which used `.eslintrc` or `.eslintrc.json`, could still be enabled in v9 by setting the `ESLINT_USE_FLAT_CONFIG` environment variable to `false`.
77+
78+
Starting with ESLint v10, the old configuration format is no longer supported.
79+
80+
**To address:**
81+
82+
- Follow the instructions in the [configuration migration guide](./configure/migration-guide).
83+
- Be aware that the deprecated APIs `FlatESLint` and `LegacyESLint` have been removed. Always use `ESLint` instead.
84+
- The `configType` option of the `Linter` class can no longer be set to `"eslintrc"`. Remove the option to use the new configuration format.
85+
86+
**Related issue(s):** [#13481](https://github.com/eslint/eslint/issues/13481)
87+
7188
## <a name="radix"></a> Deprecated options of the `radix` rule
7289

7390
As of ESLint v10.0.0, string options `"always"` and `"as-needed"` of the [`radix`](../rules/radix) rule are deprecated. Setting either of these options doesn't change the behavior of this rule, which now always enforces providing a radix, as it was the case when the `"always"` option (default) was specified. Since the default radix depends on the first argument of `parseInt()`, this rule assumes that the second argument (the radix) is always needed.

docs/src/use/migrating-to-6.0.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ As a rule of thumb: With ESLint v6, plugins should always be installed locally,
9898

9999
**To address:** If you use a global installation of ESLint (e.g. installed with `npm install eslint --global`) along with plugins, you should install those plugins locally in the projects where you run ESLint. If your config file extends shareable configs and/or parsers, you should ensure that those packages are installed as dependencies of the project containing the config file.
100100

101-
If you use a config file located outside of a local project (with the `--config` flag), consider installing the plugins as dependencies of that config file, and setting the [`--resolve-plugins-relative-to`](./command-line-interface#--resolve-plugins-relative-to) flag to the location of the config file.
101+
If you use a config file located outside of a local project (with the `--config` flag), consider installing the plugins as dependencies of that config file, and setting the `--resolve-plugins-relative-to` flag to the location of the config file.
102102

103103
**Related issue(s):** [eslint/eslint#10125](https://github.com/eslint/eslint/issues/10125), [eslint/rfcs#7](https://github.com/eslint/rfcs/pull/7)
104104

0 commit comments

Comments
 (0)