-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
svelte.js
74 lines (70 loc) · 1.83 KB
/
svelte.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
import svelte from 'eslint-plugin-svelte'
import svelteParser from 'svelte-eslint-parser'
import tseslint from 'typescript-eslint'
import ts from './ts.js'
let tsRules = ts.find(
config => config.files && config.files.includes('**/*.ts')
).rules
let globals = {}
let cleanedTsConfig = ts.map(config => {
let cleaned = { ...config }
if (cleaned.languageOptions && cleaned.languageOptions.globals) {
globals = { ...globals, ...cleaned.languageOptions.globals }
}
delete cleaned.languageOptions
return cleaned
})
export default [
{
languageOptions: {
globals,
parserOptions: {
extraFileExtensions: ['.svelte'],
project: true
},
sourceType: 'module'
}
},
...cleanedTsConfig,
{
files: ['**/*.svelte'],
languageOptions: {
parser: svelteParser,
parserOptions: {
parser: tseslint.parser
}
},
plugins: {
'@typescript-eslint': tseslint.plugin,
svelte
},
processor: 'svelte/svelte',
rules: {
...tsRules,
'import/first': 'off',
'no-undef-init': 'off',
'no-use-before-define': 'off',
'svelte/block-lang': ['error', { script: 'ts' }],
'svelte/infinite-reactive-loop': 'error',
'svelte/no-at-debug-tags': 'error',
'svelte/no-extra-reactive-curlies': 'error',
'svelte/no-reactive-literals': 'error',
'svelte/no-reactive-reassign': 'error',
'svelte/no-unused-class-name': 'error',
'svelte/prefer-class-directive': 'error',
'svelte/require-each-key': 'error',
'svelte/require-optimized-style-attribute': 'error',
'svelte/sort-attributes': 'error',
'svelte/spaced-html-comment': 'error'
}
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true
}
}
}
]