-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
189 lines (171 loc) · 5.58 KB
/
Copy patheslint.config.js
File metadata and controls
189 lines (171 loc) · 5.58 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import jsPlugin from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import eslintPluginJsonc from 'eslint-plugin-jsonc';
import perfectionist from 'eslint-plugin-perfectionist';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import numericSeparatorsPlugin from './vendor/eslint-numeric-separators-style/index.js';
// TODO: setup eslint-plugin-n
export default defineConfig(
jsPlugin.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
perfectionist.configs['recommended-natural'],
{
languageOptions: {
parserOptions: {
extraFileExtensions: ['.json5', '.jsonc'],
project: 'tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['**/*.ts', '**/*.js'],
plugins: {
'@perfectionist': perfectionist,
'@stylistic': stylistic,
'numeric-separators': numericSeparatorsPlugin,
},
rules: {
'@perfectionist/sort-classes': ['error', { partitionByNewLine: true }],
'@stylistic/lines-around-comment': [
'warn',
{
afterBlockComment: false, // conflicts with perfectionist if enabled
allowArrayStart: true,
allowBlockStart: true, // conflicts with prettier if disabled
allowClassStart: true,
allowInterfaceStart: true,
allowObjectStart: true, // conflicts with prettier if disabled
beforeBlockComment: false, // conflicts with perfectionist if enabled
},
],
'@stylistic/lines-between-class-members': ['error', 'always'],
'@stylistic/semi': 'error',
'@typescript-eslint/consistent-type-exports': [
'error',
{ fixMixedExportsWithInlineTypeSpecifier: true },
],
'@typescript-eslint/consistent-type-imports': [
'error',
{
disallowTypeAnnotations: true,
fixStyle: 'inline-type-imports',
prefer: 'type-imports',
},
],
// and sometimes you gotta use any
'@typescript-eslint/no-explicit-any': 'off',
// this rule seems broken
'@typescript-eslint/no-invalid-void-type': 'off',
// unfortunately required when using Sets and Maps
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': [
'error',
{
allowComparingNullableBooleansToFalse: true,
allowComparingNullableBooleansToTrue: true,
},
],
// too many false positives
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
varsIgnorePattern: '^_',
},
],
// these 6 bytes add up
'@typescript-eslint/require-await': 'off',
// I like my template expressions, tyvm
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unified-signatures': [
'error',
{
ignoreDifferentlyNamedParameters: true,
},
],
curly: 'error',
'func-style': ['error', 'expression'],
'new-cap': ['error', { capIsNew: true, newIsCap: true }],
'no-constructor-return': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-restricted-syntax': [
'error',
{
message:
'.readonly() is banned on Zod schemas because safeParse() will freeze values that pass through ZodReadonly schemas, which could cause unexpected mutations in our assertion library.',
selector:
'CallExpression[callee.type="MemberExpression"][callee.property.name="readonly"]',
},
],
'no-self-compare': 'error',
'numeric-separators/numeric-separators-style': 'error',
'object-shorthand': ['error', 'always'],
'prefer-arrow-callback': 'error',
semi: 'error',
},
},
{
files: ['test/**/*.test.ts', 'test/**/*.macro.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/unbound-method': 'off',
},
},
{
files: ['test-d/**/*.test-d.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/unbound-method': 'off',
},
},
{
files: ['.config/*.js', '/*.js', '/.*.js', 'scripts/*.js'],
languageOptions: {
globals: globals.node,
},
},
{
files: ['examples/**/*.js', 'examples/**/*.ts'],
languageOptions: {
globals: globals.node,
},
},
/** @type {any} */ (eslintPluginJsonc.configs['flat/prettier'][0]),
/** @type {any} */ ({
...eslintPluginJsonc.configs['flat/prettier'][1],
extends: [tseslint.configs.disableTypeChecked],
}),
/** @type {any} */ (eslintPluginJsonc.configs['flat/prettier'][2]),
{
ignores: [
'docs',
'dist',
'coverage',
'*.snapshot',
'.tshy/**/*',
'.tmp/**/*',
'.wallaby.js',
'.worktrees',
'site',
'astro.config.js',
'.astro/**/*',
'test-d/**/*',
'vendor/**/*',
'test/integration/fixture/**/*',
'test/fixtures/adapters/**/*',
],
},
);