Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
New: Config files with extensions (fixes eslint#4045, fixes eslint#4263)
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Nov 16, 2015
1 parent 425eb7c commit c9a8883
Show file tree
Hide file tree
Showing 38 changed files with 1,625 additions and 613 deletions.
File renamed without changes.
21 changes: 20 additions & 1 deletion docs/user-guide/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ESLint is designed to be completely configurable, meaning you can turn off every rule and run only with basic syntax validation, or mix and match the bundled rules and your custom rules to make ESLint perfect for your project. There are two primary ways to configure ESLint:

1. **Configuration Comments** - use JavaScript comments to embed configuration information directly into a file.
1. **Configuration Files** - use a JSON or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of an `.eslintrc` file or an `eslintConfig` field in a `package.json` file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](command-line-interface).
1. **Configuration Files** - use a JavaScript, JSON or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of an `.eslintrc` file or an `eslintConfig` field in a `package.json` file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](command-line-interface).

There are several pieces of information that can be configured:

Expand Down Expand Up @@ -382,6 +382,25 @@ The second way to use configuration files is via `.eslintrc` and `package.json`

In each case, the settings in the configuration file override default settings.

## Configuration File Formats

ESLint supports configuration files in several formats:

* **JavaScript** - use `.eslintrc.js` and export an object containing your configuration.
* **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.
* **package.json** - create an `eslintConfig` property in your `package.json` file and define your configuration there.
* **Deprecated** - use `.eslintrc`, which can be either JSON or YAML.

If there are multiple `.eslintrc.*` files in the same directory, ESLint will only use one. The priority order is:

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


## Configuration Cascading and Hierarchy

When using `.eslintrc` and `package.json` files for configuration, you can take advantage of configuration cascading. For instance, suppose you have the following structure:
Expand Down
2 changes: 1 addition & 1 deletion lib/cli-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var fs = require("fs"),
fileEntryCache = require("file-entry-cache"),
globUtil = require("./util/glob-util"),
SourceCodeFixer = require("./util/source-code-fixer"),
validator = require("./config-validator"),
validator = require("./config/config-validator"),
stringify = require("json-stable-stringify"),

crypto = require( "crypto" ),
Expand Down
Loading

0 comments on commit c9a8883

Please sign in to comment.