Skip to content

Commit

Permalink
fix(eslint-plugin-ts): do not ignore non-ts file for `no-export-assig…
Browse files Browse the repository at this point in the history
…nment`
  • Loading branch information
zanminkian committed Sep 19, 2024
1 parent 9aa9d94 commit 5fd6951
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-cougars-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@git-validator/eslint-plugin-ts": patch
---

fix(eslint-plugin-ts): do not ignore non-ts file for `no-export-assignment`
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { test } from "../test.spec.js";
import { noExportAssignment } from "./no-export-assignment.js";

const valid = [
{ code: "export default {}", filename: "test.ts" },
{ code: "export = {}", filename: "test.js" },
];
const valid = ["export default {}", "exports = {}", "module.exports = {}"];

const invalid = [{ code: "export = {}", filename: "test.ts" }];
const invalid = ["export = {}"];

test({ valid, invalid, ...noExportAssignment });
16 changes: 5 additions & 11 deletions packages/eslint-plugin-ts/src/rules/no-export-assignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ import { createSimpleRule, getRuleName } from "../utils.js";
export const noExportAssignment = createSimpleRule({
name: getRuleName(import.meta.url),
message: "Disallow using `export =` statement.",
create: (context) => {
const extension = context.filename.split(".").pop();
if (!["ts", "tsx", "mts", "cts"].includes(extension ?? "")) {
return {};
}
return {
TSExportAssignment: (node: Node) => {
context.reportNode(node);
},
};
},
create: (context) => ({
TSExportAssignment: (node: Node) => {
context.reportNode(node);
},
}),
});

0 comments on commit 5fd6951

Please sign in to comment.