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 FP css:S5362 ('function-calc-no-invalid'): Consider SCSS-specific syntaxes #3136

Closed
yassin-kammoun-sonarsource opened this issue May 12, 2022 · 7 comments
Labels
topic: quality type: false positive Issue is reported when it should NOT be

Comments

@yassin-kammoun-sonarsource
Copy link
Contributor

Reported in https://community.sonarsource.com/t/scss-css-s5362-invalid-malformed-calc-function/62691

@yassin-kammoun-sonarsource yassin-kammoun-sonarsource added type: false positive Issue is reported when it should NOT be topic: quality labels May 12, 2022
@crush83
Copy link

crush83 commented Aug 16, 2022

Has there been progress on this ticket? I'm still getting false positives when using valid SCSS interpolation in conjunction with the CSS calc function...

@sohaleKing
Copy link

any progress? I still recieve this as critical!

@davidgataric
Copy link

Hello there is there any progress we are getting critical issues because of this?

@kuschti
Copy link

kuschti commented Oct 3, 2022

This is an old issue. We have hundreds of this. Please fix this

@yassin-kammoun-sonarsource
Copy link
Contributor Author

An initial investigation of the false positive shows that the parsing of calc scss-like argument produces a malformed abstract syntax tree.

Given the definition

p {
  width: calc(100% - #{$foo} - #{bar(20)});
}

we observe that the term #{bar(20)} is wrongly parsed as #{bar and }. This is due to the fact that the rule is currently able to parse property values with CSS syntax only.

As the original implementation from Stylelint did, we need to implement a proper parser not only for the calc syntax but also to consider SCSS-specific syntax.

For now, we advise disabling the rule when it is executed outside the scope of a plain CSS stylesheet until a proper fix is implemented.

@victor-diez-sonarsource
Copy link
Contributor

link to stylelint removal: stylelint/stylelint#5296

@ilia-kebets-sonarsource
Copy link
Contributor

We chose to deprecate this rule because:

  • It was originally dropped by Stylelint
  • It is too noisy as it currently does not support syntaxes other than CSS
  • It needs a proper parser which requires too much work and maintainability for what it's worth

You can track its deprecation in here: #3470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: quality type: false positive Issue is reported when it should NOT be
Projects
None yet
Development

No branches or pull requests

8 participants