1

I have a problem with Style Lint. I have set the selector-max-specificity at 0,2,0 with some ignored rules : ignoreSelectors: [":focus", ":hover", etc..]

Now, I want to ignore the :not(.myClass) selector but this doesn't work :(

For example i have my class with this name : .track a:not(.track-visual)

I have tried with regex selector "/:not\\(.*\\)/" or even with "/.*:not\\(.*\\)/"

But no chance :'(

If you have a solution, i'm interested :) Thank you

2 Answers 2

0

I'm guessing that here we would be wishing to capture those with :not, which in that event, we would be starting with a simple expression such as:

.+?:not\(.+?\)

Demo

RegEx Circuit

jex.im visualizes regular expressions:

enter image description here

1
  • Thank you for your response, i have tested your solution, but this is not working :'( I don't understand why, because for example this is work well if i want to ignore selector attributes : /\[.*\]/
    – Rudy
    Jun 5, 2019 at 8:12
0

Don't think this can be done. The latest code for the rule includes the following:

const ownSpecificity =
    ownValue === ':not' || ownValue === ':matches'
        ? // :not and :matches don't add specificity themselves, but their children do
          zeroSpecificity()
        : simpleSpecificity(ownValue);

As per the comment, this is not including the :not itself as something that would add specificity but is including its children, which is what the regex would be checking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.