diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-04-07 01:59:09 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-04-07 01:59:09 +0200 |
commit | 1d2b5c85a177b4be0cc270b8e6e54488e23da5a1 (patch) | |
tree | c8b87c875faa7e6048e5ba41b5a9e4449263fc6a /.eslintrc.cjs | |
parent | chore(deps): upgrade to frontend-jdk17 8.0.0 (diff) | |
download | refinery-1d2b5c85a177b4be0cc270b8e6e54488e23da5a1.tar.gz refinery-1d2b5c85a177b4be0cc270b8e6e54488e23da5a1.tar.zst refinery-1d2b5c85a177b4be0cc270b8e6e54488e23da5a1.zip |
build: move Javascript config to top level
We need this to support multiple Javascript subprojects (e.g., a frontend and a
documentation website).
Diffstat (limited to '.eslintrc.cjs')
-rw-r--r-- | .eslintrc.cjs | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 00000000..da434649 --- /dev/null +++ b/.eslintrc.cjs | |||
@@ -0,0 +1,136 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | |||
7 | const path = require('node:path'); | ||
8 | |||
9 | // Allow the Codium ESLint plugin to find `tsconfig.json` from the repository root. | ||
10 | const project = [ | ||
11 | path.join(__dirname, 'tsconfig.json'), | ||
12 | path.join(__dirname, 'subprojects/frontend/tsconfig.json'), | ||
13 | path.join(__dirname, 'subprojects/frontend/tsconfig.node.json'), | ||
14 | path.join(__dirname, 'subprojects/frontend/tsconfig.shared.json'), | ||
15 | ]; | ||
16 | |||
17 | /** @type {import('eslint').Linter.Config} */ | ||
18 | module.exports = { | ||
19 | plugins: ['@typescript-eslint', 'mobx'], | ||
20 | extends: [ | ||
21 | 'airbnb', | ||
22 | 'airbnb-typescript', | ||
23 | 'airbnb/hooks', | ||
24 | 'plugin:@typescript-eslint/recommended', | ||
25 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
26 | 'plugin:mobx/recommended', | ||
27 | 'plugin:prettier/recommended', | ||
28 | ], | ||
29 | parserOptions: { | ||
30 | project, | ||
31 | sourceType: 'module', | ||
32 | }, | ||
33 | parser: '@typescript-eslint/parser', | ||
34 | settings: { | ||
35 | 'import/parsers': { | ||
36 | '@typescript-eslint/parser': ['.ts', '.tsx'], | ||
37 | }, | ||
38 | 'import/resolver': { | ||
39 | typescript: { | ||
40 | alwaysTryTypes: true, | ||
41 | project, | ||
42 | }, | ||
43 | }, | ||
44 | }, | ||
45 | env: { | ||
46 | browser: true, | ||
47 | }, | ||
48 | ignorePatterns: [ | ||
49 | 'build/**/*', | ||
50 | 'subprojects/*/build/**/*', | ||
51 | 'subprojects/*/dev-dist/**/*', | ||
52 | 'subprojects/*/src/**/*.typegen.ts', | ||
53 | ], | ||
54 | rules: { | ||
55 | // In typescript, some class methods implementing an inderface do not use `this`: | ||
56 | // https://github.com/typescript-eslint/typescript-eslint/issues/1103 | ||
57 | 'class-methods-use-this': 'off', | ||
58 | // Disable rules with a high performance cost. | ||
59 | // See https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting/ | ||
60 | 'import/default': 'off', | ||
61 | 'import/extensions': 'off', | ||
62 | 'import/named': 'off', | ||
63 | 'import/namespace': 'off', | ||
64 | 'import/no-named-as-default': 'off', | ||
65 | 'import/no-named-as-default-member': 'off', | ||
66 | '@typescript-eslint/indent': 'off', | ||
67 | // Make sure every import can be resolved by `eslint-import-resolver-typescript`. | ||
68 | 'import/no-unresolved': 'error', | ||
69 | // Organize imports automatically. | ||
70 | 'import/order': [ | ||
71 | 'error', | ||
72 | { | ||
73 | alphabetize: { | ||
74 | order: 'asc', | ||
75 | }, | ||
76 | 'newlines-between': 'always', | ||
77 | }, | ||
78 | ], | ||
79 | // Not all components depend on observable state. | ||
80 | 'mobx/missing-observer': 'off', | ||
81 | // A dangling underscore, while not neccessary for all private fields, | ||
82 | // is useful for backing fields of properties that should be read-only from outside the class. | ||
83 | 'no-underscore-dangle': [ | ||
84 | 'error', | ||
85 | { | ||
86 | allowAfterThis: true, | ||
87 | allowFunctionParams: true, | ||
88 | }, | ||
89 | ], | ||
90 | // Use prop spreading to conditionally add props with `exactOptionalPropertyTypes`. | ||
91 | 'react/jsx-props-no-spreading': 'off', | ||
92 | // We use the `react-jsx` runtime, so there is no need to import `React`. | ||
93 | 'react/react-in-jsx-scope': 'off', | ||
94 | }, | ||
95 | overrides: [ | ||
96 | { | ||
97 | files: ['subprojects/*/types/**/*.d.ts'], | ||
98 | rules: { | ||
99 | // We don't have control over exports of external modules. | ||
100 | 'import/prefer-default-export': 'off', | ||
101 | }, | ||
102 | }, | ||
103 | { | ||
104 | files: ['*.cjs'], | ||
105 | rules: { | ||
106 | // https://github.com/typescript-eslint/typescript-eslint/issues/1724 | ||
107 | '@typescript-eslint/no-var-requires': 'off', | ||
108 | }, | ||
109 | }, | ||
110 | { | ||
111 | files: [ | ||
112 | '.eslintrc.cjs', | ||
113 | 'scripts/*.cjs', | ||
114 | 'subprojects/*/config/*.ts', | ||
115 | 'subprojects/*/config/*.cjs', | ||
116 | 'prettier.config.cjs', | ||
117 | 'subprojects/*/vite.config.ts', | ||
118 | ], | ||
119 | env: { | ||
120 | browser: false, | ||
121 | node: true, | ||
122 | }, | ||
123 | rules: { | ||
124 | // Allow devDependencies in configuration files. | ||
125 | 'import/no-extraneous-dependencies': [ | ||
126 | 'error', | ||
127 | { devDependencies: true }, | ||
128 | ], | ||
129 | // Allow writing to the console in ad-hoc scripts. | ||
130 | 'no-console': 'off', | ||
131 | // Access to the environment in configuration files. | ||
132 | 'no-process-env': 'off', | ||
133 | }, | ||
134 | }, | ||
135 | ], | ||
136 | }; | ||