-
-
Notifications
You must be signed in to change notification settings - Fork 108
/
eslint.config.js
161 lines (151 loc) · 3.26 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
import markdown from 'eslint-plugin-markdown';
import globals from 'globals';
import n from 'eslint-plugin-n';
import svelteOrgEslintConfig from '@sveltejs/eslint-config';
import svelteParser from 'svelte-eslint-parser';
export default [
{
name: 'local/ignores',
ignores: [
'**/temp/**',
'**/dist/**',
'**/build/**',
'**/.svelte-kit/**',
'**/.svelte/**',
'packages/playground/big/src/pages/**', // lots of generated files
'packages/*/types/index.d.ts',
'packages/*/types/index.d.ts.map',
'packages/*/CHANGELOG.md'
]
},
...svelteOrgEslintConfig, // contains setup for svelte and typescript
n.configs['flat/recommended-module'],
...markdown.configs.recommended,
{
name: 'local/language-options',
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module'
}
},
{
name: 'local/generic-rules',
rules: {
'n/no-unsupported-features/es-builtins': 'error',
'n/no-unsupported-features/es-syntax': 'error',
'no-console': 'off',
'no-debugger': 'error',
'n/no-extraneous-import': [
'error',
{
allowModules: ['vite', 'vitest']
}
],
'no-restricted-properties': [
'error',
{
property: 'substr',
message: 'Use .slice instead of .substr.'
}
],
'n/no-unpublished-import': 'off',
'n/no-unpublished-require': 'off',
'no-process-exit': 'off',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
quotes: [
'error',
'single',
{
avoidEscape: true
}
]
}
},
{
name: 'local/packages-src',
files: ['packages/*/src/**'],
rules: {
'no-console': 'error'
}
},
{
name: 'local/inspector-extras',
files: [
'packages/vite-plugin-svelte-inspector/src/runtime/load-inspector.js',
'packages/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte'
],
languageOptions: {
globals: {
...globals.browser
}
},
rules: {
'n/no-unsupported-features/node-builtins': 'off'
}
},
{
name: 'local/tests-and-playground-rules',
files: ['packages/e2e-tests/**', 'packages/playground/**'],
rules: {
'n/no-extraneous-import': 'off'
}
},
{
name: 'local/svelte-files',
files: ['**/*.svelte'],
languageOptions: {
globals: {
...globals.browser
},
parserOptions: {
parser: '@typescript-eslint/parser'
}
},
rules: {
'n/no-missing-import': 'off', // n doesn't know some vite specifics or monorepo imports.
'prefer-const': 'off' // this turns let foo = $derived into a const otherwise
}
},
{
name: 'local/svelte-runes-globals',
files: ['**/*.svelte.js', '**/*.svelte.ts', '**/*.svelte.*.js', '**/*.svelte.*.ts'],
languageOptions: {
parser: svelteParser
}
},
{
name: 'local/markdown-codefences',
files: ['**/*.md/*.js', '**/*.md/*.ts', '**/*.md/*.svelte'],
rules: {
'n/no-missing-import': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
},
{
name: 'local/spec-files',
files: ['**/__tests__/**/*.spec.ts'],
languageOptions: {
globals: {
...globals.jest,
...globals.node,
...globals.browser
}
},
rules: {
'n/no-missing-import': 'off'
}
},
{
name: 'local/allow-unused-vars',
files: ['**/vite.config.*', 'packages/e2e-tests/**', '**/*.d.ts'],
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
}
];