@typescript-eslint/eslint-plugin 8.67.1-alpha.11 → 8.67.1-alpha.13
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,4 +1,4 @@
|
|
|
1
|
-
export type MessageIds = 'omittingRestParameter' | 'omittingSingleParameter' | 'singleParameterDifference';
|
|
1
|
+
export type MessageIds = 'allParametersAreSame' | 'omittingRestParameter' | 'omittingSingleParameter' | 'singleParameterDifference';
|
|
2
2
|
export type Options = [
|
|
3
3
|
{
|
|
4
4
|
ignoreDifferentlyNamedParameters?: boolean;
|
|
@@ -12,6 +12,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
12
12
|
recommended: 'strict',
|
|
13
13
|
},
|
|
14
14
|
messages: {
|
|
15
|
+
allParametersAreSame: '{{failureStringStart}} with identical parameters.',
|
|
15
16
|
omittingRestParameter: '{{failureStringStart}} with a rest parameter.',
|
|
16
17
|
omittingSingleParameter: '{{failureStringStart}} with an optional parameter.',
|
|
17
18
|
singleParameterDifference: '{{failureStringStart}} taking `{{types}}`.',
|
|
@@ -85,7 +86,24 @@ exports.default = (0, util_1.createRule)({
|
|
|
85
86
|
failureStringStart: failureStringStart(lineOfOtherOverload),
|
|
86
87
|
},
|
|
87
88
|
});
|
|
89
|
+
break;
|
|
88
90
|
}
|
|
91
|
+
case 'all-parameters-are-same': {
|
|
92
|
+
const { signature0, signature1 } = unify;
|
|
93
|
+
const lineOfOtherOverload = only2
|
|
94
|
+
? undefined
|
|
95
|
+
: signature0.loc.start.line;
|
|
96
|
+
context.report({
|
|
97
|
+
node: signature1,
|
|
98
|
+
messageId: 'allParametersAreSame',
|
|
99
|
+
data: {
|
|
100
|
+
failureStringStart: failureStringStart(lineOfOtherOverload),
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
default:
|
|
106
|
+
unify;
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
}
|
|
@@ -109,7 +127,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
109
127
|
return undefined;
|
|
110
128
|
}
|
|
111
129
|
return a.params.length === b.params.length
|
|
112
|
-
?
|
|
130
|
+
? signaturesHaveSameAmountOfParameters(a, b)
|
|
113
131
|
: signaturesDifferByOptionalOrRestParameter(a, b);
|
|
114
132
|
}
|
|
115
133
|
function signaturesCanBeUnified(a, b, isTypeParameter) {
|
|
@@ -140,8 +158,11 @@ exports.default = (0, util_1.createRule)({
|
|
|
140
158
|
signatureUsesTypeParameter(a, isTypeParameter) ===
|
|
141
159
|
signatureUsesTypeParameter(b, isTypeParameter));
|
|
142
160
|
}
|
|
143
|
-
/**
|
|
144
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Detect no difference, i.e. `a(x: number, y: string)` and `a(x: number, y: string)`,
|
|
163
|
+
* or one param difference, i.e. `a(x: number, y: number, z: number)` and `a(x: number, y: string, z: number)`.
|
|
164
|
+
*/
|
|
165
|
+
function signaturesHaveSameAmountOfParameters(signature0, signature1) {
|
|
145
166
|
const types1 = signature0.params;
|
|
146
167
|
const types2 = signature1.params;
|
|
147
168
|
const firstParam1 = types1[0];
|
|
@@ -152,7 +173,11 @@ exports.default = (0, util_1.createRule)({
|
|
|
152
173
|
}
|
|
153
174
|
const index = getIndexOfFirstDifference(types1, types2, parametersAreEqual);
|
|
154
175
|
if (index == null) {
|
|
155
|
-
return
|
|
176
|
+
return {
|
|
177
|
+
kind: 'all-parameters-are-same',
|
|
178
|
+
signature0,
|
|
179
|
+
signature1,
|
|
180
|
+
};
|
|
156
181
|
}
|
|
157
182
|
// If remaining arrays are equal, the signatures differ by just one parameter type
|
|
158
183
|
if (!(0, util_1.arraysAreEqual)(types1.slice(index + 1), types2.slice(index + 1), parametersAreEqual)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.67.1-alpha.
|
|
3
|
+
"version": "8.67.1-alpha.13",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"ignore": "^7.0.5",
|
|
50
50
|
"natural-compare": "^1.4.0",
|
|
51
51
|
"ts-api-utils": "^2.5.0",
|
|
52
|
-
"@typescript-eslint/scope-manager": "8.67.1-alpha.
|
|
53
|
-
"@typescript-eslint/
|
|
54
|
-
"@typescript-eslint/utils": "8.67.1-alpha.
|
|
55
|
-
"@typescript-eslint/
|
|
52
|
+
"@typescript-eslint/scope-manager": "8.67.1-alpha.13",
|
|
53
|
+
"@typescript-eslint/visitor-keys": "8.67.1-alpha.13",
|
|
54
|
+
"@typescript-eslint/type-utils": "8.67.1-alpha.13",
|
|
55
|
+
"@typescript-eslint/utils": "8.67.1-alpha.13"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/json-schema": "^7.0.15",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"typescript": ">=4.8.4 <6.1.0",
|
|
77
77
|
"unist-util-visit": "^5.0.0",
|
|
78
78
|
"vitest": "^4.0.18",
|
|
79
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.67.1-alpha.
|
|
80
|
-
"@typescript-eslint/rule-tester": "8.67.1-alpha.
|
|
79
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.67.1-alpha.13",
|
|
80
|
+
"@typescript-eslint/rule-tester": "8.67.1-alpha.13"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
84
84
|
"typescript": ">=4.8.4 <6.1.0",
|
|
85
|
-
"@typescript-eslint/parser": "^8.67.1-alpha.
|
|
85
|
+
"@typescript-eslint/parser": "^8.67.1-alpha.13"
|
|
86
86
|
},
|
|
87
87
|
"funding": {
|
|
88
88
|
"type": "opencollective",
|