Skip to content

Commit

Permalink
Fix #252
Browse files Browse the repository at this point in the history
  • Loading branch information
YozhikM committed Jun 14, 2018
1 parent b3db105 commit 9bfed13
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/rules/operator-no-newline-before/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ testRule(rule, {
}
`,
description: "Newline before the preceding op: 10px +\\n 1"
},
{
code: `
:root {
--foo: '{{}}';
}
`,
description: "Custom property"
}
],

Expand Down
4 changes: 4 additions & 0 deletions src/rules/operator-no-unspaced/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ testRule(rule, {
{
code: "a { width: #{$var} +1; }",
description: "List. width: #{$var} +1."
},
{
code: ":root { --foo: '{{}}'; }",
description: "Custom property"
}
],

Expand Down
10 changes: 6 additions & 4 deletions src/utils/sassValueParser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,21 @@ export default function findOperators({
for (let i = 0; i < string.length; i++) {
const character = string[i];
const substringStartingWithIndex = string.substring(i);
const lastMode = modesEntered[lastModeIndex];

// If entering/exiting a string
if (character === '"' || character === "'") {
if (modesEntered[lastModeIndex].isCalculationEnabled === true) {
if (lastMode && lastMode.isCalculationEnabled === true) {
modesEntered.push({
mode: "string",
isCalculationEnabled: false,
character
});
lastModeIndex++;
} else if (
modesEntered[lastModeIndex].mode === "string" &&
modesEntered[lastModeIndex].character === character &&
lastMode &&
lastMode.mode === "string" &&
lastMode.character === character &&
string[i - 1] !== "\\"
) {
modesEntered.pop();
Expand All @@ -77,7 +79,7 @@ export default function findOperators({
}

// Don't lint if inside a string
if (modesEntered[lastModeIndex].isCalculationEnabled === false) {
if (lastMode && lastMode.isCalculationEnabled === false) {
continue;
}

Expand Down

0 comments on commit 9bfed13

Please sign in to comment.