Skip to content

Commit

Permalink
dimension-no-non-numeric-values: fix error thrown with unitless inter…
Browse files Browse the repository at this point in the history
…polation
  • Loading branch information
kristerkari committed Jul 18, 2021
1 parent 0ed236a commit c3fffd9
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 c3fffd9

Please sign in to comment.