@typescript-eslint/eslint-plugin 8.42.1-alpha.0 → 8.42.1-alpha.10
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/dist/rules/no-confusing-void-expression.d.ts.map +1 -1
- package/dist/rules/no-confusing-void-expression.js +3 -3
- package/dist/rules/no-non-null-assertion.d.ts.map +1 -1
- package/dist/rules/no-non-null-assertion.js +2 -1
- package/dist/rules/no-unnecessary-type-conversion.d.ts.map +1 -1
- package/dist/rules/no-unnecessary-type-conversion.js +37 -1
- package/dist/util/collectUnusedVariables.d.ts.map +1 -1
- package/dist/util/collectUnusedVariables.js +2 -4
- package/package.json +8 -8
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-confusing-void-expression.d.ts","sourceRoot":"","sources":["../../src/rules/no-confusing-void-expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"no-confusing-void-expression.d.ts","sourceRoot":"","sources":["../../src/rules/no-confusing-void-expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,QAAQ,EAET,MAAM,0BAA0B,CAAC;AAoBlC,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,4BAA4B,CAAC,EAAE,OAAO,CAAC;KACxC;CACF,CAAC;AAEF,MAAM,MAAM,SAAS,GACjB,iBAAiB,GACjB,sBAAsB,GACtB,8BAA8B,GAC9B,uBAAuB,GACvB,2BAA2B,GAC3B,+BAA+B,GAC/B,yBAAyB,GACzB,kBAAkB,CAAC;;AAEvB,wBAibG"}
|
@@ -236,7 +236,7 @@ exports.default = (0, util_1.createRule)({
|
|
236
236
|
* @returns Invalid ancestor node if it was found. `null` otherwise.
|
237
237
|
*/
|
238
238
|
function findInvalidAncestor(node) {
|
239
|
-
const parent =
|
239
|
+
const parent = node.parent;
|
240
240
|
if (parent.type === utils_1.AST_NODE_TYPES.SequenceExpression &&
|
241
241
|
node !== parent.expressions[parent.expressions.length - 1]) {
|
242
242
|
return null;
|
@@ -282,13 +282,13 @@ exports.default = (0, util_1.createRule)({
|
|
282
282
|
/** Checks whether the return statement is the last statement in a function body. */
|
283
283
|
function isFinalReturn(node) {
|
284
284
|
// the parent must be a block
|
285
|
-
const block =
|
285
|
+
const block = node.parent;
|
286
286
|
if (block.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
|
287
287
|
// e.g. `if (cond) return;` (not in a block)
|
288
288
|
return false;
|
289
289
|
}
|
290
290
|
// the block's parent must be a function
|
291
|
-
const blockParent =
|
291
|
+
const blockParent = block.parent;
|
292
292
|
if (![
|
293
293
|
utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
|
294
294
|
utils_1.AST_NODE_TYPES.FunctionDeclaration,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-non-null-assertion.d.ts","sourceRoot":"","sources":["../../src/rules/no-non-null-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"no-non-null-assertion.d.ts","sourceRoot":"","sources":["../../src/rules/no-non-null-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAYzD,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,sBAAsB,CAAC;;AAE9D,wBAwGG"}
|
@@ -31,7 +31,8 @@ exports.default = (0, util_1.createRule)({
|
|
31
31
|
return fixer => fixer.remove(nonNullOperator);
|
32
32
|
}
|
33
33
|
if (node.parent.type === utils_1.AST_NODE_TYPES.MemberExpression &&
|
34
|
-
node.parent.object === node
|
34
|
+
node.parent.object === node &&
|
35
|
+
!(0, util_1.isAssignee)(node.parent)) {
|
35
36
|
if (!node.parent.optional) {
|
36
37
|
if (node.parent.computed) {
|
37
38
|
// it is x![y]?.z
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-unnecessary-type-conversion.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-conversion.ts"],"names":[],"mappings":"AAgBA,KAAK,UAAU,GACX,eAAe,GACf,kBAAkB,GAClB,2BAA2B,CAAC;;AAEhC,
|
1
|
+
{"version":3,"file":"no-unnecessary-type-conversion.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-conversion.ts"],"names":[],"mappings":"AAgBA,KAAK,UAAU,GACX,eAAe,GACf,kBAAkB,GAClB,2BAA2B,CAAC;;AAEhC,wBA0XG"}
|
@@ -300,7 +300,43 @@ exports.default = (0, util_1.createRule)({
|
|
300
300
|
handleUnaryOperator(node, ts.TypeFlags.NumberLike, 'number', 'Using the unary + operator on a number', false);
|
301
301
|
},
|
302
302
|
'UnaryExpression[operator = "~"] > UnaryExpression[operator = "~"]'(node) {
|
303
|
-
|
303
|
+
const outerNode = node.parent;
|
304
|
+
const type = services.getTypeAtLocation(node.argument);
|
305
|
+
if (tsutils.unionConstituents(type).every(t => {
|
306
|
+
return ((0, util_1.isTypeFlagSet)(t, ts.TypeFlags.NumberLiteral) &&
|
307
|
+
Number.isInteger(t.value));
|
308
|
+
})) {
|
309
|
+
const wrappingFixerParams = {
|
310
|
+
node: outerNode,
|
311
|
+
innerNode: [node.argument],
|
312
|
+
sourceCode: context.sourceCode,
|
313
|
+
};
|
314
|
+
context.report({
|
315
|
+
loc: {
|
316
|
+
start: outerNode.loc.start,
|
317
|
+
end: {
|
318
|
+
column: node.loc.start.column + 1,
|
319
|
+
line: node.loc.start.line,
|
320
|
+
},
|
321
|
+
},
|
322
|
+
messageId: 'unnecessaryTypeConversion',
|
323
|
+
data: { type: 'number', violation: 'Using ~~ on an integer' },
|
324
|
+
suggest: [
|
325
|
+
{
|
326
|
+
messageId: 'suggestRemove',
|
327
|
+
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
|
328
|
+
},
|
329
|
+
{
|
330
|
+
messageId: 'suggestSatisfies',
|
331
|
+
data: { type: 'number' },
|
332
|
+
fix: (0, util_1.getWrappingFixer)({
|
333
|
+
...wrappingFixerParams,
|
334
|
+
wrap: expr => `${expr} satisfies number`,
|
335
|
+
}),
|
336
|
+
},
|
337
|
+
],
|
338
|
+
});
|
339
|
+
}
|
304
340
|
},
|
305
341
|
};
|
306
342
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collectUnusedVariables.d.ts","sourceRoot":"","sources":["../../src/util/collectUnusedVariables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,EAIL,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAKlC,UAAU,gBAAgB;IACxB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IACrD,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;CACpD;
|
1
|
+
{"version":3,"file":"collectUnusedVariables.d.ts","sourceRoot":"","sources":["../../src/util/collectUnusedVariables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,EAIL,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAKlC,UAAU,gBAAgB;IACxB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IACrD,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;CACpD;AAixBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,SAAS,MAAM,EACzB,OAAO,SAAS,SAAS,OAAO,EAAE,EAElC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,GAC3D,gBAAgB,CAQlB"}
|
@@ -306,8 +306,8 @@ function isMergableExported(variable) {
|
|
306
306
|
continue;
|
307
307
|
}
|
308
308
|
if ((MERGABLE_TYPES.has(def.node.type) &&
|
309
|
-
def.node.parent
|
310
|
-
def.node.parent
|
309
|
+
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration) ||
|
310
|
+
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
311
311
|
return true;
|
312
312
|
}
|
313
313
|
}
|
@@ -322,13 +322,11 @@ function isExported(variable) {
|
|
322
322
|
return variable.defs.some(definition => {
|
323
323
|
let node = definition.node;
|
324
324
|
if (node.type === utils_1.AST_NODE_TYPES.VariableDeclarator) {
|
325
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
326
325
|
node = node.parent;
|
327
326
|
}
|
328
327
|
else if (definition.type === utils_1.TSESLint.Scope.DefinitionType.Parameter) {
|
329
328
|
return false;
|
330
329
|
}
|
331
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
332
330
|
return node.parent.type.startsWith('Export');
|
333
331
|
});
|
334
332
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.42.1-alpha.
|
3
|
+
"version": "8.42.1-alpha.10",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -59,10 +59,10 @@
|
|
59
59
|
},
|
60
60
|
"dependencies": {
|
61
61
|
"@eslint-community/regexpp": "^4.10.0",
|
62
|
-
"@typescript-eslint/scope-manager": "8.42.1-alpha.
|
63
|
-
"@typescript-eslint/type-utils": "8.42.1-alpha.
|
64
|
-
"@typescript-eslint/utils": "8.42.1-alpha.
|
65
|
-
"@typescript-eslint/visitor-keys": "8.42.1-alpha.
|
62
|
+
"@typescript-eslint/scope-manager": "8.42.1-alpha.10",
|
63
|
+
"@typescript-eslint/type-utils": "8.42.1-alpha.10",
|
64
|
+
"@typescript-eslint/utils": "8.42.1-alpha.10",
|
65
|
+
"@typescript-eslint/visitor-keys": "8.42.1-alpha.10",
|
66
66
|
"graphemer": "^1.4.0",
|
67
67
|
"ignore": "^7.0.0",
|
68
68
|
"natural-compare": "^1.4.0",
|
@@ -71,8 +71,8 @@
|
|
71
71
|
"devDependencies": {
|
72
72
|
"@types/mdast": "^4.0.3",
|
73
73
|
"@types/natural-compare": "*",
|
74
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.42.1-alpha.
|
75
|
-
"@typescript-eslint/rule-tester": "8.42.1-alpha.
|
74
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.42.1-alpha.10",
|
75
|
+
"@typescript-eslint/rule-tester": "8.42.1-alpha.10",
|
76
76
|
"@vitest/coverage-v8": "^3.1.3",
|
77
77
|
"ajv": "^6.12.6",
|
78
78
|
"cross-fetch": "*",
|
@@ -92,7 +92,7 @@
|
|
92
92
|
"vitest": "^3.1.3"
|
93
93
|
},
|
94
94
|
"peerDependencies": {
|
95
|
-
"@typescript-eslint/parser": "^8.42.1-alpha.
|
95
|
+
"@typescript-eslint/parser": "^8.42.1-alpha.10",
|
96
96
|
"eslint": "^8.57.0 || ^9.0.0",
|
97
97
|
"typescript": ">=4.8.4 <6.0.0"
|
98
98
|
},
|