Skip to content

Commit

Permalink
bugfix(at-import-partial-extension): fixer incorrectly replaces filen…
Browse files Browse the repository at this point in the history
…ame (#643)
  • Loading branch information
chimurai committed Aug 10, 2022
1 parent e5f77c4 commit 33c1287
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/rules/at-import-partial-extension/__tests__/index.js
Expand Up @@ -406,6 +406,18 @@ testRule({
column: 33,
message: messages.rejected("scss"),
description: "Single file, has .scss extension and a dot in the name."
},
{
code: `
@import "component.scss-theme.scss";
`,
fixed: `
@import "component.scss-theme";
`,
line: 2,
column: 26,
message: messages.rejected("scss"),
description: "Single file, has .scss extension and a .scss in the filename."
}
]
});
2 changes: 1 addition & 1 deletion src/rules/at-import-partial-extension/index.js
Expand Up @@ -78,7 +78,7 @@ export default function rule(expectation, _, context) {
const isScssPartial = extension === "scss";
if (extension && isScssPartial && expectation === "never") {
if (context.fix) {
const extPattern = new RegExp(`\\.${extension}(['" ]*)`, "g");
const extPattern = new RegExp(`\\.${extension}(['" ]*)$`, "g");
decl.params = decl.params.replace(extPattern, "$1");

return;
Expand Down

0 comments on commit 33c1287

Please sign in to comment.