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 non-standard variables in function-calc-no-unspaced-operator #6053

merged 1 commit into from May 1, 2022


Copy link

@ybiquitous ybiquitous commented May 1, 2022

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

Closes #6052

Is there anything in the PR that needs further explanation?

This pull request aims to fix false positives for non-standard variables (e.g. SCSS, Less, and so on.) in the function-calc-no-unspaced-operator rule.

I think isStandardSyntaxValue() is more appropriate than isStandardSyntaxMathFunction() suggested on #6052 (comment) because isStandardSyntaxMathFunction() fails the cases using non-standard variables. E.g.

code: 'a { top: calc(100%- #{$foo}); }',
fixed: 'a { top: calc(100% - #{$foo}); }',
message: messages.expectedBefore('-'),
line: 1,
column: 19,
endLine: 1,
endColumn: 20,

@@ -166,6 +167,8 @@ const rule = (primary, _secondaryOptions, context) => {

if (firstNode.type !== 'word') return false;

if (!isStandardSyntaxValue(firstNode.value)) return false;

const operatorIndex =;
Copy link
Member Author

@ybiquitous ybiquitous May 1, 2022

Choose a reason for hiding this comment

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

[note] If the isStandardSyntaxValue() check is not performed, firstNode.value like #{$foo-bar} matches /[+-]/ (OPERATOR_REGEX):

jeddy3 approved these changes May 1, 2022
Copy link

@jeddy3 jeddy3 left a comment

LGTM, thank you!

@ybiquitous ybiquitous merged commit b4139dd into main May 1, 2022
17 checks passed
@ybiquitous ybiquitous deleted the issue-6052 branch May 1, 2022
Copy link
Member Author

@ybiquitous ybiquitous commented May 1, 2022

Changelog entry added:

  • Fixed: function-calc-no-unspaced-operator false positives for non-standard variables (#6053).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

2 participants