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 column position and ignore Sass function for font-weight-notation
#6005
Conversation
|
||
@font-face { font-weight: normal bold; } | ||
/** ↑ | ||
* Multiple notations are available in @font-face */ |
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.
[note] I think adding a description about @font-face
makes sense. Any thoughts?
See also https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight
@@ -180,7 +180,7 @@ testRule({ | |||
code: '@font-face { font-weight: 400 bold; }', | |||
message: messages.expected('numeric'), | |||
line: 1, | |||
column: 27, | |||
column: 31, |
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.
[note] The position is changed to bold
, not 400
.
return valueParser(value).nodes.filter((node, index, nodes) => { | ||
if (node.type !== 'word') return false; | ||
|
||
// Exclude `<font-size>/<line-height>` format like `16px/3`. |
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.
*/ | ||
function complain(message) { | ||
function complain(message, valueNode) { | ||
const index = declarationValueIndex(decl) + (valueNode ? valueNode.sourceIndex : 0); |
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.
[note] I'll add endIndex
on #5725.
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.
Fantastic, thank you!
This is a nice stepping stone to #3158 (and also jeddy3/stylelint-scales#73).
I've asked one question.
if (decl.prop.toLowerCase() === 'font-weight') { | ||
checkWeight(decl.value, decl); | ||
} | ||
root.walkDecls(/^font(-weight)?$/i, (decl) => { |
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.
👍
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.
LGTM, thank you!
This change uses
postcss-value-parser
instead ofpostcss.list.space()
for more accurate parsing.