You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following CLI flags are no longer supported with the flat config file format:
641
641
642
-
- `--rulesdir`
643
-
- `--ext`
642
+
- `--env`
643
+
- `--ignore-path`
644
+
- `--no-eslintrc`
644
645
- `--resolve-plugins-relative-to`
646
+
- `--rulesdir`
645
647
646
-
The flag `--no-eslintrc` has been replaced with `--no-config-lookup`.
648
+
#### `--env`
647
649
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.
649
651
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:
651
653
652
654
```js
653
655
// eslint.config.js
654
656
import { defineConfig } from"eslint/config";
655
-
importmyRulefrom"./rules/my-rule.js";
657
+
importglobalsfrom"globals";
656
658
657
659
exportdefaultdefineConfig([
658
660
{
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,
665
665
},
666
666
},
667
-
668
-
// configure the rule
669
-
rules: {
670
-
"local/my-rule": ["error"],
671
-
},
672
667
},
673
668
]);
674
669
```
675
670
676
-
#### `--ext`
671
+
#### `--ignore-path`
677
672
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`:
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`.
694
694
695
695
#### `--resolve-plugins-relative-to`
696
696
697
697
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.
698
698
699
699
With flat config, shareable configs can specify their dependencies directly, so this flag is no longer needed.
700
700
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
+
importmyRulefrom"./rules/my-rule.js";
709
+
710
+
exportdefaultdefineConfig([
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
+
701
729
### `package.json` Configuration No Longer Supported
702
730
703
731
With eslintrc, it was possible to use a `package.json` file to configure ESLint using the `eslintConfig` key.
0 commit comments