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
feat: Enable eslint.config.mjs and eslint.config.cjs (#18066)
* feat: Enable eslint.config.mjs and eslint.config.cjs
* Update CLI description
(cherry picked from commit 8792464)
* docs: update documentation for eslint.config.mjs & eslint.config.cjs support
---------
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
Copy file name to clipboardexpand all lines: docs/src/use/configure/configuration-files-new.md
+8-20
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,13 @@ You can put your ESLint project configuration in a configuration file. You can i
16
16
17
17
## Configuration File
18
18
19
-
The ESLint configuration file is named `eslint.config.js`. It should be placed in the root directory of your project and export an array of [configuration objects](#configuration-objects). Here's an example:
19
+
The ESLint configuration file may be named any of the following:
20
+
21
+
*`eslint.config.js`
22
+
*`eslint.config.mjs`
23
+
*`eslint.config.cjs`
24
+
25
+
It should be placed in the root directory of your project and export an array of [configuration objects](#configuration-objects). Here's an example:
20
26
21
27
```js
22
28
exportdefault [
@@ -44,24 +50,6 @@ module.exports = [
44
50
];
45
51
```
46
52
47
-
The configuration file can also export a promise that resolves to the configuration array. This can be useful for using ESM dependencies in CommonJS configuration files, as in this example:
ESLint only automatically looks for a config file named `eslint.config.js` and does not look for `eslint.config.cjs` or `eslint.config.mjs`. If you'd like to specify a different config filename than the default, use the `--config` command line option.
63
-
:::
64
-
65
53
## Configuration Objects
66
54
67
55
Each configuration object contains all of the information ESLint needs to execute on a set of files. Each configuration object is made up of these properties:
@@ -668,7 +656,7 @@ export default [
668
656
669
657
## Configuration File Resolution
670
658
671
-
When ESLint is run on the command line, it first checks the current working directory for `eslint.config.js`. If the file is not found, it looks to the next parent directory for the file. This search continues until either the file is found or the root directory is reached.
659
+
When ESLint is run on the command line, it first checks the current working directory for `eslint.config.js`. If that file is found, then the search stops, otherwise it checks for `eslint.config.mjs`. If that file is found, then the search stops, otherwise it checks for `eslint.config.cjs`. If none of the files are not found, it checks the parent directory for each file. This search continues until either a config file is found or the root directory is reached.
672
660
673
661
You can prevent this search for `eslint.config.js` by setting the `ESLINT_USE_FLAT_CONFIG` environment variable to `true` and using the `-c` or `--config` option on the command line to specify an alternate configuration file, such as:
0 commit comments