Skip to content

Commit

Permalink
Merge pull request #535 from kristerkari/bugfix/dimension-no-non-nume…
Browse files Browse the repository at this point in the history
…ric-values-unitless-interpolation

dimension-no-non-numeric-values: fix error thrown with unitless interpolation
  • Loading branch information
kristerkari authored Jul 18, 2021
2 parents 0ed236a + c3fffd9 commit a4ab191
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/rules/dimension-no-non-numeric-values/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ testRule(rule, {
code: `$pad: "2";
$string: "#{$pad}px";`,
description: "does not report lint when string is quoted"
},
{
code: `
@include media-breakpoint-up($grid-gutter-breakpoint) {
--#{$variable-prefix}gutter-x: #{$gutter * 2};
}`,
description: "ignores interpolation without a unit"
}
]),
reject: loopOverUnits({
Expand Down
5 changes: 5 additions & 0 deletions src/rules/dimension-no-non-numeric-values/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export default function rule(primary) {

const regex = new RegExp(`#{[$a-z_0-9 +-]*}(${units.join("|")});?`);
const matchUnit = decl.value.match(regex);

if (!matchUnit) {
return;
}

const unit = matchUnit[1];
const offset = decl.value.indexOf(unit);

Expand Down

0 comments on commit a4ab191

Please sign in to comment.