Add `ignore: ["inside-block"]` to selector-disallowed-list
See original GitHub issueWhat is the problem you’re trying to solve?
I also want to disallow top-level selectors which are starting with &
because that’s invalid CSS code
&.foo { }
(common to SASS
precompiler language but is not restricted to it)
What solution would you like to see?
either top-level flexible regex rule or an explicit rule for anything starting specifically with &
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
selector-disallowed-list - Stylelint
Specify a list of disallowed selectors. ... Split selector lists into individual selectors. ... Ignore selectors that are inside a block. Given: [".foo"]....
Read more >@alexseitsinger/stylelint-config - npm
Specify a blacklist of disallowed attribute operators. https://stylelint.io/user-guide/rules/selector-attribute-operator-blacklist/. Examples. [] ...
Read more >@fylgja/stylelint-config NPM | npm.io
We have not set any allowed/disallowed-list values. it's better to set those ... except: first-nested,; ignore: after-comment, inside-block. Selector.
Read more >stylelint-config-sass-guidelines - npm package - Snyk
Simply add a "rules" key to your config and add your overrides there. ... at-rule-disallowed-list : Specify a list of disallowed at-rules.
Read more >List of rules - Stylelint 中文文档
Keyframe block. keyframe-block-no-duplicate-selectors : Disallow duplicate selectors within keyframe blocks. Declaration block.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m a single person, not “they”… I don’t have the time capacity as I already am the author of dozens of open-source projects and have a fulltime job and also need to find the time watching funny cats YouTubes while eating watermelons and thus more busy than Elon MusK
This is an interesting one.
According to the latest draft spec
&.foo {}
is a valid CSS:I think the CSSTree validator is currently flagging it as doesn’t parse nesting outright yet, e.g.:
Stylelint is a good fit for CSS that is valid, but probably wasn’t what the author intended to write. It’d be inline with the other
*-unmatchable
rules we’re thinking of adding (e.g. https://github.com/stylelint/stylelint/issues/5907)). However, we probably don’t want to add any new nesting rules just yet as the nesting specification is influx (with the syntax still to be settled on).I can see us adding a whole suite of rules for nesting when the specification does stabilise, though. For example, there is plenty of other valid nesting CSS that a person would probably want to limit:
Or enforce a particular notation, e.g. these two are equivalent:
I suggest that anyone who is interested in these create plugins that we can port over to built-in rules once the specification stabilises.
In the meantime, we can add an
ignore: ["inside-block"]
option to theselector-disallowed-list
rule (example of prior art). A user can then craft a regex to disallow the nesting selector (&
) anywhere in a selector unless the selector is inside of a block.It’s not a perfect solution as the option will apply to all the items in the array, but it’ll probably address @yairEO immediate use case.