|
| 1 | +const vitestFiles = ['app/**/__tests__/**/*', 'app/**/*.{spec,test}.*'] |
| 2 | +const testFiles = ['**/tests/**', ...vitestFiles] |
| 3 | +const appFiles = ['app/**'] |
| 4 | + |
| 5 | +/** @type {import('@types/eslint').Linter.BaseConfig} */ |
| 6 | +module.exports = { |
| 7 | + extends: [ |
| 8 | + '@remix-run/eslint-config', |
| 9 | + '@remix-run/eslint-config/node', |
| 10 | + 'prettier', |
| 11 | + ], |
| 12 | + rules: { |
| 13 | + // playwright requires destructuring in fixtures even if you don't use anything 🤷♂️ |
| 14 | + 'no-empty-pattern': 'off', |
| 15 | + '@typescript-eslint/consistent-type-imports': [ |
| 16 | + 'warn', |
| 17 | + { |
| 18 | + prefer: 'type-imports', |
| 19 | + disallowTypeAnnotations: true, |
| 20 | + fixStyle: 'inline-type-imports', |
| 21 | + }, |
| 22 | + ], |
| 23 | + 'import/no-duplicates': ['warn', { 'prefer-inline': true }], |
| 24 | + 'import/consistent-type-specifier-style': ['warn', 'prefer-inline'], |
| 25 | + 'import/order': [ |
| 26 | + 'warn', |
| 27 | + { |
| 28 | + alphabetize: { order: 'asc', caseInsensitive: true }, |
| 29 | + groups: [ |
| 30 | + 'builtin', |
| 31 | + 'external', |
| 32 | + 'internal', |
| 33 | + 'parent', |
| 34 | + 'sibling', |
| 35 | + 'index', |
| 36 | + ], |
| 37 | + }, |
| 38 | + ], |
| 39 | + }, |
| 40 | + overrides: [ |
| 41 | + { |
| 42 | + files: appFiles, |
| 43 | + excludedFiles: testFiles, |
| 44 | + rules: { |
| 45 | + 'no-restricted-imports': [ |
| 46 | + 'error', |
| 47 | + { |
| 48 | + patterns: [ |
| 49 | + { |
| 50 | + group: testFiles, |
| 51 | + message: 'Do not import test files in app files', |
| 52 | + }, |
| 53 | + ], |
| 54 | + }, |
| 55 | + ], |
| 56 | + }, |
| 57 | + }, |
| 58 | + { |
| 59 | + extends: ['@remix-run/eslint-config/jest-testing-library'], |
| 60 | + files: vitestFiles, |
| 61 | + rules: { |
| 62 | + 'testing-library/no-await-sync-events': 'off', |
| 63 | + 'jest-dom/prefer-in-document': 'off', |
| 64 | + }, |
| 65 | + // we're using vitest which has a very similar API to jest |
| 66 | + // (so the linting plugins work nicely), but it means we have to explicitly |
| 67 | + // set the jest version. |
| 68 | + settings: { |
| 69 | + jest: { |
| 70 | + version: 28, |
| 71 | + }, |
| 72 | + }, |
| 73 | + }, |
| 74 | + ], |
| 75 | +} |
0 commit comments