-
Notifications
You must be signed in to change notification settings - Fork 5
/
eslint.config.js
149 lines (144 loc) · 4.85 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
// To run automatically on commit, add `simple-git-hooks` and `lint-staged` then run `npx simple-git-hooks` once. After that all commits will be linted.
// @ts-check
import { antfu } from '@antfu/eslint-config'
import jsEslintPlugin from '@eslint/js'
import tsEslintPlugin from '@typescript-eslint/eslint-plugin'
import svelteStylistic from 'eslint-plugin-svelte-stylistic'
// https://github.com/antfu/eslint-config
// Inspect: npx @eslint/config-inspector
export default antfu(
{
ignores: [
'**/.svelte-kit**',
'**/package/**',
'.eslintcache',
],
stylistic: {
overrides: {
'style/brace-style': ['error', '1tbs', { allowSingleLine: true }],
},
},
svelte: true,
},
{
rules: {
'jsdoc/require-property-description': 'off',
'jsdoc/require-returns-description': 'off',
},
},
{
name: 'jacob/svelte/stylistic',
files: ['**/*.svelte', '**/*.composition'],
plugins: {
'svelte-stylistic': svelteStylistic,
},
rules: {
'svelte-stylistic/brackets-same-line': 'error',
'svelte-stylistic/consistent-attribute-lines': 'error',
},
},
{
files: ['**/*.test.ts'],
rules: {
'test/consistent-test-it': ['error', { fn: 'test', withinDescribe: 'test' }],
'test/no-commented-out-tests': 'error',
'test/no-disabled-tests': 'error',
'test/consistent-test-filename': 'error',
'test/expect-expect': 'error',
'test/no-alias-methods': 'error',
'test/no-conditional-expect': 'error',
'test/no-conditional-in-test': 'error',
'test/no-conditional-tests': 'error',
'test/no-duplicate-hooks': 'error',
'test/no-focused-tests': 'error',
'test/no-standalone-expect': 'error',
'test/no-test-return-statement': 'error',
'test/prefer-comparison-matcher': 'error',
'test/prefer-hooks-on-top': 'error',
'test/prefer-spy-on': 'error',
'test/prefer-to-be-falsy': 'error',
'test/prefer-to-be-truthy': 'error',
'test/prefer-to-contain': 'error',
'test/prefer-to-have-length': 'error',
'test/valid-describe-callback': 'error',
'test/valid-expect': 'error',
},
},
{
name: 'jacob/settings',
files: ['.vscode/*.json'],
rules: {
'jsonc/comma-dangle': ['error', 'always-multiline'],
},
},
{
files: ['**/lib/routes/+layout.ts'],
rules: {
'ts/prefer-ts-expect-error': 'off',
},
},
).overrides({
'antfu/typescript/rules': {
files: ['**/*.svelte', '**/*.composition'],
rules: {
// Need to check if duplicates in these
...jsEslintPlugin.configs.recommended.rules,
// ...tsEslintPlugin.configs.recommended.rules, // cause the rest to break
...tsEslintPlugin.configs.stylistic.rules,
'prefer-destructuring': 'error',
'no-constant-binary-expression': 'error',
'ts/default-param-last': 'error',
'require-await': 'error',
'prefer-object-spread': 'error',
'no-useless-concat': 'error',
'no-else-return': 'error',
'no-console': ['error', { allow: ['warn', 'error', 'info', 'time', 'timeEnd'] }],
'require-atomic-updates': 'error',
'style/quotes': ['error', 'single', {
allowTemplateLiterals: true,
avoidEscape: true,
}],
'ts/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
caughtErrors: 'none',
ignoreRestSiblings: true,
// vars: 'all', // is this helpful?
varsIgnorePattern: '^\\$\\$Props$',
}],
'ts/no-explicit-any': 'warn',
'prefer-named-capture-group': 'warn',
'eqeqeq': 'warn',
'ts/no-empty-function': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-alert': 'off',
'ts/ban-ts-comment': 'off',
'ts/sort-type-constituents': 'off', // prefer logical rather than alphabetical sorting
'curly': 'off',
'antfu/if-newline': 'off',
'node/prefer-global/process': 'off',
},
},
'antfu/svelte/rules': {
files: ['**/*.composition'],
rules: {
'svelte/valid-compile': ['error', { ignoreWarnings: true }], // throws error on a11y issues
'svelte/no-dom-manipulating': 'error',
'svelte/no-store-async': 'error', // causes issues with auto-unsubscribing features
'svelte/require-store-reactive-access': 'error',
'svelte/require-event-dispatcher-types': 'error',
'svelte/button-has-type': 'error',
'svelte/no-extra-reactive-curlies': 'error',
'svelte/mustache-spacing': 'error',
'svelte/html-closing-bracket-spacing': 'error',
'svelte/no-reactive-reassign': ['warn', { props: false }],
'svelte/html-quotes': 'off', // should it enforce double quotes?
'svelte/no-at-html-tags': 'off',
'no-unused-expressions': 'off',
'no-inner-declarations': 'off',
'style/space-infix-ops': 'off',
'no-undef-init': 'off',
'no-self-assign': 'off',
},
},
})