-
-
Notifications
You must be signed in to change notification settings - Fork 942
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
Added: selector-max-combinators
rule.
#2658
Conversation
docs/user-guide/rules.md
Outdated
@@ -163,6 +163,7 @@ Here are all the rules within stylelint, grouped by the [*thing*](http://apps.wo | |||
- [`selector-descendant-combinator-no-non-space`](../../lib/rules/selector-descendant-combinator-no-non-space/README.md): Disallow non-space characters for descendant combinators of selectors. | |||
- [`selector-id-pattern`](../../lib/rules/selector-id-pattern/README.md): Specify a pattern for id selectors. | |||
- [`selector-max-class`](../../lib/rules/selector-max-class/README.md): Limit the number of classes in a selector. | |||
- [`selector-max-combinators`](../../lib/rules/selector-max-combinators/README.md): Limit the number of combinators selectors in a selector. |
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.
"Limit the number of combinators in a selector."
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.
@jeddy3 done
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.
@evilebottnawi Thanks for this.
I've made some doc and message requests.
Remember to update the example config and rules list docs in this PR.
I'm out of time and yet to look at the tests I'm afraid.
@@ -0,0 +1,61 @@ | |||
# selector-max-combinators | |||
|
|||
Limit the number of combinators selectors in a selector. |
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.
"Limit the number of combinators in a selector."
``` | ||
|
||
```css | ||
a, b {} |
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.
Use a b ~ c
here for parity with positive patterns.
``` | ||
|
||
```css | ||
a.foo {} |
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.
Use the following instead here:
a b {
& ~ c {}
}
``` | ||
|
||
```css | ||
/* each selector in a selector list is evaluated separately */ |
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.
Use the following instead:
a b,
c > d {}
const ruleName = "selector-max-combinators" | ||
|
||
const messages = ruleMessages(ruleName, { | ||
expected: (selector, max) => `Expected "${selector}" to have no more than ${max} combinators ${max === 1 ? "selector" : "selectors"}`, |
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.
expected: (selector, max) => `Expected "${selector}" to have no more than ${max} ${max === 1 ? "combinator" : "combinators"}`,
8a9fced
to
7ed5ad9
Compare
@jeddy3 done, about tests: all tested was migrate from basic rules and add more tests, in theory all should be fine. Btw, if someone found error we just fix it and release patch version. |
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.
Looks good.
Few small changes required: in tests descriptions lots of “max id selectors”, which are from other rule :)
description: "pseudo selectors", | ||
}, { | ||
code: "foo bar, \nbaz quux {}", | ||
description: "multiple selectors: exactly max id selectors", |
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.
“multiple selectors: fewer then max combinators selectors”
@hudochenkov Changes made. |
7d85fd5
to
52c184e
Compare
|
#2528
No, it's self explanatory.