The Wayback Machine - https://web.archive.org/web/20211228090749/https://github.com/stylelint/stylelint/issues/5032
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positive for ::-moz-focus-inner in no-descending-specificity #5032

Open
cpmsmith opened this issue Nov 9, 2020 · 1 comment
Open

Fix false positive for ::-moz-focus-inner in no-descending-specificity #5032

cpmsmith opened this issue Nov 9, 2020 · 1 comment

Comments

@cpmsmith
Copy link

@cpmsmith cpmsmith commented Nov 9, 2020

Clearly describe the bug

::-moz-focus-inner is treated as a pseudo-class, not a pseudo-element, and so can cause false positives in no-descending-specificity.

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

no-descending-specificity

What code is needed to reproduce the bug?

a::-moz-focus-inner {}
a {}

What stylelint configuration is needed to reproduce the bug?

e.g.

{
  "rules": {
    "no-descending-specificity": true
  }
}

Which version of stylelint are you using?

v13.7.2

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

Originally encountered running it with SublimeLinter, but reproducible in the Stylelint demo page

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

No

What did you expect to happen?

No errors to be flagged.

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

The following error was flagged:

2:1 error Expected selector "a" to come before selector "a::-moz-focus-inner" (no-descending-specificity)

Fixing it

This could simply be fixed by adding -moz-focus-inner to the list of known pseudo-elements in keywordSets.js, but relying on that list is obviously not the greatest—-moz-focus-inner was actually the original example given for this bug way back in #1811, and the fix still missed it.

If we instead made the selector parsing assume any selector with a double colon is a pseudo-element, not a pseudo-class, that could be a more general fix, and would match the spec:

This :: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements.

Of course, the confusion between e.g. :after and ::after is well-known, and the former is in (limited, but spec-compliant) use, so we would still need a keyword list, but this would solve all syntactically valid cases going forward, and existing logic would probably handle any common invalid ones gracefully.

@jeddy3
Copy link
Member

@jeddy3 jeddy3 commented Nov 17, 2020

@cpmsmith Thanks for the report, creating a demo and for using the template.

I agree with your more comprehensive suggested fix.

I've labelled the issue as ready to implement. Please consider contributing if you have time.

There are steps on how to fix a bug in a rule in the Developer guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants