Skip to content

Commit

Permalink
Fix no-duplicate-mixins end positions (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Dec 13, 2023
1 parent ddf8c54 commit 29e1da3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
20 changes: 15 additions & 5 deletions src/rules/no-duplicate-mixins/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ testRule({
font-size: 18px;
}
`,
column: 7,
line: 5,
column: 14,
endLine: 5,
endColumn: 31,
message: messages.rejected("font-size-default"),
description: "Two mixins with the same names."
},
Expand All @@ -56,8 +58,10 @@ testRule({
font-size: 18px;
}
`,
column: 7,
line: 8,
column: 14,
endLine: 8,
endColumn: 31,
message: messages.rejected("font-size-default"),
description: "Three mixins including two with the same names."
},
Expand All @@ -70,8 +74,10 @@ testRule({
font-size: $var;
}
`,
column: 7,
line: 5,
column: 14,
endLine: 5,
endColumn: 23,
message: messages.rejected("font-size"),
description:
"Two mixins with the same names including one accepting arguments."
Expand All @@ -85,8 +91,10 @@ testRule({
font-size: $var;
}
`,
column: 7,
line: 5,
column: 14,
endLine: 5,
endColumn: 23,
message: messages.rejected("font-size"),
description: "Two mixins with the same names accepting arguments."
},
Expand All @@ -103,8 +111,10 @@ testRule({
@include font-size;
}
`,
column: 9,
line: 7,
column: 16,
endLine: 7,
endColumn: 25,
message: messages.rejected("font-size"),
description: "Two mixins with the same names accepting arguments."
}
Expand Down
15 changes: 5 additions & 10 deletions src/rules/no-duplicate-mixins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,16 @@ function rule(value) {

const mixins = {};

root.walkAtRules(decl => {
const isMixin = decl.name === "mixin";

if (!isMixin) {
return;
}

const mixinName = atRuleBaseName(decl);
root.walkAtRules("mixin", atRule => {
const mixinName = atRuleBaseName(atRule);

if (mixins[mixinName]) {
utils.report({
message: messages.rejected(mixinName),
node: decl,
node: atRule,
result,
ruleName
ruleName,
word: mixinName
});
}

Expand Down

0 comments on commit 29e1da3

Please sign in to comment.