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 hex colours in unit-whitelist #4493

Closed
Bob-chemist opened this issue Dec 26, 2019 · 3 comments
Closed

Fix false positives for hex colours in unit-whitelist #4493

Bob-chemist opened this issue Dec 26, 2019 · 3 comments
Labels
status: ready to implement is ready to be worked on by someone syntax: sass relates to Sass and Sass-like syntax type: bug a problem with a feature or rule

Comments

@Bob-chemist
Copy link

Clearly describe the bug

unit-whitelist doesn't properly parse hex colors, starting with number in border property.
If hex color contains any letter except for "E" in border property, it causes error.
e.g. border: 2px solid #2196F3
If we move color to the first place of border property (border: #2196F3 2px solid) or extract it to border-color property or change it to rgb(33, 150, 243), error dissappears.
Single "E" in hex color dont't cause error because it is still a number - 2196E3 = 2196*10^3. "E" on last place or second "E" throws error too - it is not a proper number now.

Which rule, if any, is the bug related to?

unit-whitelist

What CSS is needed to reproduce the bug?

border: 2px solid #2196F3

What stylelint configuration is needed to reproduce the bug?

{
  "rules": {   
    "unit-whitelist": [
      "px"
    ]
  }
}

Which version of stylelint are you using?

12.0.1

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

VS Code and stylelint extension

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

"I use SASS syntax without braces"

What did you expect to happen?

"No errors to be flagged."

What actually happened (e.g. what warnings or errors did you get)?

"The following warnings were flagged:"

filter.module.sass
  Unexpected unit "F3" (unit-whitelist) stylelint(unit-whitelist) [54, 25]
@hudochenkov
Copy link
Member

Thanks for the report and for using the template.

As I see in demo it happens only to Sass syntax: demo. Doesn't happen in standard CSS (demo) or SugarSS.

@hudochenkov hudochenkov added syntax: sass relates to Sass and Sass-like syntax type: bug a problem with a feature or rule status: ready to implement is ready to be worked on by someone labels Dec 26, 2019
@fanich37
Copy link
Member

It seems that the issues is caused by postcss-sass parser. When walkDecls is invoked it returns declaration with a value 2px solid 2196F3.

@jeddy3 jeddy3 changed the title Some hex colors cause error unit-whitelist Fix false positives for hex colours in unit-whitelist Jan 11, 2020
@jeddy3
Copy link
Member

jeddy3 commented Jan 18, 2022

Closing as the syntax option was removed for the 14.0.0 release. (See the migration guide.)

Please consider opening an issue upstream and fixing the issue there as the syntax is no longer bundled by Stylelint.

@jeddy3 jeddy3 closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to implement is ready to be worked on by someone syntax: sass relates to Sass and Sass-like syntax type: bug a problem with a feature or rule
Development

No branches or pull requests

4 participants