Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
128 lines (122 loc) · 4.01 KB
/
Copy patheslint.config.mjs
File metadata and controls
128 lines (122 loc) · 4.01 KB
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
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import json from '@eslint/json';
import markdown from '@eslint/markdown';
import css from '@eslint/css';
import { defineConfig, globalIgnores } from 'eslint/config';
import stylistic from '@stylistic/eslint-plugin';
export default defineConfig([
globalIgnores([
'**/dist/*',
'samples/*/*.js',
'**/package-lock.json',
'**/playwright-report/*',
'**/test-results/*',
]),
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
plugins: { js },
extends: ['js/recommended'],
languageOptions: { globals: { ...globals.browser, ...globals.node } },
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
tseslint.configs.recommended,
{
plugins: {
'@stylistic': stylistic,
},
rules: {
'one-var': ['error', 'never'],
'no-undef': 'off', // handled better by TS
'prefer-const': 'error',
'spaced-comment': ['error', 'always'],
'no-shadow': 'error',
'no-prototype-builtins': 'off', // samples show more vanilla patterns
'object-shorthand': ['error', 'always'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'prefer-arrow-callback': 'error',
},
},
{
files: ['**/*.ts', '**/*.tsx'],
extends: [
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
parserOptions: {
projectService: true,
},
},
rules: {
'no-shadow': 'off', // required to enable @typescript-eslint/no-shadow
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-deprecated': 'error',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: {
arguments: false,
attributes: false,
},
},
],
'@typescript-eslint/no-namespace': [
'error',
{ allowDeclarations: true, allowDefinitionFiles: true },
],
// If something is already "any", then allow member access
'@typescript-eslint/no-unsafe-member-access': 'warn',
// this codebase uses non-null assertions a lot for document.querySelector() and similar patterns:
'@typescript-eslint/no-non-null-assertion': 'off',
// downgraded to warn for historic reasons:
'@typescript-eslint/restrict-template-expressions': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
// buggy. breaks the code:
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'warn',
},
},
{
files: ['**/*.json'],
plugins: { json },
language: 'json/json',
extends: ['json/recommended'],
},
{
files: ['**/*.jsonc'],
plugins: { json },
language: 'json/jsonc',
extends: ['json/recommended'],
},
{
files: ['**/*.json5'],
plugins: { json },
language: 'json/json5',
extends: ['json/recommended'],
},
{
files: ['**/*.md'],
plugins: { markdown },
language: 'markdown/gfm',
extends: ['markdown/recommended'],
rules: {
// temporarily disabled for historic reasons:
'markdown/no-empty-links': 'off',
'markdown/no-missing-label-refs': 'off',
},
},
{
files: ['**/*.css'],
plugins: { css },
language: 'css/css',
extends: ['css/recommended'],
rules: {
'css/use-baseline': 'off',
},
},
]);