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.

Fix extending rules within overrides

See original GitHub issue

Clearly describe the bug

When using extends within the overrides property, the rules don’t seem to override.

Which rule, if any, is the bug related to?

None.

What code is needed to reproduce the bug?

input.scss:

@mixin {}

What Stylelint configuration is needed to reproduce the bug?

.stylelintrc.json:

{
  "rules": {
    "at-rule-no-unknown": true
  },
  "overrides": [
    {
      "files": "**/*.scss",
      "extends": ["./scss.json"]
    }
  ]
}

scss.json:

{
  "customSyntax": "postcss-scss",
  "rules": {
    "at-rule-no-unknown": null
  }
}

Which version of Stylelint are you using?

14.0.0

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

CLI with npx stylelint input.scss

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

N/A

What did you expect to happen?

No warnings to be flagged.

What actually happened (e.g. what warnings or errors did you get)?

The following warnings were flagged:

input.scss
 1:1  ✖  Unexpected unknown at-rule "@mixin"  at-rule-no-unknown

What do we think should be the intended behaviour here? I was expecting the rule to be overridden for scss files, i.e. to have the following resolved config:

{
  "rules": {
    "at-rule-no-unknown": [
      null
    ]
  },
  "customSyntax": "postcss-scss"
}

But npx stylelint input.scss --print-config gives me:

{
  "rules": {
    "at-rule-no-unknown": [
      true
    ]
  },
  "customSyntax": "postcss-scss"
}

I’m running into this issue while looking into https://github.com/twbs/stylelint-config-twbs-bootstrap/issues/128, where I’d like to write the following:

{
  "extends": ["stylelint-config-standard"],
  "overrides": [
    {
      "files": "**/*.scss",
      "extends": ["stylelint-config-standard-scss"]
    }
  ]
}

At-mentioning @ota-meshi because of https://github.com/stylelint/stylelint/pull/5603.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jeddy3commented, Nov 1, 2021

@ota-meshi Thank you for the clear explanation.

I had it in my head that extends was resolved before overrides, but I think you’re right. Users would expect a top-level rules property to take precedence over any overrides define in a config that they extend.

1reaction
hudochenkovcommented, Oct 26, 2021

Expected behavior seems correct to me. Rule should be disabled for *.scss files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How extended config overrides my rules #15753 - eslint/eslint
Assume I have above .eslintrc.json , what would be the impact if airbnb-base turned off some rules but the eslint:recommended turns on by...
Read more >
eslint disable extends in override - javascript - Stack Overflow
The workaround involves looping over any extended rulesets and turning them all off. module.exports = { root: true, parserOptions: { ecmaVersion ...
Read more >
Enforce good code style with ESLint and EditorConfig - IBM
The sample extends the configuration file in the spm-eslint-config package, which contains a set of predefined coding style rules. You can override rules...
Read more >
Overriding and Hiding Methods (The Java™ Tutorials ...
When overriding a method, you might want to use the @Override annotation that instructs the compiler that you intend to override a method...
Read more >
Working with Rules - 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 >

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