Skip to content

Commit

Permalink
Allow calc function interpolation in SassScript (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelalozano16 committed Jan 19, 2024
1 parent 21f5039 commit 9bdfb71
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 6.0.1

- `function-calculation-no-interpolation` allows calc function interpolation in SassScript when declaring CSS custom properties.

**Full Changelog**: https://github.com/stylelint-scss/stylelint-scss/compare/v6.0.0...v6.0.1

# 6.0.0

- Added: `stylelint@16` support.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stylelint-scss",
"description": "A collection of SCSS-specific rules for Stylelint",
"version": "6.0.0",
"version": "6.0.1",
"author": "Krister Kari",
"repository": "stylelint-scss/stylelint-scss",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ testRule({
.a { .b: calc(abc(#{$c})); }
`,
description: "Allowed function with interpolation nested in `calc`"
},
{
code: `
$c: 1;
--test-d: calc(#{$c} + 1);
`,
description:
"Custom property declaration with interpolation inside `calc`"
}
],
reject: [
Expand All @@ -41,7 +49,6 @@ testRule({
description: "`calc` function one argument interpolated"
},
{
only: true,
code: `
$c: 1;
.a { .b: calc(#{$c + 1}); }
Expand Down
3 changes: 3 additions & 0 deletions src/rules/function-calculation-no-interpolation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function rule(actual) {

if (!calculationFunctions.includes(node.value)) return;

// Interpolation is valid in SassScript.
if (decl.type === "decl" && decl.prop.startsWith("--")) return;

const interpolation = node.nodes.find(
({ type, value }) => type === "word" && /^#{.*|\s*}/.test(value)
);
Expand Down

0 comments on commit 9bdfb71

Please sign in to comment.