Skip to content

Documenting configuration hierarchy for CLIEngine options and 'useEslintrc: true' #9526

@edmorley

Description

@edmorley

Hi! Many thanks for a great tool :-)

I was trying to work out from the docs, which options take precedence in the following example:

// Some tool
var CLIEngine = require("eslint").CLIEngine;

var cli = new CLIEngine({
    // ...
    useEslintrc: true,
    rules: {
        semi: "error"
    }
});
// .eslintrc
{
    "rules": {
        "semi": "off"
    }
}

The CLIEngine docs just say:

useEslintrc - Set to false to disable use of .eslintrc files (default: true). Corresponds to --no-eslintrc.

And the docs on configuration hierarchy/precedence don't mention CLIEngine at all:

The complete configuration hierarchy, from highest precedence to lowest precedence, is as follows:

  1. Inline configuration
    1. /*eslint-disable*/ and /*eslint-enable*/
    2. /*global*/
    3. /*eslint*/
    4. /*eslint-env*/
  2. Command line options:
    1. --global
    2. --rule
    3. --env
    4. -c, --config
  3. Project-level configuration:
    1. .eslintrc.* or package.json file in same directory as linted file
    2. Continue searching for .eslintrc and package.json files in ancestor directories (parent has highest precedence, then grandparent, etc.), up to and including the root directory or until a config with "root": true is found.
    3. In the absence of any configuration from (1) thru (3), fall back to a personal default configuration in ~/.eslintrc.

From experimentation, I've found that the options passed to CLIEngine take priority over the ones in .eslintrc, however I think it would be good to document this.

I'm happy to open a PR to do so, but it would be useful to know whether I should do so on the configuration page, the API page, or both?

Many thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussioncoreRelates to ESLint's core APIs and featuresdocumentationRelates to ESLint's documentationgood first issueGood for people who haven't worked on ESLint before

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions