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.

Cannot override rule in shared config

See original GitHub issue

ESLint v1.6.0

In my .eslintrc, I’m extending the AirBnb config and overriding a rule like this:

{
    "extends": "airbnb",
    "rules": {
        "indent": 2
    }
}

I couldn’t find an example elsewhere, but eslint-config-airbnb v0.1.0 is overriding a rule the same way in its .eslintrc file so I assume what I have is correct. However, I’m seeing the following output when I run eslint scripts/**:

C:\dev\my-project\scripts\index.js
  2:5  error    Expected indentation of 2 space characters but found 4  indent
  2:5  warning  Unexpected console statement                            no-console

✖ 2 problems (1 error, 1 warning)

Issue Analytics

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

github_iconTop GitHub Comments

8reactions
danny-andrewscommented, May 12, 2016

This behavior still seems confusing to me, and (as far as I understand it) makes it impossible to override certain rule options (see #6144). Also, @nzakas, I don’t see anywhere in the docs where it explains that rule options will be inherited from extended configs, just that rules can be overridden in the child configs. I was lead to believe that if you specified a rule in a child config, it would completely negate any rules of the same name in extended configs, resorting back to that rule’s default options if none are specified.

3reactions
chazzlabscommented, Oct 7, 2015

@ilyavolodin Sure, sorry. The code is simply:

function run() {
    console.log('Hello, world');
}

exports.run = run;

The documentation for the indent rule (http://eslint.org/docs/rules/indent.html) says the default is 4 spaces and gives the example "indent": 2 for 4-space indentation, so I expected that overriding any extended configs using that configuration for the indent rule would make eslint pass for any files using 4-space indentation.

I’ve changed my .eslintrc to the following, specifying a number of spaces, and it works now:

{
    "extends": "airbnb",
    "rules": {
        "indent": [2, 4]
    }
}

Perhaps the default space setting for indentation is overridden elsewhere and I’m not aware of it or haven’t found it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to adjust (not 100% override) existing eslint rule's ...
I would like to slightly adjust the import/no-extraneous-dependencies rule which is already configured with airbnb config. I am interested in ...
Read more >
Action overrides in rule groups - AWS WAF ...
Overriding the actions for a rule group inside your web ACL configuration doesn't alter the rule group itself. It only alters how AWS...
Read more >
GitLab CI/CD include examples
This method is called merging. Override included configuration arrays. You can use merging to extend and override configuration in an included template, but...
Read more >
Overriding the default Palo Alto Policies - YouTube
There are a few default policies in the Palo Alto that cannot be modified, however they can be overridden. Here we discuss why...
Read more >
Data Loss Prevention policy reference
DLP policy component and configuration reference. ... Rule 1: blocks activity and doesn't allow user override; Rule 2: blocks activity and ...
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