Skip to content

Commit 637216b

Browse files
authored
docs: update CLI flags migration instructions (#20238)
1 parent e7cda3b commit 637216b

File tree

1 file changed

+53
-25
lines changed

1 file changed

+53
-25
lines changed

docs/src/use/configure/migration-guide.md

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -639,65 +639,93 @@ export default defineConfig([
639639
640640
The following CLI flags are no longer supported with the flat config file format:
641641
642-
- `--rulesdir`
643-
- `--ext`
642+
- `--env`
643+
- `--ignore-path`
644+
- `--no-eslintrc`
644645
- `--resolve-plugins-relative-to`
646+
- `--rulesdir`
645647
646-
The flag `--no-eslintrc` has been replaced with `--no-config-lookup`.
648+
#### `--env`
647649
648-
#### `--rulesdir`
650+
The `--env` flag was used to enable environment-specific globals (for example, `browser`, or `node`). Flat config doesn't support this flag. Instead, define the relevant globals directly in your configuration. See [Specifying Globals](language-options#specifying-globals) for more details.
649651
650-
The `--rulesdir` flag was used to load additional rules from a specified directory. This is no longer supported when using flat config. You can instead create a plugin containing the local rules you have directly in your config, like this:
652+
For example, if you previously used `--env browser,node`, you’ll need to update your config file like this:
651653
652654
```js
653655
// eslint.config.js
654656
import { defineConfig } from "eslint/config";
655-
import myRule from "./rules/my-rule.js";
657+
import globals from "globals";
656658

657659
export default defineConfig([
658660
{
659-
// define the plugin
660-
plugins: {
661-
local: {
662-
rules: {
663-
"my-rule": myRule,
664-
},
661+
languageOptions: {
662+
globals: {
663+
...globals.browser,
664+
...globals.node,
665665
},
666666
},
667-
668-
// configure the rule
669-
rules: {
670-
"local/my-rule": ["error"],
671-
},
672667
},
673668
]);
674669
```
675670
676-
#### `--ext`
671+
#### `--ignore-path`
677672
678-
The `--ext` flag was used to specify additional file extensions ESLint should search for when a directory was passed on the command line, such as `npx eslint .`. This is no longer supported when using flat config. Instead, specify the file patterns you'd like ESLint to search for directly in your config. For example, if you previously were using `--ext .ts,.tsx`, then you will need to update your config file like this:
673+
The `--ignore-path` flag was used to specify which file to use as your `.eslintignore`. Flat config doesn't load ignore patterns from `.eslintignore` files and does not support this flag. If you want to include patterns from a `.gitignore` file, use `includeIgnoreFile()` from `@eslint/compat`. See [Including `.gitignore` Files](ignore#including-gitignore-files) for more details.
674+
675+
For example, if you previously used `--ignore-path .gitignore`:
679676
680677
```js
681678
// eslint.config.js
682679
import { defineConfig } from "eslint/config";
680+
import { includeIgnoreFile } from "@eslint/compat";
681+
import { fileURLToPath } from "node:url";
683682

684-
export default defineConfig([
685-
{
686-
files: ["**/*.ts", "**/*.tsx"],
683+
const gitignorePath = fileURLToPath(new URL(".gitignore", import.meta.url));
687684

688-
// any additional configuration for these file types here
689-
},
685+
export default defineConfig([
686+
includeIgnoreFile(gitignorePath, "Imported .gitignore patterns"),
687+
// other configs
690688
]);
691689
```
692690
693-
ESLint uses the `files` keys from the config file to determine which files should be linted.
691+
#### `--no-eslintrc`
692+
693+
The `--no-eslintrc` flag has been replaced with `--no-config-lookup`.
694694
695695
#### `--resolve-plugins-relative-to`
696696
697697
The `--resolve-plugins-relative-to` flag was used to indicate which directory plugin references in your configuration file should be resolved relative to. This was necessary because shareable configs could only resolve plugins that were peer dependencies or dependencies of parent packages.
698698
699699
With flat config, shareable configs can specify their dependencies directly, so this flag is no longer needed.
700700
701+
#### `--rulesdir`
702+
703+
The `--rulesdir` flag was used to load additional rules from a specified directory. This is no longer supported when using flat config. You can instead create a plugin containing the local rules you have directly in your config, like this:
704+
705+
```js
706+
// eslint.config.js
707+
import { defineConfig } from "eslint/config";
708+
import myRule from "./rules/my-rule.js";
709+
710+
export default defineConfig([
711+
{
712+
// define the plugin
713+
plugins: {
714+
local: {
715+
rules: {
716+
"my-rule": myRule,
717+
},
718+
},
719+
},
720+
721+
// configure the rule
722+
rules: {
723+
"local/my-rule": ["error"],
724+
},
725+
},
726+
]);
727+
```
728+
701729
### `package.json` Configuration No Longer Supported
702730
703731
With eslintrc, it was possible to use a `package.json` file to configure ESLint using the `eslintConfig` key.

0 commit comments

Comments
 (0)