-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
90 lines (89 loc) · 2.9 KB
/
eslint.config.mjs
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
// @ts-check
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import svelteParser from 'svelte-eslint-parser';
import globals from 'globals';
export default ts.config(
js.configs.recommended,
...ts.configs.recommendedTypeChecked,
...ts.configs.stylisticTypeChecked,
...svelte.configs['flat/recommended'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
// Seemingly not defined in `globals.browser`
ScrollBehavior: 'readonly',
}
}
},
{
languageOptions: {
parser: ts.parser,
parserOptions: {
// ...
project: true,
extraFileExtensions: ['.svelte'], // This is a required setting in `@typescript-eslint/parser` v4.24.0.
},
},
},
{
files: ['**/*.svelte', '*.svelte'],
languageOptions: {
parser: svelteParser,
// Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
parserOptions: {
parser: ts.parser,
},
},
},
{
rules: {
// Allow explicit any, to avoid type gymnastics
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
caughtErrors: 'none',
}],
// Disallow floating promises to avoid random crashes
'@typescript-eslint/no-floating-promises': 'error',
// Single quotes where possible
quotes: ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }],
// Allow some `any` expressions since otherwise they seriously mess with tests, or enforce
// strictness in areas where it really doesn't matter (eg error handling)
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
// Also disable template expression checks, since they're also error handling stuff
// TODO: Enable them at some point when I get around to actually tidying things up
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
// FIXME: When I get around to hardening the request body validation, enable this rule again
'@typescript-eslint/no-unsafe-member-access': 'off',
// Allow empty functions, as they are useful to silence promise errors
'@typescript-eslint/no-empty-function': 'off',
// Use `type` instead of `interface`
"@typescript-eslint/consistent-type-definitions": ["error", 'type'],
},
},
{
ignores: [
'**/.DS_Store',
'**/node_modules',
'build',
'.svelte-kit',
'package',
'**/.env',
'**/.env.*',
'!**/.env.example',
'**/pnpm-lock.yaml',
'**/package-lock.json',
'**/yarn.lock',
'**/svelte.config.js',
'**/vitest.config.ts',
'eslint.config.mjs',
'vite.config.ts',
],
},
);