|
| 1 | +import { version as typescriptESLintPluginVersion } from '@typescript-eslint/eslint-plugin/package.json'; |
| 2 | +import { version as eslintVersion } from 'eslint/package.json'; |
| 3 | +import type { Config } from 'jest'; |
| 4 | +import * as semver from 'semver'; |
| 5 | + |
| 6 | +const config = { |
| 7 | + clearMocks: true, |
| 8 | + restoreMocks: true, |
| 9 | + resetMocks: true, |
| 10 | + |
| 11 | + coverageThreshold: { |
| 12 | + global: { |
| 13 | + branches: 100, |
| 14 | + functions: 100, |
| 15 | + lines: 100, |
| 16 | + statements: 100, |
| 17 | + }, |
| 18 | + }, |
| 19 | + |
| 20 | + projects: [ |
| 21 | + { |
| 22 | + displayName: 'test', |
| 23 | + testPathIgnorePatterns: [ |
| 24 | + '<rootDir>/lib/.*', |
| 25 | + '<rootDir>/src/rules/__tests__/fixtures/*', |
| 26 | + '<rootDir>/src/rules/__tests__/test-utils.ts', |
| 27 | + ], |
| 28 | + coveragePathIgnorePatterns: ['/node_modules/'], |
| 29 | + }, |
| 30 | + { |
| 31 | + displayName: 'lint', |
| 32 | + runner: 'jest-runner-eslint', |
| 33 | + testMatch: ['<rootDir>/**/*.{js,ts}'], |
| 34 | + testPathIgnorePatterns: ['<rootDir>/lib/.*'], |
| 35 | + coveragePathIgnorePatterns: ['/node_modules/'], |
| 36 | + }, |
| 37 | + ], |
| 38 | +} satisfies Config; |
| 39 | + |
| 40 | +if (semver.major(eslintVersion) >= 9) { |
| 41 | + config.projects = config.projects.filter( |
| 42 | + ({ displayName }) => displayName !== 'lint', |
| 43 | + ); |
| 44 | + |
| 45 | + // jest/unbound-method doesn't work when using @typescript-eslint v6 |
| 46 | + if (semver.major(typescriptESLintPluginVersion) === 6) { |
| 47 | + for (const project of config.projects) { |
| 48 | + project.testPathIgnorePatterns.push( |
| 49 | + '<rootDir>/src/rules/__tests__/unbound-method.test.ts', |
| 50 | + ); |
| 51 | + project.coveragePathIgnorePatterns.push( |
| 52 | + '<rootDir>/src/rules/unbound-method.ts', |
| 53 | + ); |
| 54 | + } |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +export default config; |
0 commit comments