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.

at-rule-no-unknown errors

See original GitHub issue

I get at-rule-no-unknown errors for things like @extend, @mixin etc. with this plugin installed. I could be mistaken, but I assumed this plugin would cover those cases, but right now I have to use a custom ignore rule:

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-css-modules"
  ],
  "plugins": [
    "stylelint-scss"
  ],
  "rules": {
    "at-rule-no-unknown": [ true, {
      ignoreAtRules: ['extend', 'at-root', 'debug', 'warn', 'error', 'if', 'else', 'for', 'each', 'while', 'mixin', 'include', 'content', 'return', 'function']
    }]
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

5reactions
davidtheclarkcommented, Dec 4, 2016

Another possibility would be to write a new rule for stylelint-scss that wraps at-rule-no-unknown but automatically ignores Sass’s special at-rules. Something like this:

var sassAtRules = [
  'extend', 'at-root', 'debug', 
  'warn', 'error', 'if', 'else', 
  'for', 'each', 'while', 'mixin', 
  'include', 'content', 'return', 'function'
];

function atRuleNoUnknownSassy(on, options) {
  return function (root, result) {
    const defaultedOptions = Object.assign({}, options, {
      ignoreAtRules: sassAtRules.concat(options.ignoreAtRules || [])
    });

    stylelint.rules['at-rule-no-unknown'](on, defaultedOptions)(root, result);
  };
};

This solution means your rule is easy to maintain, without duplicating code and at-rule lists in stylelint.

This ability to manually invoke stylelint rules within plugin rules opens a lot of doors!

2reactions
eriklharpercommented, Nov 30, 2016

@neverfox I’m in the same boat, but what I realized is that because stylelint-scss is a stylelint plugin, it doesn’t automatically enable any rule for you because that’s how plugins work.

What we really need to make the linter “scss aware” is a scss lint config that we can tell stylelint to extend instead, the same way you’re extending stylelint-config-css-modules above.

I did a quick search online for “stylelint scss config” but it isn’t turning up anything, perhaps this is a perfect moment for me to attempt to write one myself!

Read more comments on GitHub >

github_iconTop Results From Across the Web

at-rule-no-unknown - Stylelint
Disallow unknown at-rules. ... This rule considers at-rules defined in the CSS Specifications, up to and including Editor's Drafts, to be known. Options​....
Read more >
Prevent `at-rule-no-unknown` from warning against Sass ...
A feature request to not warn against Sass directives like @import , @function , and @if when using Sass or SCSS syntax. Which...
Read more >
css - Unexpected unknown at-rule "@tailwind" scss/at-rule-no ...
And when I run stylelint "**/*.{scss,css,sass,svelte}" , I get the following error: yarn run v1.22.17 ...
Read more >
stylus/at-rule-no-unknown | stylelint-plugin-stylus
The at-rule-no-unknown (opens new window) rule incorrectly report errors in Stylus. This problem is that the core rules do not understand at- ...
Read more >
@tailwind unknown at rule | The AI Search Engine You Control
Whenever i try to use any tailwind directive except @apply it throws me an error: "Unexpected unknown at-rule "@screen" at-rule-no-unknown", nor screen, nor ......
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