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