-
-
Notifications
You must be signed in to change notification settings - Fork 938
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
Add annotation-no-unknown
#6155
Conversation
Possible questions with my implementation: - how should I be checking for nonstandard syntax? ex just at the declaration level? - I've interpreted the spec to allow any capitalization of important, but I could be wrong here! I did test on Chrome and it seems to allow case-insensitive responses. - I've opted to include the `!` in the secondary options; is that too clunky? - should I add any testcases for nonstandard syntax?
Actually - going to mark this as draft; I think I've made an implementation mistake that the code coverage sneakily catches. I'll revisit and mark as ready when relevant! |
@mattxwang Thanks for creating the pull request! 👍🏼 Here are my answers to your questions in the description:
If you would have clear test cases for non-standard syntaxes, it might be nice to check them to reduce potential false positives. But if you wouldn't have them or the rule implementation would be much more complex by adding such a check, it would be acceptable not to check them.
It seems good that
I think it's unnecessary for consistency to include stylelint/lib/rules/property-no-unknown/README.md Lines 130 to 138 in 592b149
|
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.
@mattxwang Thanks for making a start on this. Looking good so far.
I've requested some changes to make the docs, tests and rule consistent with existing rules.
Let's not add additional tests for non-standard syntax. Only if users report an issue, should we add that code.
I agree with @ybiquitous that it's unnecessary to include !
.
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
Thank you @ybiquitous and @jeddy3 for the in-depth feedback, I appreciate both of you and your patience as I still getting familiar with the codebase. I definitely need to do a better job of following the conventions doc! I think I've resolved all of the outstanding changes, and I've removed the need to use One note:
With my understanding of the PostCSS parser, the top-level declaration doesn't differentiate between different capitalizations of $ node -e 'require("postcss").parse("a { color: red !IMPORTANT }").walkDecls(decl => console.log(decl))'
<ref *1> Declaration {
raws: { before: ' ', between: ': ', important: ' !IMPORTANT' },
type: 'decl',
parent: Rule {
raws: { before: '', between: ' ', semicolon: false, after: ' ' },
type: 'rule',
nodes: [ [Circular *1] ],
parent: Root {
raws: [Object],
type: 'root',
nodes: [Array],
source: [Object],
lastEach: 1,
indexes: [Object],
[Symbol(isClean)]: false,
[Symbol(my)]: true
},
source: { start: [Object], input: [Input], end: [Object] },
selector: 'a',
lastEach: 1,
indexes: { '1': 0 },
[Symbol(isClean)]: false,
[Symbol(my)]: true
},
source: {
start: { offset: 4, line: 1, column: 5 },
input: Input {
css: 'a { color: red !IMPORTANT }',
hasBOM: false,
id: '<input css HyYU1z>',
[Symbol(fromOffsetCache)]: [Array]
},
end: { offset: 24, line: 1, column: 25 }
},
prop: 'color',
important: true,
value: 'red',
[Symbol(isClean)]: false,
[Symbol(my)]: true
}
|
Sorry, let's follow the current PostCSS parser behavior! |
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.
@mattxwang Thanks for the quick fix! I've left a suggestion comment, but this looks mostly good to me. 👍🏼
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
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.
Thank you. LGTM 👍🏼
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 for making the changes. LGTM, thank you!
|
Closes #4508.
A late turnaround on this one! I think there's probably a few missing things before this is mergeable.
Possible questions with my implementation:
!important
be case-insensitive? on one hand, syntax highlighters and the literal reading of the spec only allow for lowercase, but it seems like Chrome respects any capitalization.!
in the secondary options; is that too clunky?