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

Fix false positives for functions inside of math functions in length-zero-no-unit #5204

Closed
tomyo opened this issue Mar 19, 2021 · 1 comment
Labels
good first issue is good for newcomers status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule

Comments

@tomyo
Copy link
Contributor

tomyo commented Mar 19, 2021

Clearly describe the bug
The rule length-zero-no-unit is applying fixes inside level 4 math functions.

This test exercises exactly what it shouldn't happen:

https://github.com/tomyo/stylelint/blob/eb419ef754ac442f9f3b9f7164fccb938b99adb3/lib/rules/length-zero-no-unit/__tests__/index.js#L332

Why?
It converts this:

padding: calc(var(--foo, 0px) + 10px);

Into this:

padding: calc(var(--foo, 0) + 10px);

If --foo is not defined, the fallback value 0 is used, resulting in calc(0 + 10px); which is invalid.

What stylelint configuration is needed to reproduce the bug?

{
  "rules": {
    "length-zero-no-unit": true
  }
}

Which version of stylelint are you using?

13.12.0

What did you expect to happen?

No unit strips should happen inside level 4 math functions, just for safety.

In the link to the test I gave, something like this is what I would expect instead:

{
			description: 'ignore calc, and inner functions',
			code: 'padding: calc(var(--foo, 0in) + 10px) 0px;',
			fixed: 'padding: calc(var(--foo, 0in) + 10px) 0;',
}
@jeddy3
Copy link
Member

jeddy3 commented Mar 26, 2021

@tomyo Thanks for the report and clear write-up of the problem.

No unit strips should happen inside level 4 math functions, just for safety.

Yes, that sounds appropriate.

Now that your related pull request (#5203) is merged, I'll label this is ready to implement.

@jeddy3 jeddy3 changed the title length-zero-no-unit fix incorrectly applied for functions inside level 4 math functions Fix false positives for functions inside of math functions in length-zero-no-unit Mar 26, 2021
@jeddy3 jeddy3 added good first issue is good for newcomers status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule labels Mar 26, 2021
@jeddy3 jeddy3 closed this as completed Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue is good for newcomers status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule
Development

No branches or pull requests

2 participants