Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: support .eslintrc.cjs (refs eslint/rfcs#43) #12321

Merged
merged 4 commits into from Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/user-guide/configuring.md
Expand Up @@ -664,6 +664,7 @@ In each case, the settings in the configuration file override default settings.
ESLint supports configuration files in several formats:

* **JavaScript** - use `.eslintrc.js` and export an object containing your configuration.
* **JavaScript (ESM)** - same as `.eslintrc.js` but used with ES module packages
kaicataldo marked this conversation as resolved.
Show resolved Hide resolved
kaicataldo marked this conversation as resolved.
Show resolved Hide resolved
* **YAML** - use `.eslintrc.yaml` or `.eslintrc.yml` to define the configuration structure.
* **JSON** - use `.eslintrc.json` to define the configuration structure. ESLint's JSON files also allow JavaScript-style comments.
* **Deprecated** - use `.eslintrc`, which can be either JSON or YAML.
Expand All @@ -672,12 +673,14 @@ ESLint supports configuration files in several formats:
If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is:

1. `.eslintrc.js`
1. `.eslintrc.cjs`
1. `.eslintrc.yaml`
1. `.eslintrc.yml`
1. `.eslintrc.json`
1. `.eslintrc`
1. `package.json`

**Note:** JavaScript (ESM) is for use with JavaScript packages that specify `"type":"module"` in `package.json`.

## Configuration Cascading and Hierarchy

Expand Down
2 changes: 2 additions & 0 deletions lib/cli-engine/config-array-factory.js
Expand Up @@ -62,6 +62,7 @@ const eslintRecommendedPath = path.resolve(__dirname, "../../conf/eslint-recomme
const eslintAllPath = path.resolve(__dirname, "../../conf/eslint-all.js");
const configFilenames = [
".eslintrc.js",
".eslintrc.cjs",
".eslintrc.yaml",
".eslintrc.yml",
".eslintrc.json",
Expand Down Expand Up @@ -279,6 +280,7 @@ function configMissingError(configName, importerName) {
function loadConfigFile(filePath) {
switch (path.extname(filePath)) {
case ".js":
case ".cjs":
return loadJSConfigFile(filePath);

case ".json":
Expand Down