-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.mjs
More file actions
149 lines (148 loc) · 4.95 KB
/
eslint.config.mjs
File metadata and controls
149 lines (148 loc) · 4.95 KB
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
import tseslint from 'typescript-eslint';
import importPlugin from 'eslint-plugin-import';
import vitestPlugin from '@vitest/eslint-plugin';
export default [
{ ignores: ['**/dist/**', '**/node_modules/**', '**/*.js', '!eslint.config.mjs'] },
{
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tseslint.plugin,
import: importPlugin,
},
linterOptions: { reportUnusedDisableDirectives: 'error' },
languageOptions: {
parser: tseslint.parser,
parserOptions: { projectService: true },
sourceType: 'module',
},
settings: {
'import/extensions': ['.ts'],
},
rules: {
// eslint rules
'arrow-body-style': ['error', 'as-needed'],
'arrow-parens': ['off', 'as-needed'],
curly: 'warn',
'eol-last': 'off',
eqeqeq: ['warn', 'smart'],
'linebreak-style': 'off',
'max-len': 'off',
'new-parens': 'off',
'newline-per-chained-call': 'off',
'no-cond-assign': 'warn',
'no-console': ['warn', { allow: ['error'] }],
'no-debugger': 'warn',
'no-else-return': 'error',
'no-empty-pattern': 'error',
'no-extra-semi': 'off',
'no-irregular-whitespace': 'off',
'no-multiple-empty-lines': 'off',
'no-restricted-exports': [
'error',
{
restrictDefaultExports: {
defaultFrom: true,
direct: true,
named: true,
namedFrom: true,
namespaceFrom: true,
},
},
],
'no-restricted-syntax': [
'error',
{
selector: 'FunctionDeclaration',
message: 'Use const with an arrow function instead of function declarations.',
},
{
selector: 'ImportDeclaration:not([importKind="type"])[source.value=vitest]',
message: 'Utilities from Vitest are available as globals and should not be imported',
},
{
selector: 'Literal[value=/\\bPlease\\b/i]',
message: "Avoid using the word 'Please' in strings",
},
],
'no-trailing-spaces': 'off',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': ['warn', { allowNamedFunctions: true }],
'prefer-const': 'warn',
'prefer-template': 'warn',
'quote-props': 'off',
'require-await': 'off',
'space-before-function-paren': 'off',
'spaced-comment': ['error', 'always'],
'template-curly-spacing': ['error', 'never'],
// @typescript-eslint rules
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/consistent-type-assertions': ['warn', { assertionStyle: 'as' }],
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'separate-type-imports', prefer: 'type-imports' },
],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/member-delimiter-style': [
'off',
'error',
{
singleline: { delimiter: 'semi', requireLast: false },
multiline: { delimiter: 'none', requireLast: true },
},
],
'@typescript-eslint/no-deprecated': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrors: 'none',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/quotes': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/semi': ['off', null],
'@typescript-eslint/space-within-parens': ['off', 'never'],
'@typescript-eslint/type-annotation-spacing': 'off',
// import rules
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import/export': 'warn',
'import/group-exports': 'error',
'import/no-duplicates': ['warn', { 'prefer-inline': false }],
'import/order': [
'warn',
{
groups: ['type', 'builtin', 'external', 'parent', 'sibling', 'index'],
named: true,
alphabetize: { order: 'asc', orderImportKind: 'asc' },
},
],
},
},
{
files: ['**/tests/**/*.test.ts'],
plugins: { vitest: vitestPlugin },
rules: {
'no-console': 'off',
'vitest/consistent-test-it': ['error', { fn: 'it' }],
'vitest/no-commented-out-tests': 'error',
'vitest/no-identical-title': 'error',
'vitest/no-import-node-test': 'error',
'vitest/no-restricted-vi-methods': [
'error',
{ mock: 'vi.mock is hoisted which can cause hard-to-debug errors. Prefer vi.doMock' },
],
'vitest/padding-around-all': 'error',
'vitest/prefer-hooks-in-order': 'error',
'vitest/prefer-hooks-on-top': 'error',
'vitest/valid-describe-callback': 'error',
'vitest/valid-expect': 'error',
'vitest/valid-title': 'error',
},
}
];