/
eslint.config.js
121 lines (110 loc) · 3.2 KB
/
eslint.config.js
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
// @ts-check
import stylisticJs from '@stylistic/eslint-plugin-js';
import stylisticTs from '@stylistic/eslint-plugin-ts';
import eslintPluginJsonc from 'eslint-plugin-jsonc';
import tseslint from 'typescript-eslint';
// TODO: setup eslint-plugin-n
export default tseslint.config(
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
project: './.config/tsconfig.eslint.json',
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: ['.json5', '.jsonc'],
},
},
},
{
files: ['**/*.ts'],
plugins: {
'@stylistic/ts': stylisticTs,
},
rules: {
'@stylistic/ts/semi': 'error',
// I like my template expressions, tyvm
'@typescript-eslint/restrict-template-expressions': 'off',
// and sometimes you gotta use any
'@typescript-eslint/no-explicit-any': 'off',
// these 6 bytes add up
'@typescript-eslint/require-await': 'off',
// unfortunately required when using Sets and Maps
'@typescript-eslint/no-non-null-assertion': 'off',
// this rule seems broken
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': [
'error',
{
allowComparingNullableBooleansToTrue: true,
allowComparingNullableBooleansToFalse: true,
},
],
'@typescript-eslint/unified-signatures': [
'error',
{
ignoreDifferentlyNamedParameters: true,
},
],
// too many false positives
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{
disallowTypeAnnotations: true,
fixStyle: 'inline-type-imports',
prefer: 'type-imports',
},
],
'@typescript-eslint/consistent-type-exports': [
'error',
{ fixMixedExportsWithInlineTypeSpecifier: true },
],
'@stylistic/ts/lines-around-comment': [
'warn',
{
beforeBlockComment: true,
// these conflict with prettier, so we must allow them
allowObjectStart: true,
allowClassStart: true,
allowInterfaceStart: true,
allowBlockStart: true,
allowArrayStart: true,
},
],
},
},
{
plugins: {
'@stylistic/js': stylisticJs,
},
files: ['**/*.js', '**/*.cjs', '*.cjs', '*.js'],
extends: [tseslint.configs.disableTypeChecked],
rules: {
'@stylistic/js/semi': 'error',
'@stylistic/js/lines-around-comment': [
'warn',
{
beforeBlockComment: true,
// these conflict with prettier, so we must allow them
allowObjectStart: true,
allowClassStart: true,
},
],
},
},
{
files: ['src/test/**/*.spec.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
},
},
eslintPluginJsonc.configs['flat/prettier'][0],
{
...eslintPluginJsonc.configs['flat/prettier'][1],
extends: [tseslint.configs.disableTypeChecked],
},
eslintPluginJsonc.configs['flat/prettier'][2],
{
ignores: ['dist', 'coverage', '__snapshots__', '.tshy*'],
},
);