-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint.config.mjs
112 lines (107 loc) · 4.58 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
/* eslint-disable unicorn/filename-case */
import eslint from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import eslintPluginPreferArrow from 'eslint-plugin-prefer-arrow-functions';
// import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
const config = tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
eslintPluginUnicorn.configs['flat/recommended'],
// eslintPluginPrettierRecommended,
{
languageOptions: {
globals: globals.builtin,
ecmaVersion: 6,
sourceType: "module",
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
}
},
{
plugins: { "prefer-arrow-functions": eslintPluginPreferArrow }
},
{
ignores: [
"eslint.config.js",
"assets/",
"build/",
"mobile/",
"docs/",
"json_examples/",
"types/",
'**/node_modules',
'**/external'
]
},
{
// ESLINT rules
rules: {
"no-underscore-dangle": "error",
"prefer-arrow-functions/prefer-arrow-functions": "error",
"max-classes-per-file": ["error", 1],
"quotes": ["error", "double", { "avoidEscape": true }],
"indent": ["error", 4, { SwitchCase: 1 }]
},
},
{
// TYPESCRIPT rules
rules: {
// disable
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-invalid-void-type": "off", // will report "Promise<void[]>"
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-condition": "off", // too much false positives (TS-Bug?)
"@typescript-eslint/no-unnecessary-type-parameters": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/prefer-literal-enum-member": "off", // we use calculated values, ex: enum{ MyEvent = 1+Event.CUSTOM_EVENTS}
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/unified-signatures": "off",
"@typescript-eslint/use-unknown-in-catch-callback-variable": "off",
// enable / Tweak
"@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
"@typescript-eslint/no-duplicate-type-constituents": ["error", { ignoreUnions: true }],
"@typescript-eslint/no-inferrable-types": ["error", { ignoreParameters: true, ignoreProperties: true }],
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false, "argsIgnorePattern": "^_" }],
"@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
"@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
},
},
{
// UNICORN rules
rules: {
"unicorn/prefer-global-this": "off",
"unicorn/prevent-abbreviations": ["error",
{
"replacements": {
"str": { "string": false },
"num": { "number": false },
"i": { "index": false },
"j": { "index": false },
"args": false,
"res": false,
}
}],
"unicorn/no-array-callback-reference": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-array-reduce": "off",
"unicorn/no-lonely-if": "off", // we'll keep "if"s for readability
"unicorn/numeric-separators-style": "off",
"unicorn/prefer-dom-node-append": "off",
"unicorn/prefer-dom-node-remove": "off",
"unicorn/prefer-number-properties": "off",
"unicorn/prefer-query-selector": "off", // nah, just not my style
"unicorn/prefer-string-raw": "off",
"unicorn/switch-case-braces": "off",
},
}
);
export default config;