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 interpolation in function-no-unknown #5913

Closed
m4thieulavoie opened this issue Feb 14, 2022 · 5 comments · Fixed by #5914
Closed

Fix false positives for interpolation in function-no-unknown #5913

m4thieulavoie opened this issue Feb 14, 2022 · 5 comments · Fixed by #5914
Labels
status: wip is being worked on by someone syntax: scss relates to SCSS and SCSS-like syntax type: bug a problem with a feature or rule

Comments

@m4thieulavoie
Copy link
Contributor

What steps are needed to reproduce the bug?

When having something like the following, stylelint's function-no-unknown throws a false error (assuming darken is in ignoreFunctions

:root {
  --primary-color: #{darken(#fff, 0.5)};
}

What Stylelint configuration is needed to reproduce the bug?

{
    "function-no-unknown": [true, {ignoreFunctions: ["lighten", "darken"]}]
}

How did you run Stylelint?

npx stylelint

Which version of Stylelint are you using?

14.5.0

What did you expect to happen?

No violation thrown by stylelint

What actually happened?

Unexpected unknown function             function-no-unknown          
          "#{darken" 
//          ^^ Note the `#{` prefix

Does the bug relate to non-standard syntax?

No response

Proposal to fix the bug

Add logic to remove any #{} syntax

@ybiquitous
Copy link
Member

ybiquitous commented Feb 14, 2022

@m4thieulavoie
Copy link
Contributor Author

@m4thieulavoie Thanks for the report and for using the template.

This issue seems to be the same problem as:

Indeed! Hopefully stylelint is the right place to fix that as I took a stab at it and opened a PR for it

@ybiquitous
Copy link
Member

ybiquitous commented Feb 14, 2022

Stylelint should not handle non-standard CSS syntaxes. Instead, the stylelint-scss plugin should do it.

For example, sanitizing a value like #{...} would be more difficult to support more syntaxes.

@jeddy3 jeddy3 changed the title function-no-unknown not acting as expected in custom properties Fix false positives for interpolation in function-no-unknown Feb 14, 2022
@jeddy3 jeddy3 added status: wip is being worked on by someone syntax: scss relates to SCSS and SCSS-like syntax type: bug a problem with a feature or rule labels Feb 14, 2022
@jeddy3
Copy link
Member

jeddy3 commented Feb 14, 2022

@m4thieulavoie Thanks for opening the issue.

Hopefully stylelint is the right place to fix that

Yes, it is.

For example, sanitizing a value like #{...} would be more difficult to support more syntaxes.

That's correct. As @ybiquitous is implying, we ignore non-standard syntax in the built-in rules (using the isStandardSyntax* utilities) as there is a lot of non-standard syntax out there. This then allows plugins, like stylelint-scss, to write companion rules that deal with non-standard syntax specific to that language.

@m4thieulavoie
Copy link
Contributor Author

@m4thieulavoie Thanks for opening the issue.

Hopefully stylelint is the right place to fix that

Yes, it is.

For example, sanitizing a value like #{...} would be more difficult to support more syntaxes.

That's correct. As @ybiquitous is implying, we ignore non-standard syntax in the built-in rules (using the isStandardSyntax* utilities) as there is a lot of non-standard syntax out there. This then allows plugins, like stylelint-scss, to write companion rules that deal with non-standard syntax specific to that language.

Thanks for the feedback! I'll keep my eyes opened for a fix in stylelint-scss

beatrizsmerino added a commit to beatrizsmerino/vue-editor that referenced this issue Feb 16, 2022
Error:
- Unexpected unknown function "mix"  function-no-unknown
stylelint-scss/stylelint-scss#589 (comment)
stylelint-scss/stylelint-scss#589 (comment)

Solution:
- Disable the rule 'function-no-unknown' or add exceptions using 'ignoreFunction'
stylelint/stylelint#5913
beatrizsmerino added a commit to beatrizsmerino/vue-editor that referenced this issue Feb 17, 2022
Error:
- Unexpected unknown function "mix" function-no-unknown
stylelint-scss/stylelint-scss#589 (comment)
stylelint-scss/stylelint-scss#589 (comment)

Solution:
- Disable the rule 'function-no-unknown' or add exceptions using 'ignoreFunction'
stylelint/stylelint#5913
anyesu added a commit to anyesu/taro-demo that referenced this issue Apr 8, 2024
- https://taroify.github.io/taroify.com/quickstart
- stylelint/stylelint#5913
- `No matching export in ...` `import { createVanIconComponent } from "./van"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wip is being worked on by someone syntax: scss relates to SCSS and SCSS-like syntax type: bug a problem with a feature or rule
Development

Successfully merging a pull request may close this issue.

3 participants