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
Only report immutable class selectors, add ignoreSelectors option #43
Conversation
const config = { | ||
plugins: [require.resolve('../plugins/no-override')], | ||
rules: { | ||
'primer/no-override': [true, {bundles: ['base']}] |
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.
This test tells the primer/no-override
rule only to match selectors in the "base" bundle, which is where we normalize element styles, including hr
.
@@ -4,6 +4,7 @@ const {requirePrimerFile} = require('../src/primer') | |||
const ruleName = 'primer/no-override' | |||
const CLASS_PATTERN = /(\.[-\w]+)/ | |||
const CLASS_PATTERN_ALL = new RegExp(CLASS_PATTERN, 'g') | |||
const CLASS_PATTERN_ONLY = /^\.[-\w]+(:{1,2}[-\w]+)?$/ |
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.
Aaaand here's the ugly part: a regular expression that matches any class selector with an optional pseudo-class.
After testing this in github/github, I noticed that there were a bunch of false positives for non-class selectors like
ul
,li
, etc. This is an update to the work in #37 that:"in <selector>"
bit at the end).ignoreSelectors
rule option that allows you to ignore selectors containing one or more strings, matching one or more regular expressions, or satisfying a function.