diff --git a/src/tests/noExportedTypesInTsxFiles.test.ts b/src/tests/noExportedTypesInTsxFiles.test.ts new file mode 100644 index 0000000..6ae7551 --- /dev/null +++ b/src/tests/noExportedTypesInTsxFiles.test.ts @@ -0,0 +1,70 @@ +import { RuleTester } from "@typescript-eslint/rule-tester"; +import * as vitest from "vitest"; +import { noExportedTypesInTsxFiles } from "../rules/noExportedTypesInTsxFiles"; + +RuleTester.afterAll = vitest.afterAll; +RuleTester.it = vitest.it; +RuleTester.itOnly = vitest.it.only; +RuleTester.describe = vitest.describe; + +const ruleTester = new RuleTester({ + parser: "@typescript-eslint/parser", +}); + +ruleTester.run("noExportedTypesInTsxFiles", noExportedTypesInTsxFiles, { + valid: [ + { + code: ` + export interface MyInterface { + prop: string; + } + `, + filename: "types.ts", + parserOptions: { ecmaVersion: 2020, sourceType: "module" }, + }, + { + code: ` + interface MyInterface { + prop: string; + } + `, + filename: "component.tsx", + parserOptions: { ecmaVersion: 2020, sourceType: "module" }, + }, + { + code: ` + export type MyType = string; + `, + filename: "someFile.ts", + parserOptions: { ecmaVersion: 2020, sourceType: "module" }, + }, + ], + invalid: [ + { + code: ` + export interface MyInterface { + prop: string; + } + `, + filename: "component.tsx", + parserOptions: { ecmaVersion: 2020, sourceType: "module" }, + errors: [ + { + messageId: "noExportedTypesInTsxFiles", + }, + ], + }, + { + code: ` + export type MyType = string; + `, + filename: "component.tsx", + parserOptions: { ecmaVersion: 2020, sourceType: "module" }, + errors: [ + { + messageId: "noExportedTypesInTsxFiles", + }, + ], + }, + ], +}); diff --git a/src/tests/noExportedTypesInTsxFiles.ts b/src/tests/noExportedTypesInTsxFiles.ts deleted file mode 100644 index d46da7d..0000000 --- a/src/tests/noExportedTypesInTsxFiles.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { RuleTester } from "@typescript-eslint/rule-tester"; -import * as vitest from "vitest"; -import { noExportedTypesInTsxFiles } from "../rules/noExportedTypesInTsxFiles"; - -RuleTester.afterAll = vitest.afterAll; -RuleTester.it = vitest.it; -RuleTester.itOnly = vitest.it.only; -RuleTester.describe = vitest.describe; - -const ruleTester = new RuleTester({ - parser: "@typescript-eslint/parser", -}); - -ruleTester.run("noExportedTypesInTsxFiles", noExportedTypesInTsxFiles, { - valid: [ - { - code: ` - export interface MyInterface { - prop: string; - } - `, - filename: "types.ts", - parserOptions: { ecmaVersion: 2020, sourceType: "module" }, - }, - { - code: ` - interface MyInterface { - prop: string; - } - `, - filename: "component.tsx", - parserOptions: { ecmaVersion: 2020, sourceType: "module" }, - }, - { - code: ` - export type MyType = string; - `, - filename: "someFile.ts", - parserOptions: { ecmaVersion: 2020, sourceType: "module" }, - }, - ], - invalid: [ - { - code: ` - export interface MyInterface { - prop: string; - } - `, - filename: "component.tsx", - parserOptions: { ecmaVersion: 2020, sourceType: "module" }, - errors: [ - { - messageId: "noExportedTypesInTsxFiles", - }, - ], - }, - { - code: ` - export type MyType = string; - `, - filename: "component.tsx", - parserOptions: { ecmaVersion: 2020, sourceType: "module" }, - errors: [ - { - messageId: "noExportedTypesInTsxFiles", - }, - ], - }, - ], -});