@virmator/lint 14.27.4 → 14.28.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.
|
@@ -13,6 +13,15 @@ function isInlineCallbackArgument(node) {
|
|
|
13
13
|
}
|
|
14
14
|
return parent.arguments.includes(node);
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The typescript-eslint parser emits `TSParameterProperty` nodes for constructor parameters that
|
|
18
|
+
* use an accessibility (`public`/`private`/`protected`) or `readonly` modifier. These are absent
|
|
19
|
+
* from the base estree `Pattern` union. Such parameters declare class fields rather than plain
|
|
20
|
+
* positional arguments, so the rule ignores them when counting/comparing parameters.
|
|
21
|
+
*/
|
|
22
|
+
function isParameterProperty(param) {
|
|
23
|
+
return param.type === 'TSParameterProperty';
|
|
24
|
+
}
|
|
16
25
|
/**
|
|
17
26
|
* Excludes a leading `this` parameter (which is a type-only annotation in TypeScript, not a real
|
|
18
27
|
* positional argument).
|
|
@@ -110,15 +119,28 @@ const rule = {
|
|
|
110
119
|
return;
|
|
111
120
|
}
|
|
112
121
|
const realParams = getRealParams(node.params);
|
|
113
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Constructor parameter properties (those with an access modifier) declare class fields
|
|
124
|
+
* rather than plain positional arguments, so they are excluded from the count and
|
|
125
|
+
* duplicate-type comparison.
|
|
126
|
+
*/
|
|
127
|
+
const consideredParams = realParams.filter((param) => !isParameterProperty(param));
|
|
128
|
+
const messageId = consideredParams.length > 3
|
|
114
129
|
? 'tooManyPositionalParams'
|
|
115
|
-
: hasDuplicateType(
|
|
130
|
+
: hasDuplicateType(consideredParams, sourceCode)
|
|
116
131
|
? 'duplicateParamType'
|
|
117
132
|
: undefined;
|
|
118
133
|
if (!messageId) {
|
|
119
134
|
return;
|
|
120
135
|
}
|
|
121
|
-
|
|
136
|
+
/**
|
|
137
|
+
* A params object can only wrap the plain parameters. When parameter properties are
|
|
138
|
+
* interspersed there is no safe single-range replacement, so the fix is omitted and the
|
|
139
|
+
* developer resolves it manually.
|
|
140
|
+
*/
|
|
141
|
+
const fix = consideredParams.length === realParams.length
|
|
142
|
+
? buildParamsObjectFix(consideredParams, sourceCode)
|
|
143
|
+
: undefined;
|
|
122
144
|
context.report({
|
|
123
145
|
node,
|
|
124
146
|
messageId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/lint",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.28.0",
|
|
4
4
|
"description": "Default ESLint linting plugin for virmator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"virmator",
|
|
@@ -32,32 +32,32 @@
|
|
|
32
32
|
"test:update": "npm test update"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@augment-vir/assert": "^32.
|
|
36
|
-
"@augment-vir/common": "^32.
|
|
37
|
-
"@augment-vir/node": "^32.
|
|
38
|
-
"@virmator/core": "^14.
|
|
35
|
+
"@augment-vir/assert": "^32.1.0",
|
|
36
|
+
"@augment-vir/common": "^32.1.0",
|
|
37
|
+
"@augment-vir/node": "^32.1.0",
|
|
38
|
+
"@virmator/core": "^14.28.0",
|
|
39
39
|
"globals": "^17.7.0",
|
|
40
40
|
"jiti": "^2.7.0",
|
|
41
41
|
"mri": "^1.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@augment-vir/test": "^32.
|
|
44
|
+
"@augment-vir/test": "^32.1.0",
|
|
45
45
|
"@eslint/js": "10.0.1",
|
|
46
46
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
47
47
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
48
48
|
"@types/estree": "^1.0.9",
|
|
49
|
-
"@types/node": "^26.
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
49
|
+
"@types/node": "^26.1.1",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^8.63.0",
|
|
51
51
|
"c8": "^11.0.0",
|
|
52
|
-
"eslint": "^10.
|
|
52
|
+
"eslint": "^10.6.0",
|
|
53
53
|
"eslint-config-prettier": "^10.1.8",
|
|
54
|
-
"eslint-plugin-jsdoc": "^63.0.
|
|
55
|
-
"eslint-plugin-playwright": "^2.10.
|
|
54
|
+
"eslint-plugin-jsdoc": "^63.0.12",
|
|
55
|
+
"eslint-plugin-playwright": "^2.10.5",
|
|
56
56
|
"eslint-plugin-prettier": "^5.5.6",
|
|
57
57
|
"eslint-plugin-sonarjs": "^4.1.0",
|
|
58
|
-
"eslint-plugin-unicorn": "^
|
|
58
|
+
"eslint-plugin-unicorn": "^71.1.0",
|
|
59
59
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
60
|
-
"typescript-eslint": "^8.
|
|
60
|
+
"typescript-eslint": "^8.63.0"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=22"
|
|
@@ -45,6 +45,16 @@ function isInlineCallbackArgument(node: AnyFunctionNode): boolean {
|
|
|
45
45
|
return parent.arguments.includes(node);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The typescript-eslint parser emits `TSParameterProperty` nodes for constructor parameters that
|
|
50
|
+
* use an accessibility (`public`/`private`/`protected`) or `readonly` modifier. These are absent
|
|
51
|
+
* from the base estree `Pattern` union. Such parameters declare class fields rather than plain
|
|
52
|
+
* positional arguments, so the rule ignores them when counting/comparing parameters.
|
|
53
|
+
*/
|
|
54
|
+
function isParameterProperty(param: Pattern): boolean {
|
|
55
|
+
return (param as {type: string}).type === 'TSParameterProperty';
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
/**
|
|
49
59
|
* Excludes a leading `this` parameter (which is a type-only annotation in TypeScript, not a real
|
|
50
60
|
* positional argument).
|
|
@@ -181,11 +191,17 @@ const rule: Rule.RuleModule = {
|
|
|
181
191
|
}
|
|
182
192
|
|
|
183
193
|
const realParams = getRealParams(node.params);
|
|
194
|
+
/**
|
|
195
|
+
* Constructor parameter properties (those with an access modifier) declare class fields
|
|
196
|
+
* rather than plain positional arguments, so they are excluded from the count and
|
|
197
|
+
* duplicate-type comparison.
|
|
198
|
+
*/
|
|
199
|
+
const consideredParams = realParams.filter((param) => !isParameterProperty(param));
|
|
184
200
|
|
|
185
201
|
const messageId =
|
|
186
|
-
|
|
202
|
+
consideredParams.length > 3
|
|
187
203
|
? 'tooManyPositionalParams'
|
|
188
|
-
: hasDuplicateType(
|
|
204
|
+
: hasDuplicateType(consideredParams, sourceCode)
|
|
189
205
|
? 'duplicateParamType'
|
|
190
206
|
: undefined;
|
|
191
207
|
|
|
@@ -193,7 +209,15 @@ const rule: Rule.RuleModule = {
|
|
|
193
209
|
return;
|
|
194
210
|
}
|
|
195
211
|
|
|
196
|
-
|
|
212
|
+
/**
|
|
213
|
+
* A params object can only wrap the plain parameters. When parameter properties are
|
|
214
|
+
* interspersed there is no safe single-range replacement, so the fix is omitted and the
|
|
215
|
+
* developer resolves it manually.
|
|
216
|
+
*/
|
|
217
|
+
const fix =
|
|
218
|
+
consideredParams.length === realParams.length
|
|
219
|
+
? buildParamsObjectFix(consideredParams, sourceCode)
|
|
220
|
+
: undefined;
|
|
197
221
|
|
|
198
222
|
context.report({
|
|
199
223
|
node,
|