Skip to content
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

Merged
merged 5 commits into from Nov 9, 2019

Conversation

fanich37
Copy link
Member

@fanich37 fanich37 commented Nov 1, 2019

Which issue, if any, is this issue related to?

It should close #4250 .

Is there anything in the PR that needs further explanation?

Nope, the logic of the PR is quite clear.

@hudochenkov
Copy link
Member

This is strange. Rule file is not formatted by Prettier. But Prettier is run on pre-commit hook. Could you run npm install just to be sure git hooks are installed. And run npm run prettier:fix to reformat files.

In one of previous PRs you also had lint errors, because file wasn't formatted with Prettier. Maybe you skipping git hook intentionally?

@fanich37
Copy link
Member Author

fanich37 commented Nov 2, 2019

This is strange. Rule file is not formatted by Prettier. But Prettier is run on pre-commit hook. Could you run npm install just to be sure git hooks are installed. And run npm run prettier:fix to reformat files.

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 😕

@hudochenkov
Copy link
Member

Could it depend on an OS platform?

It shouldn't be a problem because of OS, but who knows, everything is possible.

I have no idea what could be wrong :(

Copy link
Member

@hudochenkov hudochenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution!

lib/rules/length-zero-no-unit/__tests__/index.js Outdated Show resolved Hide resolved
@hudochenkov hudochenkov mentioned this pull request Nov 5, 2019
6 tasks
Copy link
Member

@alexander-akait alexander-akait left a 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') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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/

Copy link
Member

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; }

Copy link
Member Author

@fanich37 fanich37 Nov 8, 2019

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.

@vankop
Copy link
Member

vankop commented Nov 7, 2019

I think we can create build script to automatically update references required for rules before release

You are totally right, it simplifies work a lot =)

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Thanks!

@hudochenkov hudochenkov merged commit 1c415f5 into stylelint:master Nov 9, 2019
@hudochenkov
Copy link
Member

  • Fixed: length-zero-no-unit false positives for line-height, and for fr units (#4394).

@fanich37 fanich37 deleted the lznu-ignore-some-properties branch November 9, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

False positive length-zero-no-unit on fr unit
4 participants