Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix(at-import-partial-extension): fixer incorrectly replaces filename #643

Merged
merged 1 commit into from Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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