Skip to content

Commit

Permalink
fix(eslint): fix package detection (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
wKovacs64 authored Jun 5, 2024
1 parent 8789183 commit f1b67c3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ import {
const ERROR = 'error'
const WARN = 'warn'

const has = pkg =>
import(pkg).then(
() => true,
() => false,
)
const has = pkg => {
try {
import.meta.resolve(pkg, import.meta.url)
return true
} catch {
return false
}
}

const hasTypeScript = await has('typescript')
const hasReact = await has('react')
const hasTestingLibrary = await has('@testing-library/dom')
const hasJestDom = await has('@testing-library/jest-dom')
const hasVitest = await has('vitest')
const hasTypeScript = has('typescript')
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 testFiles = ['**/tests/**', '**/#tests/**', ...vitestFiles]
const playwrightFiles = ['**/e2e/**']
Expand Down

0 comments on commit f1b67c3

Please sign in to comment.