question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
PiIsFourcommented, Jan 17, 2018

Hi, I’m new to this. But would like to give it a try, if that’s ok with you all.

0reactions
platinumazurecommented, Jan 17, 2018

@PiIsFour The change looks good to me. Don’t worry, our Travis Continuous Integration service will check for issues when you create the pull request.

I think npm run docs has been broken for some time. I don’t use it at all. We have a separate script which will copy the documentation from ESLint to eslint.github.io as part of our release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How to use the eslint.CLIEngine function in eslint - Snyk
CLIEngine examples, based on popular ways it is used in public projects. ... '.eslintrc.js'); } if (options) { Hoek.merge(configuration, options, true, ...
Read more >
eslint/eslint - Gitter
Hey, I have an issue that I use Node API to write script verify my js file, but .eslintrc not work, how to...
Read more >
VS Code ESLint extension - Visual Studio Marketplace
If you are new to ESLint check the documentation. ... To follow VS Code's model to confirm workspace local settings that impact code ......
Read more >
eslint-config-eslint | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found