1
1
import globals from 'globals' ;
2
2
import eslint from '@eslint/js' ;
3
3
import tseslint from 'typescript-eslint' ;
4
- import eslintConfigPrettier from 'eslint-config -prettier' ;
4
+ import eslintPluginPrettierRecommended from 'eslint-plugin -prettier/recommended ' ;
5
5
import eslintPluginUnicorn from 'eslint-plugin-unicorn' ;
6
6
7
7
export default tseslint . config (
8
8
eslint . configs . recommended ,
9
9
tseslint . configs . strictTypeChecked ,
10
10
tseslint . configs . stylisticTypeChecked ,
11
11
eslintPluginUnicorn . configs [ 'flat/recommended' ] ,
12
- eslintConfigPrettier ,
12
+ eslintPluginPrettierRecommended ,
13
13
{
14
14
languageOptions : {
15
15
globals : globals . node ,
@@ -19,8 +19,100 @@ export default tseslint.config(
19
19
} ,
20
20
} ,
21
21
} ,
22
+ {
23
+ files : [ 'src/**/*.ts' , 'tests/**/*.ts' ] ,
24
+ rules : {
25
+ 'no-console' : 'warn' ,
26
+ 'no-debugger' : 'warn' ,
27
+ 'no-empty-pattern' : 'warn' ,
28
+ 'no-empty' : 'warn' ,
29
+ 'no-param-reassign' : 'warn' ,
30
+ 'no-unreachable' : 'warn' ,
31
+ 'no-var' : 'warn' ,
32
+ 'no-warning-comments' : 'warn' ,
33
+ 'prefer-const' : 'warn' ,
34
+ eqeqeq : 'warn' ,
35
+
36
+ 'prettier/prettier' : 'warn' ,
37
+
38
+ 'unicorn/prevent-abbreviations' : 'off' ,
39
+ 'unicorn/prefer-optional-catch-binding' : 'warn' ,
40
+ 'unicorn/no-empty-file' : 'warn' ,
41
+ 'unicorn/prefer-set-has' : 'warn' ,
42
+ /**
43
+ * There are situations where you might prefer to use `null` because
44
+ * `undefined` doesn't fit. For example, when merging one object into another
45
+ * with lodash's merge function, it completely ignores properties with
46
+ * `undefined` values and you may want to keep those properties.
47
+ */
48
+ 'unicorn/no-null' : 'off' ,
49
+
50
+ '@typescript-eslint/no-magic-numbers' : 'warn' ,
51
+ '@typescript-eslint/no-unused-vars' : 'warn' ,
52
+ '@typescript-eslint/no-unsafe-assignment' : 'warn' ,
53
+ '@typescript-eslint/no-floating-promises' : [ 'warn' , { ignoreIIFE : true } ] ,
54
+ '@typescript-eslint/no-empty-function' : 'warn' ,
55
+ '@typescript-eslint/explicit-function-return-type' : [
56
+ 'warn' ,
57
+ {
58
+ allowExpressions : false ,
59
+ allowTypedFunctionExpressions : true ,
60
+ allowHigherOrderFunctions : false ,
61
+ allowDirectConstAssertionInArrowFunctions : true ,
62
+ allowConciseArrowFunctionExpressionsStartingWithVoid : false ,
63
+ allowFunctionsWithoutTypeParameters : false ,
64
+ allowedNames : [ ] ,
65
+ allowIIFEs : false ,
66
+ } ,
67
+ ] ,
68
+ '@typescript-eslint/explicit-module-boundary-types' : 'warn' ,
69
+ '@typescript-eslint/typedef' : [
70
+ 'warn' ,
71
+ {
72
+ arrayDestructuring : true ,
73
+ objectDestructuring : true ,
74
+ arrowParameter : true ,
75
+ memberVariableDeclaration : true ,
76
+ parameter : true ,
77
+ propertyDeclaration : true ,
78
+ variableDeclaration : true ,
79
+ variableDeclarationIgnoreFunction : true ,
80
+ } ,
81
+ ] ,
82
+ '@typescript-eslint/strict-boolean-expressions' : 'warn' ,
83
+ '@typescript-eslint/no-unsafe-call' : 'warn' ,
84
+ '@typescript-eslint/no-unsafe-member-access' : 'warn' ,
85
+ '@typescript-eslint/no-for-in-array' : 'warn' ,
86
+ '@typescript-eslint/consistent-type-exports' : 'warn' ,
87
+ '@typescript-eslint/consistent-type-imports' : 'warn' ,
88
+ '@typescript-eslint/no-shadow' : 'warn' ,
89
+ '@typescript-eslint/require-await' : 'warn' ,
90
+ '@typescript-eslint/no-explicit-any' : 'warn' ,
91
+ '@typescript-eslint/no-unsafe-return' : 'warn' ,
92
+ /**
93
+ * It's better to explicitly define the type. The implementation may change in the future,
94
+ * and you can forget to add the type if it's not there. Also, you may need to create a variable
95
+ * that could have several types and in this case it's better to explicitly define what are those types.
96
+ */
97
+ '@typescript-eslint/no-inferrable-types' : 'off' ,
98
+ // /**
99
+ // * The nullish coalescing operator only coalesces when the checked value is null or
100
+ // * undefined, but what if you want to coalesce on any falsy value like an empty string?
101
+ // * In that case you would need "||". This requires {"strictNullChecks": true}
102
+ // */
103
+ // '@typescript-eslint/prefer-nullish-coalescing': 'off',
104
+ } ,
105
+ } ,
22
106
{
23
107
files : [ '**/*.js' ] ,
108
+ // TS rules are applied by default so we have to disable the
109
+ // type-checking rules for JS files.
24
110
extends : [ tseslint . configs . disableTypeChecked ] ,
25
111
} ,
112
+ // {
113
+ // files: ['tests/**/*.ts'],
114
+ // env: {
115
+ // jest: true,
116
+ // },
117
+ // },
26
118
) ;
0 commit comments