-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint.config.js
178 lines (170 loc) · 5.9 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
// 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'
// /** @type import('@antfu/eslint-config').TypedFlatConfigItem['rules'] */
// const typescript_overrides =
// {
// ''
// }
// https://github.com/antfu/eslint-config
// Inspect: npx @eslint/config-inspector
export default antfu(
{
ignores: [
'**/.svelte-kit**',
'**/functions/lib/**',
'.eslintcache',
'packages/scripts/import/old**',
'**/route/kitbook/**',
'**/locales/**',
'supabase/functions/**',
'**.snap.json',
],
stylistic: {
overrides: {
'style/brace-style': ['error', '1tbs', { allowSingleLine: true }],
'antfu/if-newline': 'off',
'curly': 'off',
},
},
svelte: true,
},
{
name: 'jacob/svelte/stylistic',
files: ['**/*.svelte', '**/*.composition'],
plugins: {
'svelte-stylistic': svelteStylistic,
},
rules: {
'svelte-stylistic/brackets-same-line': 'error',
'svelte-stylistic/consistent-attribute-lines': 'error',
},
},
{
name: 'jacob/test/rules',
files: ['**/*.test.ts'],
rules: {
'test/consistent-test-it': ['error', { fn: 'test' }],
'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',
'test/no-commented-out-tests': 'warn',
},
},
{
name: 'jacob/settings',
files: ['.vscode/*.json'],
rules: {
'jsonc/comma-dangle': ['error', 'always-multiline'],
},
},
{
name: 'ld/script-exceptions',
files: ['packages/{scripts,functions}/**'],
rules: {
'no-console': 'off',
'ts/no-unused-vars': 'off',
'ts/no-var-requires': 'off',
'node/prefer-global/process': 'off',
'unused-imports/no-unused-vars': 'off',
},
},
{
name: 'ld/intercontinental-dictionaries-series',
files: ['**/ids-import/**'],
rules: {
'ts/no-unused-vars': 'off',
'no-undef': 'off',
'unused-imports/no-unused-vars': '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',
'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',
},
},
})
// learn more
// https://github.com/AndreaPontrandolfo/sheriff
// https://github.com/enso-org/enso/blob/b2c1f97437870fa7b7a4d7c2d3630e2d2bd6fc2c/app/ide-desktop/eslint.config.js
// https://github.com/azat-io/eslint-config/blob/044959d8fef2acff50e252b8a238be933cd38eea/base/index.ts
// https://github.com/darkobits/eslint-plugin/blob/f55a64dc9038148f3227cda7ae4543dffcb0b14e/src/config-sets/ts
// https://github.com/azat-io/eslint-config/blob/044959d8fef2acff50e252b8a238be933cd38eea/react/index.ts