-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
142 lines (138 loc) · 4.7 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
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
// @ts-check
import eslint from '@eslint/js';
import jestPlugin from 'eslint-plugin-jest';
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint';
import * as importPlugin from 'eslint-plugin-import';
export default tseslint.config(
{
// Config replacement for `.eslintignore`
ignores: ['**/dist/**', 'jest.config.js'],
},
stylistic.configs.customize({
flat: true,
semi: true,
}),
eslint.configs.all,
tseslint.configs.recommended,
{
extends: [
// 'eslint:recommended',
importPlugin.flatConfigs?.recommended,
// The following lines do the trick
importPlugin.flatConfigs?.typescript,
],
settings: {
'import/resolver': {
// You will also need to install and configure the TypeScript resolver
// See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
typescript: true,
// Always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
alwaysTryTypes: true,
node: true,
},
},
},
{
// Disable type-aware linting on JS files
extends: [tseslint.configs.disableTypeChecked],
files: ['**/*.js'],
},
{
// Enable jest rules on test files
extends: [jestPlugin.configs['flat/recommended']],
files: ['**/*.test.ts'],
rules: {
'init-declarations': 'off',
'max-lines-per-function': 'off',
},
},
{
// Enable debugging rules
files: ['**/output/**/*', '**/test/**/*', '**/index.ts'],
rules: {
'no-console': 'off',
},
},
{
// Custom rules
rules: {
'@stylistic/array-element-newline': ['error', 'consistent'],
'@stylistic/arrow-parens': ['error', 'as-needed'],
'@stylistic/comma-dangle': 'off',
'@stylistic/indent': ['error', 4],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
varsIgnorePattern: '^_',
},
],
'array-callback-return': 'error',
'arrow-body-style': ['error', 'as-needed'],
'camelcase': ['error', { allow: ['_impl$'] }],
'capitalized-comments': [
'error',
'always',
{
ignoreConsecutiveComments: true,
ignorePattern: 'console',
},
],
'curly': 'error',
'eqeqeq': 'error',
'id-length': 'off',
'import/order': ['error', {
groups: [
// Imports of builtins are first
'builtin',
// Then sibling and parent imports. They can be mingled together
'sibling',
'parent',
// Then index file imports
'index',
// Then any arcane TypeScript imports
'object',
// Then the omitted imports: internal, external, type, unknown
],
}],
'max-statements': 'error',
'no-eval': 'error',
'no-magic-numbers': 'off',
'no-plusplus': 'off',
'no-ternary': 'off',
'no-unused-vars': 'off',
'no-useless-assignment': 'error',
'no-useless-return': 'warn',
'one-var': ['error', { const: 'never', let: 'never', var: 'always' }],
'prefer-const': 'error',
'prefer-destructuring': 'warn',
'radix': 'warn',
// 'sort-imports': [
// 'error',
// {
// allowSeparatedGroups: false,
// ignoreCase: true,
// ignoreDeclarationSort: false,
// ignoreMemberSort: false,
// memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
// },
// ],
'sort-imports':
[
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true
}
],
'sort-keys': 'off',
'sort-vars': 'error',
},
}
);