-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy patheslint.config.mjs
More file actions
159 lines (152 loc) · 4.03 KB
/
eslint.config.mjs
File metadata and controls
159 lines (152 loc) · 4.03 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
150
151
152
153
154
155
156
157
158
159
// eslint.config.js
import { globalIgnores } from 'eslint/config';
import prettier from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import unusedImports from 'eslint-plugin-unused-imports';
import { readFileSync } from 'fs';
import tseslint from 'typescript-eslint';
import eslint from '@eslint/js';
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.strictTypeChecked,
tseslint.configs.stylistic,
tseslint.configs.stylisticTypeCheckedOnly,
tseslint.configs.recommendedTypeChecked,
globalIgnores([
'**/*.test.ts',
// Use ignore rules from `.prettierignore`
...readFileSync('.prettierignore', { encoding: 'utf8' })
.split('\n')
.filter((rule) => rule && !rule.startsWith('#')),
]),
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
globals: {
window: 'readonly',
document: 'readonly',
require: 'readonly',
console: 'readonly',
module: 'writable',
},
},
plugins: {
import: importPlugin,
'unused-imports': unusedImports,
'simple-import-sort': simpleImportSort,
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
rules: {
'import/no-useless-path-segments': ['error', { noUselessIndex: true }],
'import/no-unresolved': ['error', { ignore: ['^vitest/config'] }],
'import/export': 'off',
'import/namespace': 'warn',
'import/no-duplicates': ['error', { 'prefer-inline': true }],
'import/newline-after-import': ['error', { count: 1 }],
'unused-imports/no-unused-imports': 'error',
'simple-import-sort/imports': [
'error',
{
groups: [
['^\\u0000'],
['^node:'],
['^react', '^\\w', '^@\\w'],
['^'],
['^../../'],
['^../', '^./', '^\\.'],
['\\.css$'],
],
},
],
'function-call-argument-newline': ['error', 'consistent'],
'no-var': 'error',
'no-bitwise': 'error',
'no-multi-spaces': 'error',
'no-multiple-empty-lines': 'error',
'space-in-parens': 'error',
semi: 'error',
'prefer-const': 'error',
'no-use-before-define': 'off',
// Types
// Disabled, because force programmers to cast anything to `String()` with no profit
'@typescript-eslint/restrict-template-expressions': 'off',
// Disabled, since case with `or, if empty` is too frequent
'@typescript-eslint/prefer-nullish-coalescing': 'off',
// Disabled, since conflict with many cases where third party property is not in camelCase
'@typescript-eslint/dot-notation': 'off',
// Disabled, because replaced `type` to `interface` and it makes type is incompatible with an `Record`/object
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/prefer-readonly': 'error',
'class-methods-use-this': [
'error',
{
exceptMethods: ['getLengthLimit', 'getRequestsTimeout'],
},
],
'@typescript-eslint/no-empty-object-type': [
'error',
{
allowObjectTypes: 'always',
},
],
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
camelcase: [
'error',
{
allow: ['^UNSAFE_', '^UNSTABLE_'],
},
],
'arrow-parens': ['error', 'always'],
'operator-linebreak': [
'error',
'after',
{
overrides: {
'?': 'before',
':': 'before',
},
},
],
'space-before-function-paren': [
'error',
{
asyncArrow: 'always',
anonymous: 'never',
named: 'never',
},
],
},
},
prettier,
{
files: ['**/*.js', '*.{js,mjs,cjs}'],
extends: [tseslint.configs.disableTypeChecked],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
);