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 x unit in some cases #4427

Merged
merged 3 commits into from Nov 24, 2019
Merged

Conversation

fanich37
Copy link
Member

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

It should close #3770 .

Is there anything in the PR that needs further explanation?

No, it's self explanatory.

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.

Looks good!

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.

Let's add more tests, anyway good job, thanks!

{
code: 'a { image-resolution: 1x; }',
description: 'ignore `x` unit in image-resolution',
},
Copy link
Member

Choose a reason for hiding this comment

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

Let's add test with @media (resolution: 2x) and (min-width: 200x) {}, second should be rejected

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to update logic so that such a case could be handled properly.
Not sure about implementation though.
Any suggestions are welcome.

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.

I think we can parse media queries and improve logic

@fanich37
Copy link
Member Author

I think we can parse media queries and improve logic

That's what I did in the last commit :)
Or what do you mean?

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.

Let's improve more, good job

if (
node.type === 'decl' &&
(node.prop.toLowerCase() === 'image-resolution' || /^image-set/i.test(node.value))
) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can parse decl here too, because you can use background: image-set("../../media/examples/star.png" 1x) left 20x / 15% 60% repeat-x

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice case. Updated the logic.

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.

/cc @hudochenkov

/cc @fanich37 Very good job! Thanks!

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.

LGTM!

@hudochenkov hudochenkov merged commit 1b43fca into stylelint:master Nov 24, 2019
@hudochenkov
Copy link
Member

  • Added: unit-no-unknown support for x unit (#4427).

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.

Add support for x to unit-no-unknown
3 participants