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
Ignore calc() in length-zero-no-unit #4175
Changes from 3 commits
297d8db
5dd12b0
76501f2
8ed5186
d37e933
fedba5a
f294149
dbcefbf
0e69ed6
37e4cab
338bb1f
eb32f00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,18 @@ testRule(rule, { | |
code: "a { top: 0; }", | ||
description: "unitless zero" | ||
}, | ||
{ | ||
description: "ignore calc", | ||
code: "a { padding: calc(0px +\n 0px); }" | ||
}, | ||
{ | ||
description: "ignore calc. insensitive", | ||
code: "a { padding: cAlc(0px + 0px); }" | ||
}, | ||
{ | ||
description: "ignore calc. empty calc", | ||
code: "a { padding: calc(); }" | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add test like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome suggestion. I have improve it to |
||
{ | ||
code: "a { padding: 0 /* 0px */; }", | ||
description: "united zero in comment" | ||
|
@@ -246,14 +258,6 @@ testRule(rule, { | |
line: 1, | ||
column: 27 | ||
}, | ||
{ | ||
code: "a { padding: calc(1in + 0in * 2)); }", | ||
fixed: "a { padding: calc(1in + 0 * 2)); }", | ||
|
||
message: messages.rejected, | ||
line: 1, | ||
column: 26 | ||
}, | ||
{ | ||
code: "@media (min-width: 0px) {}", | ||
fixed: "@media (min-width: 0) {}", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
|
||
module.exports = function isMathFunction(valueString) { | ||
return /calc\((.|\s)*\)/i.test(valueString); | ||
}; |
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.
Minor doc nitpick. Let's revert the change to this sentence and add the following below the example:
This is to be consistent with other rule READMEs e.g.
https://github.com/stylelint/stylelint/tree/master/lib/rules/font-family-name-quotes#font-family-name-quotes
Otherwise, this PR 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.
updated