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 some properties with 0 value (#4250) #4394
Ignore some properties with 0 value (#4250) #4394
Conversation
This is strange. Rule file is not formatted by Prettier. But Prettier is run on pre-commit hook. Could you run In one of previous PRs you also had lint errors, because file wasn't formatted with Prettier. Maybe you skipping git hook intentionally? |
Hm... Hooks are installed but doesn't seem to work. Could it depend on an OS platform? I use Win 10 now and can also check it on Ubuntu. I also ran lint & tests manually before the commit and everything passed 😕 |
It shouldn't be a problem because of OS, but who knows, everything is possible. I have no idea what could be wrong :( |
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.
Nice solution!
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.
All good, need more properties
/cc @stylelint/core I think we can create build script to automatically update references required for rules before release
@@ -29,6 +29,10 @@ const rule = function(actual, secondary, context) { | |||
} | |||
|
|||
root.walkDecls((decl) => { | |||
if (decl.prop.toLowerCase() === 'line-height') { |
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.
Not only line-height
can contains <length> | <percentage>
, for example https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width, https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dashoffset and other, you can find them here https://github.com/mdn/data/blob/master/css/properties.json, also let's put them in https://github.com/stylelint/stylelint/tree/master/lib/reference
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.
To be honest I completely lost the idea why I'd ignored line-height
😕 .
This is the same:
line-height: 0;
line-height: 0px;
line-height: 0em;
So in case of zero value the dimension unit is useless and the warning should be flagged (or it should be auto-fixed).
The only unit to ignore here is fr
since 0fr
and 0
mean completely different things.
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.
line-height: 0;
!== line-height: 0px;
Сlarifications and examples - cssnano/cssnano#768
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.
Make sense.
But what the point to ignore stroke-width
for example. It doesn't matter whether it has unit or not. Example: https://jsfiddle.net/vc2otk06/
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.
Oh, yes, my mistake, you are right, don't found other properties with same ability as line-height
has, let's add tests for this cases:
a { font: normal normal 400 16px/0px cursive; }
a { font: normal normal 400 16px/0 cursive; }
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.
The funny thing is these cases don't break tests in master branch but they have to.
I added some logic to process font
declaration and updated test cases.
You are totally right, it simplifies work a lot =) |
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.
Great job! Thanks!
|
It should close #4250 .
Nope, the logic of the PR is quite clear.