-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
eslint.config.mjs
207 lines (201 loc) · 7.16 KB
/
eslint.config.mjs
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
import love from 'eslint-config-love'
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import typescriptParser from '@typescript-eslint/parser'
import stylistic from '@stylistic/eslint-plugin'
import eslintLit from 'eslint-plugin-lit'
import globals from 'globals'
export default tseslint.config(
{
ignores: [
'node_modules/', 'dist/', 'webpack.config.js',
'build/',
'vendor/',
'support/documentation', 'support',
'build-*js'
]
},
eslint.configs.recommended,
...tseslint.configs.recommended,
{
...love,
files: ['**/*.ts']
},
stylistic.configs.customize({
quotes: 'single',
semi: false,
commaDangle: 'never',
blockSpacing: true,
braceStyle: '1tbs',
indent: 2,
quoteProps: 'as-needed'
}),
{
rules: {
'@stylistic/space-before-function-paren': ['error', { anonymous: 'always', asyncArrow: 'always', named: 'always' }],
'@stylistic/arrow-parens': 'off',
'@stylistic/operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before' } }],
'@stylistic/max-statements-per-line': ['error', { max: 2 }]
}
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/return-await': [2, 'in-try-catch'], // FIXME: correct?
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-explicit-any': 'off', // FIXME: should be "error", and we should use 'unknown' in the code.
'init-declarations': 'off',
'@typescript-eslint/init-declarations': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/consistent-type-exports': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'max-params': 'off',
'@typescript-eslint/max-params': ['error', { max: 8 }], // FIXME: this rules should use the default max value.
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/class-methods-use-this': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used.
'@typescript-eslint/no-unsafe-return': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used.
'@typescript-eslint/no-unsafe-assignment': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used.
'@typescript-eslint/no-unsafe-call': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used.
'@typescript-eslint/no-unnecessary-condition': 'off', // FIXME: comes with eslint-config-love 84 update, but seems buggy (false positive).
'max-len': [
'error',
{
code: 120,
comments: 120
}
]
}
},
{
files: ['**/*.js'],
rules: {
// Disabling typescript-eslint rules for JS files (did not find a simplier way...)
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/init-declarations': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/consistent-type-exports': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/max-params': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/class-methods-use-this': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'max-params': 'off',
'init-declarations': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'max-len': [
'error',
{
code: 120,
comments: 120
}
]
}
},
{
files: ['.stylelintrc.js'],
languageOptions: {
globals: globals.node
}
},
{
files: ['server/**/*.js', 'server/**/*.ts'],
languageOptions: {
ecmaVersion: 6,
globals: {
...globals.node
},
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2018,
project: './server/tsconfig.json',
projectService: true
}
}
},
{
files: ['shared/**/*.js', 'shared/**/*.ts'],
languageOptions: {
ecmaVersion: 6,
globals: {
...globals.es2016,
...globals.browser
},
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2018,
project: [
'./server/tsconfig.json'
// './client/tsconfig.json' // FIXME: dont really know what is necessary here.
],
// FIXME: how to make projectService work?
projectService: false
// projectService: {
// allowDefaultProject: ['shared/lib/*.js', 'shared/lib/*.ts'],
// defaultProject: './server/tsconfig.json'
// }
}
}
},
{
files: ['client/**/*.js', 'client/**/*.ts', 'conversejs/**/*.js', 'conversejs/**/*.ts'],
languageOptions: {
ecmaVersion: 6,
globals: {
...globals.browser
},
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2018,
project: [
'./client/tsconfig.json',
'./conversejs/tsconfig.json'
]
}
},
// FIXME: not sure elintLit works.
plugins: {
...eslintLit.configs['flat/recommended'].plugins
},
rules: {
...eslintLit.configs['flat/recommended'].rules
}
},
{
files: ['conversejs/build-*.js', 'conversejs/loc.keys.js', 'conversejs/custom/webpack.livechat.js'],
languageOptions: {
globals: {
...globals.node
}
}
}
)