@typescript-eslint/eslint-plugin 8.71.2-alpha.4 → 8.71.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.
|
@@ -113,7 +113,8 @@ exports.default = (0, util_1.createRule)({
|
|
|
113
113
|
grandparent.type === utils_1.AST_NODE_TYPES.TSIntersectionType ||
|
|
114
114
|
grandparent.type === utils_1.AST_NODE_TYPES.TSUnionType ||
|
|
115
115
|
grandparent.type === utils_1.AST_NODE_TYPES.TSConditionalType ||
|
|
116
|
-
grandparent.type === utils_1.AST_NODE_TYPES.TSTypeOperator
|
|
116
|
+
grandparent.type === utils_1.AST_NODE_TYPES.TSTypeOperator ||
|
|
117
|
+
grandparent.type === utils_1.AST_NODE_TYPES.TSOptionalType;
|
|
117
118
|
if (isWeakPrecedenceConstraint &&
|
|
118
119
|
isWeakPrecedenceTypeParent) {
|
|
119
120
|
yield fixer.replaceText(referenceNode.parent, `(${constraintText})`);
|
|
@@ -654,7 +654,8 @@ exports.default = (0, util_1.createRule)({
|
|
|
654
654
|
const params = context.sourceCode.getDeclaredVariables(def.node);
|
|
655
655
|
const posteriorParams = params.slice(params.indexOf(variable) + 1);
|
|
656
656
|
// If any used parameters occur after this parameter, do not report.
|
|
657
|
-
return !posteriorParams.some(v => v.
|
|
657
|
+
return !posteriorParams.some(v => v.eslintUsed ||
|
|
658
|
+
v.references.some(ref => !(0, isTypeOnlyReference_1.isTypeOnlyReference)(v, ref)));
|
|
658
659
|
}
|
|
659
660
|
const analysisResults = (0, util_1.collectVariables)(context);
|
|
660
661
|
const variables = [
|
|
@@ -589,8 +589,32 @@ function analyzeChain(context, parserServices, options, node, operator, chain, l
|
|
|
589
589
|
// foo !== null && foo !== undefined
|
|
590
590
|
validatedOperands[validatedOperands.length - 1].comparedName);
|
|
591
591
|
if (comparisonResult === compareNodes_1.NodeComparisonResult.Subset) {
|
|
592
|
-
|
|
593
|
-
|
|
592
|
+
if (operator === '||' &&
|
|
593
|
+
currentOperand.comparisonType ===
|
|
594
|
+
gatherLogicalOperands_1.NullishComparisonType.StrictEqualNull &&
|
|
595
|
+
// A paired `[=== null, === undefined]` operand is semantically safe
|
|
596
|
+
// because it merges to `== null`. Only a lone `=== null` can produce
|
|
597
|
+
// a broken strict-equality check in the merged chain.
|
|
598
|
+
validatedOperands.length === 1 &&
|
|
599
|
+
subChain
|
|
600
|
+
.flat()
|
|
601
|
+
.some(operand => operand.comparisonType ===
|
|
602
|
+
gatherLogicalOperands_1.NullishComparisonType.StrictEqualUndefined)) {
|
|
603
|
+
// For OR chains that contain a `=== undefined` guard anywhere,
|
|
604
|
+
// extending the chain with a lone `=== null` subset changes
|
|
605
|
+
// semantics: when the guarded node is undefined, `node?.child`
|
|
606
|
+
// returns `undefined`, and `undefined === null` is false (strict),
|
|
607
|
+
// but the original `=== undefined` guard was true.
|
|
608
|
+
//
|
|
609
|
+
// e.g. `foo === undefined || foo.bar === null` must NOT merge to
|
|
610
|
+
// `foo?.bar === null`, and neither should a mid-chain form like
|
|
611
|
+
// `a == null || a.b === undefined || a.b.c === null`.
|
|
612
|
+
maybeReportThenReset(validatedOperands);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
// the operands are comparable, so we can continue searching
|
|
616
|
+
subChain.push(currentOperand);
|
|
617
|
+
}
|
|
594
618
|
}
|
|
595
619
|
else if (comparisonResult === compareNodes_1.NodeComparisonResult.Invalid) {
|
|
596
620
|
maybeReportThenReset(validatedOperands);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.71.2-alpha.
|
|
3
|
+
"version": "8.71.2-alpha.5",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@eslint-community/regexpp": "^4.12.2",
|
|
50
|
-
"@typescript-eslint/scope-manager": "8.71.2-alpha.
|
|
51
|
-
"@typescript-eslint/type-utils": "8.71.2-alpha.
|
|
52
|
-
"@typescript-eslint/utils": "8.71.2-alpha.
|
|
53
|
-
"@typescript-eslint/visitor-keys": "8.71.2-alpha.
|
|
50
|
+
"@typescript-eslint/scope-manager": "8.71.2-alpha.5",
|
|
51
|
+
"@typescript-eslint/type-utils": "8.71.2-alpha.5",
|
|
52
|
+
"@typescript-eslint/utils": "8.71.2-alpha.5",
|
|
53
|
+
"@typescript-eslint/visitor-keys": "8.71.2-alpha.5",
|
|
54
54
|
"ignore": "^7.0.5",
|
|
55
55
|
"natural-compare": "^1.4.0",
|
|
56
56
|
"ts-api-utils": "^2.5.0"
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@types/mdast": "^4.0.4",
|
|
61
61
|
"@types/natural-compare": "^1.4.3",
|
|
62
62
|
"@types/react": "^18.3.21",
|
|
63
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.71.2-alpha.
|
|
64
|
-
"@typescript-eslint/rule-tester": "8.71.2-alpha.
|
|
63
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.71.2-alpha.5",
|
|
64
|
+
"@typescript-eslint/rule-tester": "8.71.2-alpha.5",
|
|
65
65
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
66
66
|
"@vitest/coverage-v8": "^4.0.18",
|
|
67
67
|
"ajv": "^6.12.6",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"vitest": "^4.0.18"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@typescript-eslint/parser": "^8.71.2-alpha.
|
|
84
|
+
"@typescript-eslint/parser": "^8.71.2-alpha.5",
|
|
85
85
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
86
86
|
"typescript": ">=4.8.4 <6.1.0"
|
|
87
87
|
},
|