@typescript-eslint/eslint-plugin 8.31.2-alpha.4 → 8.31.2-alpha.5
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unified-signatures.d.ts","sourceRoot":"","sources":["../../src/rules/unified-signatures.ts"],"names":[],"mappings":"AAuDA,MAAM,MAAM,UAAU,GAClB,uBAAuB,GACvB,yBAAyB,GACzB,2BAA2B,CAAC;AAEhC,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,gCAAgC,CAAC,EAAE,OAAO,CAAC;QAC3C,iCAAiC,CAAC,EAAE,OAAO,CAAC;KAC7C;CACF,CAAC;;AAEF,
|
1
|
+
{"version":3,"file":"unified-signatures.d.ts","sourceRoot":"","sources":["../../src/rules/unified-signatures.ts"],"names":[],"mappings":"AAuDA,MAAM,MAAM,UAAU,GAClB,uBAAuB,GACvB,yBAAyB,GACzB,2BAA2B,CAAC;AAEhC,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,gCAAgC,CAAC,EAAE,OAAO,CAAC;QAC3C,iCAAiC,CAAC,EAAE,OAAO,CAAC;KAC7C;CACF,CAAC;;AAEF,wBA8kBG"}
|
@@ -147,6 +147,12 @@ exports.default = (0, util_1.createRule)({
|
|
147
147
|
}
|
148
148
|
/** Detect `a(x: number, y: number, z: number)` and `a(x: number, y: string, z: number)`. */
|
149
149
|
function signaturesDifferBySingleParameter(types1, types2) {
|
150
|
+
const firstParam1 = types1[0];
|
151
|
+
const firstParam2 = types2[0];
|
152
|
+
// exempt signatures with `this: void` from the rule
|
153
|
+
if (isThisVoidParam(firstParam1) || isThisVoidParam(firstParam2)) {
|
154
|
+
return undefined;
|
155
|
+
}
|
150
156
|
const index = getIndexOfFirstDifference(types1, types2, parametersAreEqual);
|
151
157
|
if (index == null) {
|
152
158
|
return undefined;
|
@@ -164,6 +170,16 @@ exports.default = (0, util_1.createRule)({
|
|
164
170
|
? { kind: 'single-parameter-difference', p0: a, p1: b }
|
165
171
|
: undefined;
|
166
172
|
}
|
173
|
+
function isThisParam(param) {
|
174
|
+
return (param != null &&
|
175
|
+
param.type === utils_1.AST_NODE_TYPES.Identifier &&
|
176
|
+
param.name === 'this');
|
177
|
+
}
|
178
|
+
function isThisVoidParam(param) {
|
179
|
+
return (isThisParam(param) &&
|
180
|
+
param.typeAnnotation?.typeAnnotation.type ===
|
181
|
+
utils_1.AST_NODE_TYPES.TSVoidKeyword);
|
182
|
+
}
|
167
183
|
/**
|
168
184
|
* Detect `a(): void` and `a(x: number): void`.
|
169
185
|
* Returns the parameter declaration (`x: number` in this example) that should be optional/rest, and overload it's a part of.
|
@@ -175,6 +191,17 @@ exports.default = (0, util_1.createRule)({
|
|
175
191
|
const longer = sig1.length < sig2.length ? sig2 : sig1;
|
176
192
|
const shorter = sig1.length < sig2.length ? sig1 : sig2;
|
177
193
|
const shorterSig = sig1.length < sig2.length ? a : b;
|
194
|
+
const firstParam1 = sig1.at(0);
|
195
|
+
const firstParam2 = sig2.at(0);
|
196
|
+
// If one signature has explicit this type and another doesn't, they can't
|
197
|
+
// be unified.
|
198
|
+
if (isThisParam(firstParam1) !== isThisParam(firstParam2)) {
|
199
|
+
return undefined;
|
200
|
+
}
|
201
|
+
// exempt signatures with `this: void` from the rule
|
202
|
+
if (isThisVoidParam(firstParam1) || isThisVoidParam(firstParam2)) {
|
203
|
+
return undefined;
|
204
|
+
}
|
178
205
|
// If one is has 2+ parameters more than the other, they must all be optional/rest.
|
179
206
|
// Differ by optional parameters: f() and f(x), f() and f(x, ?y, ...z)
|
180
207
|
// Not allowed: f() and f(x, y)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.31.2-alpha.
|
3
|
+
"version": "8.31.2-alpha.5",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -62,10 +62,10 @@
|
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
64
|
"@eslint-community/regexpp": "^4.10.0",
|
65
|
-
"@typescript-eslint/scope-manager": "8.31.2-alpha.
|
66
|
-
"@typescript-eslint/type-utils": "8.31.2-alpha.
|
67
|
-
"@typescript-eslint/utils": "8.31.2-alpha.
|
68
|
-
"@typescript-eslint/visitor-keys": "8.31.2-alpha.
|
65
|
+
"@typescript-eslint/scope-manager": "8.31.2-alpha.5",
|
66
|
+
"@typescript-eslint/type-utils": "8.31.2-alpha.5",
|
67
|
+
"@typescript-eslint/utils": "8.31.2-alpha.5",
|
68
|
+
"@typescript-eslint/visitor-keys": "8.31.2-alpha.5",
|
69
69
|
"graphemer": "^1.4.0",
|
70
70
|
"ignore": "^5.3.1",
|
71
71
|
"natural-compare": "^1.4.0",
|
@@ -75,8 +75,8 @@
|
|
75
75
|
"@types/marked": "^5.0.2",
|
76
76
|
"@types/mdast": "^4.0.3",
|
77
77
|
"@types/natural-compare": "*",
|
78
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.31.2-alpha.
|
79
|
-
"@typescript-eslint/rule-tester": "8.31.2-alpha.
|
78
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.31.2-alpha.5",
|
79
|
+
"@typescript-eslint/rule-tester": "8.31.2-alpha.5",
|
80
80
|
"@vitest/coverage-v8": "^3.1.1",
|
81
81
|
"ajv": "^6.12.6",
|
82
82
|
"cross-fetch": "*",
|