-
Notifications
You must be signed in to change notification settings - Fork 13
/
eslint.config.js
205 lines (193 loc) · 4.95 KB
/
eslint.config.js
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
// @ts-check
import './tools/node-esm-hook/register-hooks.js';
import { FlatCompat } from '@eslint/eslintrc';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginYml from 'eslint-plugin-yml';
import eslint from '@eslint/js';
const eslintPluginLyne = await import('./tools/eslint/index.ts');
const compat = new FlatCompat({
baseDirectory: import.meta.resolve('.'),
});
const ignores = [
'dist/**/*',
'coverage/**/*',
'tools/generate-component/**/*',
'**/__snapshots__/**/*',
];
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
{
settings: {
'import-x/resolver': {
typescript: true,
},
},
},
{
languageOptions: {
globals: { ...globals.browser, ...globals.node },
},
},
{
ignores,
},
{
rules: eslint.configs.recommended.rules,
ignores,
},
...tseslint.configs.recommended,
...eslintPluginYml.configs['flat/standard'],
...eslintPluginYml.configs['flat/prettier'],
...compat.extends(
'plugin:lit/recommended',
'plugin:import-x/recommended',
'plugin:import-x/typescript',
),
// @ts-expect-error The returned config will exist.
eslintPluginLyne.default.configs.recommended,
{
files: ['src/visual-regression-app/**/*.ts'],
rules: {
'lyne/custom-element-class-name-rule': 'off',
'import-x/namespace': 'off',
},
},
{
files: ['src/storybook/**/*.ts'],
rules: {
'lyne/test-describe-title-rule': 'off',
},
},
{
files: ['**/*.spec.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
format: ['PascalCase'],
selector: 'interface',
},
{
format: ['camelCase'],
selector: 'default',
},
{
format: ['camelCase', 'UPPER_CASE'],
selector: 'variable',
},
{
format: ['camelCase'],
leadingUnderscore: 'allow',
selector: 'parameter',
},
{
format: ['camelCase'],
leadingUnderscore: 'require',
modifiers: ['private'],
selector: 'memberLike',
},
{
format: ['PascalCase'],
selector: 'typeLike',
},
{
format: null,
selector: 'objectLiteralProperty',
},
],
// TODO: Remove this after fixing issues
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-use-before-define': 'error',
// TODO: Evaluate this rule
'@typescript-eslint/semi': 'error',
'import-x/first': 'error',
'import-x/no-absolute-path': 'error',
'import-x/no-cycle': 'error',
'import-x/no-self-import': 'error',
'import-x/no-unresolved': [
'error',
{
ignore: [
'\\.md\\?raw$',
'\\.svg\\?raw$',
'\\.scss\\?lit\\&inline',
// Broken. Maybe due to commonjs?
'@storybook/addon-actions/decorator',
],
},
],
'import-x/no-useless-path-segments': 'error',
'import-x/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
'newlines-between': 'always',
},
],
// TODO: Discuss this with the team
'lit/no-invalid-html': 'off',
camelcase: 'off',
'@typescript-eslint/member-ordering': [
'error',
{
default: {
memberTypes: [
// Index signature
'signature',
'call-signature',
'static-field',
// Static initialization
'static-initialization',
['set', 'get', 'field', 'accessor'],
'constructor',
'static-method',
['method', 'decorated-method'],
],
},
},
],
},
},
{
files: ['**/*.stories.ts'],
rules: {
'@typescript-eslint/naming-convention': 'off',
},
},
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
},
],
'import-x/namespace': 'off',
'import-x/default': 'off',
'import-x/no-named-as-default': 'off',
'import-x/no-named-as-default-member': 'off',
},
},
eslintConfigPrettier,
];