@keeex/eslint-config 1.12.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +97 -150
- package/package.json +75 -41
- package/src/bin/kxeslint-dump.js +16 -0
- package/src/bin/kxeslint-setup.js +111 -0
- package/src/config/base.js +168 -254
- package/src/config/globals.js +42 -0
- package/src/config/importx.js +104 -0
- package/src/config/lazy.js +8 -0
- package/src/config/mocha.js +32 -47
- package/src/config/react/reacthooks.js +12 -0
- package/src/config/react/reactnative.js +26 -0
- package/src/config/react.js +74 -0
- package/src/config/reactfullconfig.js +16 -0
- package/src/config/typescript.js +88 -340
- package/src/defaults.js +41 -0
- package/src/dependencies.js +183 -0
- package/src/environ.js +7 -0
- package/src/index.js +66 -299
- package/src/sections.js +61 -0
- package/src/bin/eslint-depcheck.js +0 -105
- package/src/config/common.js +0 -7
- package/src/config/deprecation.js +0 -8
- package/src/config/import.js +0 -63
- package/src/config/jsx.js +0 -128
- package/src/config/promise.js +0 -9
- package/src/config/reacthooks.js +0 -8
- package/src/config/reactnative.js +0 -19
- package/src/config/typescript_types.js +0 -27
- package/src/consts.js +0 -1
package/src/config/mocha.js
CHANGED
|
@@ -1,49 +1,34 @@
|
|
|
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
|
-
extendsBase,
|
|
31
|
-
rules: {
|
|
32
|
-
"mocha/handle-done-callback": ["error", {"ignoreSkipped": true}],
|
|
33
|
-
"mocha/no-mocha-arrows": "off",
|
|
34
|
-
"prefer-arrow-callback": "off",
|
|
35
|
-
"mocha/prefer-arrow-callback": ["warn", {"allowUnboundThis": false}],
|
|
36
|
-
"func-names": "off",
|
|
37
|
-
"no-invalid-this": "off",
|
|
1
|
+
import mochaPlugin from "eslint-plugin-mocha";
|
|
2
|
+
|
|
3
|
+
import * as sections from "../sections.js";
|
|
4
|
+
|
|
5
|
+
export const apply = (configResult, eslintConfig) => {
|
|
6
|
+
if (!eslintConfig.mocha) return;
|
|
7
|
+
const mochaFilter = ["src/tests/**/*", "**/*.test.*"];
|
|
8
|
+
const mochaSection = {
|
|
9
|
+
...mochaPlugin.configs.flat.recommended,
|
|
10
|
+
files: mochaFilter,
|
|
11
|
+
};
|
|
12
|
+
sections.configureRules(
|
|
13
|
+
mochaSection,
|
|
14
|
+
"",
|
|
15
|
+
{
|
|
16
|
+
"max-classes-per-file": "off",
|
|
17
|
+
"max-lines": "off",
|
|
18
|
+
"max-lines-per-function": "off",
|
|
19
|
+
"max-params": "off",
|
|
20
|
+
"no-magic-numbers": "off",
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
if (eslintConfig.typescript) {
|
|
24
|
+
sections.configureRules(
|
|
25
|
+
mochaSection,
|
|
26
|
+
"@typescript-eslint",
|
|
27
|
+
{
|
|
28
|
+
"max-params": "off",
|
|
29
|
+
"no-magic-numbers": "off",
|
|
38
30
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (allOptions.typescript) {
|
|
43
|
-
mochaOverride.rules["@typescript-eslint/no-unused-expressions"] = "off";
|
|
44
|
-
mochaOverride.rules["@typescript-eslint/no-non-null-assertion"] = "off";
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return [mochaOverride];
|
|
48
|
-
},
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
configResult.push(mochaSection);
|
|
49
34
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
|
|
2
|
+
|
|
3
|
+
import {getReactFullConfig} from "../reactfullconfig.js";
|
|
4
|
+
|
|
5
|
+
export const apply = (configResult, eslintConfig) => {
|
|
6
|
+
const reactCfg = getReactFullConfig(eslintConfig.react);
|
|
7
|
+
if (!reactCfg.reactHooks) return;
|
|
8
|
+
configResult.push({
|
|
9
|
+
...eslintPluginReactHooks.configs.recommended,
|
|
10
|
+
files: ["src/webapp/**/*.js", "**/*.jsx", "**/*.tsx"],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {fixupPluginRules} from "@eslint/compat";
|
|
2
|
+
|
|
3
|
+
import reactNative from "eslint-plugin-react-native";
|
|
4
|
+
|
|
5
|
+
import * as sections from "../../sections.js";
|
|
6
|
+
import {getReactFullConfig} from "../reactfullconfig.js";
|
|
7
|
+
|
|
8
|
+
export const apply = (configResult, eslintConfig) => {
|
|
9
|
+
const reactCfg = getReactFullConfig(eslintConfig.react);
|
|
10
|
+
if (!reactCfg.reactNative) return;
|
|
11
|
+
const reactNativeSection = sections.getNamedSection(configResult, "keeex/react-native");
|
|
12
|
+
reactNativeSection.plugins = {"react-native": fixupPluginRules(reactNative)};
|
|
13
|
+
sections.configureRules(
|
|
14
|
+
reactNativeSection,
|
|
15
|
+
"react-native",
|
|
16
|
+
{
|
|
17
|
+
"no-color-literals": "warn",
|
|
18
|
+
"no-inline-styles": "warn",
|
|
19
|
+
"no-raw-text": "error",
|
|
20
|
+
"no-single-element-style-arrays": "error",
|
|
21
|
+
"no-unused-styles": "warn",
|
|
22
|
+
"sort-styles": "warn",
|
|
23
|
+
"split-platform-components": "warn",
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* eslint-disable no-magic-numbers */
|
|
2
|
+
import reactPlugin from "eslint-plugin-react";
|
|
3
|
+
|
|
4
|
+
import * as sections from "../sections.js";
|
|
5
|
+
|
|
6
|
+
import {getReactFullConfig} from "./reactfullconfig.js";
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line max-lines-per-function
|
|
9
|
+
export const apply = (configResult, eslintConfig) => {
|
|
10
|
+
const reactCfg = getReactFullConfig(eslintConfig.react);
|
|
11
|
+
if (!reactCfg.react) return;
|
|
12
|
+
configResult.push(
|
|
13
|
+
reactPlugin.configs.flat.recommended,
|
|
14
|
+
reactPlugin.configs.flat["jsx-runtime"],
|
|
15
|
+
);
|
|
16
|
+
const override = sections.getNamedSection(configResult, "keeex/react");
|
|
17
|
+
sections.sectionAddOption(override, "settings", "react", {version: "detect"});
|
|
18
|
+
sections.configureRules(
|
|
19
|
+
override,
|
|
20
|
+
"react",
|
|
21
|
+
{
|
|
22
|
+
"button-has-type": "warn",
|
|
23
|
+
"checked-requires-onchange-or-readonly": "warn",
|
|
24
|
+
"forward-ref-uses-ref": "warn",
|
|
25
|
+
"hook-use-state": "error",
|
|
26
|
+
"iframe-missing-sandbox": "error",
|
|
27
|
+
"jsx-boolean-value": "warn",
|
|
28
|
+
"jsx-child-element-spacing": "warn",
|
|
29
|
+
"jsx-curly-brace-presence": [
|
|
30
|
+
"error",
|
|
31
|
+
{
|
|
32
|
+
children: "never",
|
|
33
|
+
propElementValues: "always",
|
|
34
|
+
props: "never",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
"jsx-curly-newline": "warn",
|
|
38
|
+
"jsx-curly-spacing": "warn",
|
|
39
|
+
"jsx-equals-spacing": "warn",
|
|
40
|
+
"jsx-filename-extension": ["error", {extensions: [".js", ".tsx"]}],
|
|
41
|
+
"jsx-fragments": "error",
|
|
42
|
+
"jsx-handler-names": "warn",
|
|
43
|
+
"jsx-indent": ["error", 2],
|
|
44
|
+
"jsx-indent-props": ["error", 2],
|
|
45
|
+
"jsx-max-depth": ["warn", {max: 8}],
|
|
46
|
+
"jsx-no-bind": "error",
|
|
47
|
+
"jsx-no-constructed-context-values": "error",
|
|
48
|
+
"jsx-no-leaked-render": "warn",
|
|
49
|
+
"jsx-no-script-url": "error",
|
|
50
|
+
"jsx-no-useless-fragment": "warn",
|
|
51
|
+
"jsx-pascal-case": ["warn", {allowNamespace: true}],
|
|
52
|
+
"jsx-sort-props": ["warn", { ignoreCase: true}],
|
|
53
|
+
"jsx-tag-spacing": ["warn", {beforeClosing: "never"}],
|
|
54
|
+
"no-access-state-in-setstate": "error",
|
|
55
|
+
"no-array-index-key": "warn",
|
|
56
|
+
"no-arrow-function-lifecycle": "off",
|
|
57
|
+
"no-danger": "error",
|
|
58
|
+
"no-invalid-html-attribute": "error",
|
|
59
|
+
"no-namespace": "error",
|
|
60
|
+
"no-redundant-should-component-update": "error",
|
|
61
|
+
"no-this-in-sfc": "error",
|
|
62
|
+
"no-typos": "error",
|
|
63
|
+
"no-unsafe": "error",
|
|
64
|
+
"no-unstable-nested-components": "error",
|
|
65
|
+
"no-unused-class-component-methods": "warn",
|
|
66
|
+
"no-unused-state": "warn",
|
|
67
|
+
"prefer-es6-class": ["error"],
|
|
68
|
+
"require-optimization": "warn",
|
|
69
|
+
"self-closing-comp": "error",
|
|
70
|
+
"state-in-constructor": ["error"],
|
|
71
|
+
"void-dom-elements-no-children": "error",
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Normalize the user configuration for react */
|
|
2
|
+
export const getReactFullConfig = configEntry => {
|
|
3
|
+
if (typeof configEntry === "boolean") {
|
|
4
|
+
if (configEntry) return {react: true, reactHooks: false, reactNative: false};
|
|
5
|
+
return {react: false, reactHooks: false, reactNative: false};
|
|
6
|
+
}
|
|
7
|
+
const cfg = {
|
|
8
|
+
react: configEntry?.react ?? false,
|
|
9
|
+
reactHooks: configEntry?.reactHooks ?? false,
|
|
10
|
+
reactNative: configEntry?.reactNative ?? false,
|
|
11
|
+
};
|
|
12
|
+
if (!cfg.react && (cfg.reactHooks || cfg.reactNative)) {
|
|
13
|
+
throw new Error("Invalid react config; react must be enabled for react-native and react-hooks to be enabled too.");
|
|
14
|
+
}
|
|
15
|
+
return cfg;
|
|
16
|
+
};
|
package/src/config/typescript.js
CHANGED
|
@@ -1,351 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} = require("./typescript_types.js");
|
|
1
|
+
import tsdocPlugin from "eslint-plugin-tsdoc";
|
|
2
|
+
// Uses exports
|
|
3
|
+
// eslint-disable-next-line import-x/no-unresolved
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
* Check if types-based rules can be used
|
|
9
|
-
*/
|
|
10
|
-
const useTypes = presetOptions => typeof presetOptions === "string";
|
|
11
|
-
const useDeprecation = (presetOptions, allOptions) => {
|
|
12
|
-
if (!useTypes(presetOptions)) return false;
|
|
13
|
-
const deprecationKey = "deprecation";
|
|
14
|
-
if (!(deprecationKey in allOptions)) return true;
|
|
15
|
-
return allOptions[deprecationKey] === true;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const useTSDoc = allOptions => {
|
|
19
|
-
const tsdocOptions = allOptions.tsdoc;
|
|
20
|
-
if (tsdocOptions !== undefined && tsdocOptions === false) return false;
|
|
21
|
-
return true;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const rulesBase = {
|
|
25
|
-
"@typescript-eslint/array-type": [
|
|
26
|
-
"error",
|
|
27
|
-
{
|
|
28
|
-
"default": "generic",
|
|
29
|
-
"readonly": "generic",
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
"brace-style": "off",
|
|
33
|
-
"@typescript-eslint/brace-style": ["error"],
|
|
34
|
-
"@typescript-eslint/naming-convention": ["error"],
|
|
35
|
-
"comma-spacing": "off",
|
|
36
|
-
"@typescript-eslint/comma-spacing": ["error"],
|
|
37
|
-
"@typescript-eslint/consistent-type-assertions": [
|
|
38
|
-
"error",
|
|
39
|
-
{
|
|
40
|
-
"assertionStyle": "as",
|
|
41
|
-
"objectLiteralTypeAssertions": "never",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
"@typescript-eslint/consistent-type-definitions": [
|
|
45
|
-
"error",
|
|
46
|
-
"interface",
|
|
47
|
-
],
|
|
48
|
-
"default-param-last": "off",
|
|
49
|
-
"@typescript-eslint/default-param-last": ["error"],
|
|
50
|
-
"@typescript-eslint/explicit-member-accessibility": ["error"],
|
|
51
|
-
"@typescript-eslint/explicit-module-boundary-types": ["error"],
|
|
52
|
-
"func-call-spacing": "off",
|
|
53
|
-
"@typescript-eslint/func-call-spacing": ["error"],
|
|
54
|
-
"indent": "off",
|
|
55
|
-
"@typescript-eslint/indent": [
|
|
56
|
-
"error",
|
|
57
|
-
indentDepth,
|
|
58
|
-
{
|
|
59
|
-
"FunctionDeclaration": {"parameters": "first"},
|
|
60
|
-
"FunctionExpression": {"parameters": "first"},
|
|
61
|
-
"CallExpression": {"arguments": "first"},
|
|
62
|
-
"ArrayExpression": "first",
|
|
63
|
-
"ignoreComments": true,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
"@typescript-eslint/member-delimiter-style": ["warn"],
|
|
67
|
-
"@typescript-eslint/member-ordering": [
|
|
68
|
-
"warn",
|
|
69
|
-
{
|
|
70
|
-
"default": [
|
|
71
|
-
// Index signature
|
|
72
|
-
"signature",
|
|
73
|
-
|
|
74
|
-
// Fields
|
|
75
|
-
"public-static-field",
|
|
76
|
-
"protected-static-field",
|
|
77
|
-
"private-static-field",
|
|
78
|
-
"#private-static-field",
|
|
79
|
-
|
|
80
|
-
"public-decorated-field",
|
|
81
|
-
"protected-decorated-field",
|
|
82
|
-
"private-decorated-field",
|
|
83
|
-
|
|
84
|
-
"public-instance-field",
|
|
85
|
-
"protected-instance-field",
|
|
86
|
-
"private-instance-field",
|
|
87
|
-
"#private-instance-field",
|
|
88
|
-
|
|
89
|
-
"public-abstract-field",
|
|
90
|
-
"protected-abstract-field",
|
|
91
|
-
|
|
92
|
-
"public-field",
|
|
93
|
-
"protected-field",
|
|
94
|
-
"private-field",
|
|
95
|
-
"#private-field",
|
|
96
|
-
|
|
97
|
-
"static-field",
|
|
98
|
-
"instance-field",
|
|
99
|
-
"abstract-field",
|
|
100
|
-
|
|
101
|
-
"decorated-field",
|
|
102
|
-
|
|
103
|
-
"field",
|
|
104
|
-
|
|
105
|
-
// Constructors
|
|
106
|
-
"static-initialization",
|
|
107
|
-
"public-constructor",
|
|
108
|
-
"protected-constructor",
|
|
109
|
-
"private-constructor",
|
|
110
|
-
|
|
111
|
-
"constructor",
|
|
112
|
-
|
|
113
|
-
// Getters/Setters
|
|
114
|
-
["public-static-get", "public-static-set"],
|
|
115
|
-
["protected-static-get", "protected-static-set"],
|
|
116
|
-
["private-static-get", "private-static-set"],
|
|
117
|
-
["#private-static-get", "#private-static-set"],
|
|
118
|
-
|
|
119
|
-
["public-decorated-get", "public-decorated-set"],
|
|
120
|
-
["protected-decorated-get", "protected-decorated-set"],
|
|
121
|
-
["private-decorated-get", "private-decorated-set"],
|
|
122
|
-
|
|
123
|
-
["public-instance-get", "public-instance-set"],
|
|
124
|
-
["protected-instance-get", "protected-instance-set"],
|
|
125
|
-
["private-instance-get", "private-instance-set"],
|
|
126
|
-
["#private-instance-get", "#private-instance-set"],
|
|
6
|
+
import * as sections from "../sections.js";
|
|
127
7
|
|
|
128
|
-
|
|
129
|
-
["protected-abstract-get", "protected-abstract-set"],
|
|
8
|
+
const filterForFiles = (rules, files) => rules.map(c => ({...c, files}));
|
|
130
9
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"public-static-method",
|
|
146
|
-
"protected-static-method",
|
|
147
|
-
"private-static-method",
|
|
148
|
-
"#private-static-method",
|
|
149
|
-
|
|
150
|
-
"public-decorated-method",
|
|
151
|
-
"protected-decorated-method",
|
|
152
|
-
"private-decorated-method",
|
|
153
|
-
|
|
154
|
-
"public-instance-method",
|
|
155
|
-
"protected-instance-method",
|
|
156
|
-
"private-instance-method",
|
|
157
|
-
"#private-instance-method",
|
|
158
|
-
|
|
159
|
-
"public-abstract-method",
|
|
160
|
-
"protected-abstract-method",
|
|
161
|
-
|
|
162
|
-
"public-method",
|
|
163
|
-
"protected-method",
|
|
164
|
-
"private-method",
|
|
165
|
-
"#private-method",
|
|
166
|
-
|
|
167
|
-
"static-method",
|
|
168
|
-
"instance-method",
|
|
169
|
-
"abstract-method",
|
|
170
|
-
|
|
171
|
-
"decorated-method",
|
|
172
|
-
|
|
173
|
-
"method",
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
"no-array-constructor": "off",
|
|
178
|
-
"@typescript-eslint/no-array-constructor": ["warn"],
|
|
179
|
-
"@typescript-eslint/no-dupe-class-members": ["error"],
|
|
180
|
-
"@typescript-eslint/no-dynamic-delete": ["error"],
|
|
181
|
-
"no-empty-function": "off",
|
|
182
|
-
"@typescript-eslint/no-empty-function": [
|
|
183
|
-
"warn",
|
|
184
|
-
{
|
|
185
|
-
"allow": [
|
|
186
|
-
"arrowFunctions",
|
|
187
|
-
"protected-constructors",
|
|
188
|
-
"private-constructors",
|
|
189
|
-
],
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
"@typescript-eslint/no-empty-interface": [
|
|
193
|
-
"warn",
|
|
194
|
-
{"allowSingleExtends": true},
|
|
195
|
-
],
|
|
196
|
-
"@typescript-eslint/no-explicit-any": ["error"],
|
|
197
|
-
"@typescript-eslint/no-extra-non-null-assertion": ["error"],
|
|
198
|
-
"no-extra-parens": "off",
|
|
199
|
-
"@typescript-eslint/no-extra-parens": [
|
|
200
|
-
"warn",
|
|
201
|
-
"functions",
|
|
202
|
-
],
|
|
203
|
-
"no-extra-semi": "off",
|
|
204
|
-
"@typescript-eslint/no-extra-semi": ["error"],
|
|
205
|
-
"@typescript-eslint/no-extraneous-class": ["error"],
|
|
206
|
-
"no-magic-numbers": "off",
|
|
207
|
-
"@typescript-eslint/no-magic-numbers": [
|
|
208
|
-
"error",
|
|
209
|
-
{
|
|
210
|
-
"ignore": [
|
|
211
|
-
0,
|
|
212
|
-
1,
|
|
213
|
-
-1,
|
|
10
|
+
/**
|
|
11
|
+
* Apply the recommended typescript-eslint configuration plus KeeeX tweaks.
|
|
12
|
+
*
|
|
13
|
+
* @param configResult - The eslint configuration object currently being built.
|
|
14
|
+
*/
|
|
15
|
+
// eslint-disable-next-line max-lines-per-function
|
|
16
|
+
export const apply = (configResult, eslintConfig) => {
|
|
17
|
+
if (!eslintConfig.typescript) return;
|
|
18
|
+
const tsExts = ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"];
|
|
19
|
+
configResult.push(
|
|
20
|
+
...filterForFiles(
|
|
21
|
+
[
|
|
22
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
23
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
214
24
|
],
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
"@typescript-eslint/no-require-imports": ["error"],
|
|
226
|
-
"@typescript-eslint/no-this-alias": ["error"],
|
|
227
|
-
"@typescript-eslint/no-type-alias": [
|
|
228
|
-
"error",
|
|
229
|
-
{
|
|
230
|
-
"allowAliases": "always",
|
|
231
|
-
"allowCallbacks": "always",
|
|
232
|
-
"allowMappedTypes": "always",
|
|
233
|
-
"allowGenerics": "always",
|
|
234
|
-
"allowConditionalTypes": "always",
|
|
235
|
-
},
|
|
236
|
-
],
|
|
237
|
-
"@typescript-eslint/no-unnecessary-boolean-literal-compare": ["error"],
|
|
238
|
-
"no-unused-expressions": "off",
|
|
239
|
-
"@typescript-eslint/no-unused-expressions": [
|
|
240
|
-
"error",
|
|
25
|
+
tsExts,
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
if (!eslintConfig.noBase) configResult.push(tseslint.configs.eslintRecommended);
|
|
29
|
+
const section = sections.getNamedSection(configResult, "keeex/typescript-parserOptions");
|
|
30
|
+
section.files = tsExts;
|
|
31
|
+
sections.sectionAddOption(
|
|
32
|
+
section,
|
|
33
|
+
"languageOptions",
|
|
34
|
+
"parserOptions",
|
|
241
35
|
{
|
|
242
|
-
|
|
243
|
-
|
|
36
|
+
projectService: true,
|
|
37
|
+
tsConfigRootDir: import.meta.dirname,
|
|
244
38
|
},
|
|
245
|
-
|
|
246
|
-
"
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
"@typescript-eslint/no-useless-constructor": ["warn"],
|
|
253
|
-
"@typescript-eslint/prefer-as-const": ["error"],
|
|
254
|
-
"@typescript-eslint/prefer-for-of": ["error"],
|
|
255
|
-
"@typescript-eslint/prefer-optional-chain": ["warn"],
|
|
256
|
-
"quotes": "off",
|
|
257
|
-
"@typescript-eslint/quotes": ["error"],
|
|
258
|
-
"semi": "off",
|
|
259
|
-
"@typescript-eslint/semi": ["error"],
|
|
260
|
-
"space-before-function-paren": "off",
|
|
261
|
-
"@typescript-eslint/space-before-function-paren": [
|
|
262
|
-
"error",
|
|
39
|
+
);
|
|
40
|
+
const override = sections.getNamedSection(configResult, "keeex/typescript-override");
|
|
41
|
+
override.files = tsExts;
|
|
42
|
+
const eslintOverride = sections.getNamedSection(configResult, "keeex/eslint-override");
|
|
43
|
+
const overrule = (name, defaultValue = "error") => sections.configureRules(
|
|
44
|
+
override,
|
|
45
|
+
"",
|
|
263
46
|
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
"asyncArrow": "always",
|
|
47
|
+
[name]: "off",
|
|
48
|
+
[`@typescript-eslint/${name}`]: eslintOverride.rules?.[name] ?? defaultValue,
|
|
267
49
|
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
module.exports = {
|
|
273
|
-
dependencies: ["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"],
|
|
274
|
-
overrides: [
|
|
50
|
+
);
|
|
51
|
+
sections.configureRules(
|
|
52
|
+
override,
|
|
53
|
+
"@typescript-eslint",
|
|
275
54
|
{
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const typescriptBase = [
|
|
292
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
293
|
-
"plugin:@typescript-eslint/recommended",
|
|
294
|
-
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
|
295
|
-
];
|
|
296
|
-
const typeExtends = useTypes(presetOptions)
|
|
297
|
-
? extendsBaseType
|
|
298
|
-
: [];
|
|
299
|
-
const importExtends = allOptions["import"]
|
|
300
|
-
? ["plugin:i/typescript"]
|
|
301
|
-
: [];
|
|
302
|
-
return [
|
|
303
|
-
...typescriptBase,
|
|
304
|
-
...typeExtends,
|
|
305
|
-
...importExtends,
|
|
306
|
-
];
|
|
307
|
-
},
|
|
308
|
-
plugins: (presetOptions, allOptions, dependencies) => {
|
|
309
|
-
if (useTSDoc(allOptions)) {
|
|
310
|
-
if (dependencies) dependencies.add("eslint-plugin-tsdoc");
|
|
311
|
-
return ["eslint-plugin-tsdoc"];
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
rules: (presetOptions, allOptions) => {
|
|
315
|
-
// There seem to be no way for now to have import understand that ".js" imports should refer
|
|
316
|
-
// to ".ts" files.
|
|
317
|
-
// Either it complains about needing the ".ts" suffix (which is wrong) or it enforces having
|
|
318
|
-
// an extension, but doesn't actually resolve the file (since we disable the ts-specific
|
|
319
|
-
// resolver).
|
|
320
|
-
// If this change in the future, restore full ts-resolver support from import plugin.
|
|
321
|
-
const importOverride = allOptions.import
|
|
322
|
-
? {
|
|
323
|
-
"i/no-unresolved": "off",
|
|
324
|
-
"i/no-cycle": "off",
|
|
325
|
-
"i/named": "off",
|
|
326
|
-
}
|
|
327
|
-
: undefined;
|
|
328
|
-
const typesOverride = useTypes(presetOptions)
|
|
329
|
-
? rulesType
|
|
330
|
-
: undefined;
|
|
331
|
-
const deprecationOverride = useDeprecation(presetOptions, allOptions)
|
|
332
|
-
? {"deprecation/deprecation": "warn"}
|
|
333
|
-
: undefined;
|
|
334
|
-
const reactOverride = allOptions.jsx
|
|
335
|
-
? {"react/sort-comp": "off"}
|
|
336
|
-
: undefined;
|
|
337
|
-
const tsdoc = useTSDoc(allOptions)
|
|
338
|
-
? {"tsdoc/syntax": "warn"}
|
|
339
|
-
: undefined;
|
|
340
|
-
return {
|
|
341
|
-
...rulesBase,
|
|
342
|
-
...tsdoc,
|
|
343
|
-
...typesOverride,
|
|
344
|
-
...importOverride,
|
|
345
|
-
...reactOverride,
|
|
346
|
-
...deprecationOverride,
|
|
347
|
-
};
|
|
348
|
-
},
|
|
55
|
+
"array-type": ["error", {default: "generic", readonly: "generic"}],
|
|
56
|
+
"explicit-function-return-type": "warn",
|
|
57
|
+
"explicit-member-accessibility": "error",
|
|
58
|
+
"explicit-module-boundary-types": "error",
|
|
59
|
+
"naming-convention": "error",
|
|
60
|
+
"no-deprecated": "warn",
|
|
61
|
+
"no-dynamic-delete": "warn",
|
|
62
|
+
"no-unnecessary-boolean-literal-compare": "warn",
|
|
63
|
+
"no-unnecessary-condition": ["warn", {allowConstantLoopConditions: true}],
|
|
64
|
+
"no-unnecessary-template-expression": "warn",
|
|
65
|
+
"parameter-properties": "error",
|
|
66
|
+
"prefer-readonly": "warn",
|
|
67
|
+
"prefer-return-this-type": "warn",
|
|
68
|
+
"return-await": "error",
|
|
69
|
+
"unified-signatures": "error",
|
|
349
70
|
},
|
|
350
|
-
|
|
71
|
+
);
|
|
72
|
+
for (const baseRule of [
|
|
73
|
+
"class-methods-use-this",
|
|
74
|
+
"default-param-last",
|
|
75
|
+
"dot-notation",
|
|
76
|
+
"init-declarations",
|
|
77
|
+
"max-params",
|
|
78
|
+
"no-array-constructor",
|
|
79
|
+
"no-implied-eval",
|
|
80
|
+
"no-loop-func",
|
|
81
|
+
"no-magic-numbers",
|
|
82
|
+
"no-shadow",
|
|
83
|
+
"no-unused-expressions",
|
|
84
|
+
"no-unused-vars",
|
|
85
|
+
"no-use-before-define",
|
|
86
|
+
"no-useless-constructor",
|
|
87
|
+
"prefer-destructuring",
|
|
88
|
+
"prefer-promise-reject-errors",
|
|
89
|
+
"require-await",
|
|
90
|
+
]) {
|
|
91
|
+
overrule(baseRule);
|
|
92
|
+
}
|
|
93
|
+
sections.configureRules(override, "", {"no-return-await": "off"});
|
|
94
|
+
configResult.push({
|
|
95
|
+
files: tsExts,
|
|
96
|
+
plugins: {"tsdoc": tsdocPlugin},
|
|
97
|
+
rules: {"tsdoc/syntax": "warn"},
|
|
98
|
+
});
|
|
351
99
|
};
|