test.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { Linter } from 'eslint';
  2. import { interopDefault } from '../util';
  3. export async function test(): Promise<Linter.Config[]> {
  4. const [pluginTest, pluginNoOnlyTests] = await Promise.all([
  5. interopDefault(import('eslint-plugin-vitest')),
  6. // @ts-expect-error - no types
  7. interopDefault(import('eslint-plugin-no-only-tests')),
  8. ] as const);
  9. return [
  10. {
  11. files: [
  12. `**/__tests__/**/*.?([cm])[jt]s?(x)`,
  13. `**/*.spec.?([cm])[jt]s?(x)`,
  14. `**/*.test.?([cm])[jt]s?(x)`,
  15. `**/*.bench.?([cm])[jt]s?(x)`,
  16. `**/*.benchmark.?([cm])[jt]s?(x)`,
  17. ],
  18. plugins: {
  19. test: {
  20. ...pluginTest,
  21. rules: {
  22. ...pluginTest.rules,
  23. ...pluginNoOnlyTests.rules,
  24. },
  25. },
  26. },
  27. rules: {
  28. 'no-console': 'off',
  29. 'node/prefer-global/process': 'off',
  30. 'test/consistent-test-it': [
  31. 'error',
  32. { fn: 'it', withinDescribe: 'it' },
  33. ],
  34. 'test/no-identical-title': 'error',
  35. 'test/no-import-node-test': 'error',
  36. 'test/no-only-tests': 'error',
  37. 'test/prefer-hooks-in-order': 'error',
  38. 'test/prefer-lowercase-title': 'error',
  39. },
  40. },
  41. ];
  42. }