diff options
Diffstat (limited to 'subprojects/frontend/.eslintrc.cjs')
-rw-r--r-- | subprojects/frontend/.eslintrc.cjs | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/subprojects/frontend/.eslintrc.cjs b/subprojects/frontend/.eslintrc.cjs new file mode 100644 index 00000000..e6be4d65 --- /dev/null +++ b/subprojects/frontend/.eslintrc.cjs | |||
@@ -0,0 +1,89 @@ | |||
1 | const path = require('node:path'); | ||
2 | |||
3 | // Allow the Codium ESLint plugin to find `tsconfig.json` from the repository root. | ||
4 | const project = [ | ||
5 | path.join(__dirname, 'tsconfig.json'), | ||
6 | path.join(__dirname, 'tsconfig.node.json'), | ||
7 | ]; | ||
8 | |||
9 | /** @type {import('eslint').Linter.Config} */ | ||
10 | module.exports = { | ||
11 | plugins: ['@typescript-eslint'], | ||
12 | extends: [ | ||
13 | 'airbnb', | ||
14 | 'airbnb-typescript', | ||
15 | 'airbnb/hooks', | ||
16 | 'plugin:@typescript-eslint/recommended', | ||
17 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
18 | 'plugin:prettier/recommended', | ||
19 | ], | ||
20 | parserOptions: { | ||
21 | project, | ||
22 | sourceType: 'module', | ||
23 | }, | ||
24 | parser: '@typescript-eslint/parser', | ||
25 | settings: { | ||
26 | 'import/parsers': { | ||
27 | '@typescript-eslint/parser': ['.ts', '.tsx'], | ||
28 | }, | ||
29 | 'import/resolver': { | ||
30 | typescript: { | ||
31 | alwaysTryTypes: true, | ||
32 | project, | ||
33 | }, | ||
34 | }, | ||
35 | }, | ||
36 | env: { | ||
37 | browser: true, | ||
38 | }, | ||
39 | ignorePatterns: ['build/**/*'], | ||
40 | rules: { | ||
41 | // In typescript, some class methods implementing an inderface do not use `this`: | ||
42 | // https://github.com/typescript-eslint/typescript-eslint/issues/1103 | ||
43 | 'class-methods-use-this': 'off', | ||
44 | // Make sure every import can be resolved by `eslint-import-resolver-typescript`. | ||
45 | 'import/no-unresolved': 'error', | ||
46 | // Organize imports automatically. | ||
47 | 'import/order': [ | ||
48 | 'error', | ||
49 | { | ||
50 | alphabetize: { | ||
51 | order: 'asc', | ||
52 | }, | ||
53 | 'newlines-between': 'always', | ||
54 | }, | ||
55 | ], | ||
56 | }, | ||
57 | overrides: [ | ||
58 | { | ||
59 | files: ['types/**/*.d.ts'], | ||
60 | rules: { | ||
61 | // We don't have control over exports of external modules. | ||
62 | 'import/prefer-default-export': 'off', | ||
63 | }, | ||
64 | }, | ||
65 | { | ||
66 | files: ['*.cjs'], | ||
67 | rules: { | ||
68 | // https://github.com/typescript-eslint/typescript-eslint/issues/1724 | ||
69 | '@typescript-eslint/no-var-requires': 'off', | ||
70 | }, | ||
71 | }, | ||
72 | { | ||
73 | files: ['.eslintrc.cjs', 'prettier.config.cjs', 'vite.config.ts'], | ||
74 | env: { | ||
75 | browser: false, | ||
76 | node: true, | ||
77 | }, | ||
78 | rules: { | ||
79 | // Allow devDependencies in configuration files. | ||
80 | 'import/no-extraneous-dependencies': [ | ||
81 | 'error', | ||
82 | { devDependencies: true }, | ||
83 | ], | ||
84 | // Access to the environment in configuration files. | ||
85 | 'no-process-env': 'off', | ||
86 | }, | ||
87 | }, | ||
88 | ], | ||
89 | }; | ||