From 232b8e7dcbf398fd2d547eabaf71451add4c836a Mon Sep 17 00:00:00 2001 From: markgaze Date: Thu, 24 Oct 2024 16:15:59 +0100 Subject: [PATCH] feat(eslint): support *.spec.* files for Vitest --- eslint.js | 6 +++--- fixture/app/components/accordion.spec.tsx | 1 + fixture/app/components/accordion.tsx | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 fixture/app/components/accordion.spec.tsx diff --git a/eslint.js b/eslint.js index d56c91b..41aea3f 100644 --- a/eslint.js +++ b/eslint.js @@ -17,7 +17,7 @@ const hasReact = has('react') const hasTestingLibrary = has('@testing-library/dom') const hasJestDom = has('@testing-library/jest-dom') const hasVitest = has('vitest') -const vitestFiles = ['**/__tests__/**/*', '**/*.test.*'] +const vitestFiles = ['**/__tests__/**/*', '**/*.test.*', '**/*.spec.*'] const testFiles = ['**/tests/**', '**/#tests/**', ...vitestFiles] const playwrightFiles = ['**/e2e/**'] @@ -224,8 +224,8 @@ export const config = [ : null, // This assumes test files are those which are in the test directory or have - // *.test.* in the filename. If a file doesn't match this assumption, then it - // will not be allowed to import test files. + // *.test.* or *.spec.* in the filename. If a file doesn't match this assumption, + // then it will not be allowed to import test files. { files: ['**/*.ts?(x)', '**/*.js?(x)'], ignores: testFiles, diff --git a/fixture/app/components/accordion.spec.tsx b/fixture/app/components/accordion.spec.tsx new file mode 100644 index 0000000..cd0d0e8 --- /dev/null +++ b/fixture/app/components/accordion.spec.tsx @@ -0,0 +1 @@ +export const MockAccordion = () =>
Accordion
diff --git a/fixture/app/components/accordion.tsx b/fixture/app/components/accordion.tsx index aabb2c1..77b0dde 100644 --- a/fixture/app/components/accordion.tsx +++ b/fixture/app/components/accordion.tsx @@ -1,4 +1,7 @@ // eslint-disable-next-line import { MockAccordion } from './__tests__/accordion.tsx' +// eslint-disable-next-line +import { MockAccordion as SpecMockAccordion } from './accordion.spec.tsx' console.log(MockAccordion) +console.log(SpecMockAccordion)