Skip to content

Commit

Permalink
feat(eslint): support *.spec.* files for Vitest (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
markgaze authored Oct 24, 2024
1 parent 8d8e188 commit d7f6490
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/**']

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions fixture/app/components/accordion.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const MockAccordion = () => <div>Accordion</div>
3 changes: 3 additions & 0 deletions fixture/app/components/accordion.tsx
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit d7f6490

Please sign in to comment.