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 positives for universal selector and disallowInList in no-duplicate-selectors #4809
Conversation
@srawlins Thanks for looking into this (and discovering the big bug behind this).
Let's try caching the parsed lists. You can use At the moment jeddy3@jeddy3 stylelint % npm run benchmark-rule -- no-duplicate-selectors "[true, {\"disallowInList\": true}]"
> stylelint@13.5.0 benchmark-rule /Users/jeddy3/Projects/stylelint
> node scripts/benchmark-rule.js "no-duplicate-selectors" "[true, {\"disallowInList\": true}]"
Warnings: 78
Mean: 91.46247921052631 ms
Deviation: 28.897587464632007 ms And this branch is: jeddy3@jeddy3 stylelint % npm run benchmark-rule -- no-duplicate-selectors "[true, {\"disallowInList\": true}]"
> stylelint@13.5.0 benchmark-rule /Users/jeddy3/Projects/stylelint
> node scripts/benchmark-rule.js "no-duplicate-selectors" "[true, {\"disallowInList\": true}]"
Warnings: 37
Mean: 10107.0616478 ms
Deviation: 508.2475623037317 ms We don't need to make this branch comparable to |
Thanks so much for the benchmarking tips! I read the code further and discovered what |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent. The benchmarks are now comparable.
While reviewing this pull request, @m-allanson and I had to refamiliarise ourselves with nodeContextLookup
as it'd be a long while since either of us had used it. I'm glad you were able to make use of it to fix the bug without impacting the performance of the rule.
# By Mike Allanson (6) and others # Via GitHub * master: Bump @types/lodash from 4.14.152 to 4.14.154 (#4817) Update CHANGELOG.md Fix with workaround a TypeError thrown for "html" (#4797) Update CHANGELOG.md Fix false positives for variables in font-family-no-missing-generic-family-keyword (#4806) Update CHANGELOG.md Add ignoreSelectors option to block-opening-brace-space-before (#4640) Update CHANGELOG.md Fix error message percentage/number precision for alpha-value-notation (#4802) Create new 'createPartialStylelintResult' module (#4815) Move function normalizeAllRuleSettings() out to a separate module (#4810)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM 👍
(I fixed a merge conflict from a recent dep update)
|
Fixes #4683
Closes #4795
This code had a pretty big bug in it; it used
.includes
on a selector string, not a list, so it was just a substring match; the new code certainly takes more time, with more parsing, but is correct. Open to suggestions about how to do improve performance (perhaps cache parsed lists?).