eslint-plugin-react-x 1.37.1-beta.3 → 1.37.1-next.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.
- package/dist/index.js +14 -14
- package/dist/index.mjs +16 -16
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -136,7 +136,7 @@ var settings3 = {
|
|
|
136
136
|
|
|
137
137
|
// package.json
|
|
138
138
|
var name4 = "eslint-plugin-react-x";
|
|
139
|
-
var version = "1.37.1-
|
|
139
|
+
var version = "1.37.1-next.0";
|
|
140
140
|
var createRule = shared.createRuleForPlugin("x");
|
|
141
141
|
|
|
142
142
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -414,7 +414,6 @@ var no_array_index_key_default = createRule({
|
|
|
414
414
|
defaultOptions: []
|
|
415
415
|
});
|
|
416
416
|
function create4(context) {
|
|
417
|
-
const report = shared.createReport(context);
|
|
418
417
|
const indexParamNames = [];
|
|
419
418
|
function isArrayIndex(node) {
|
|
420
419
|
return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
@@ -491,7 +490,7 @@ function create4(context) {
|
|
|
491
490
|
if (!("value" in prop)) {
|
|
492
491
|
continue;
|
|
493
492
|
}
|
|
494
|
-
getReportDescriptors(prop.value).
|
|
493
|
+
getReportDescriptors(prop.value).map(shared.report(context));
|
|
495
494
|
}
|
|
496
495
|
},
|
|
497
496
|
"CallExpression:exit"() {
|
|
@@ -507,7 +506,7 @@ function create4(context) {
|
|
|
507
506
|
if (node.value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
508
507
|
return;
|
|
509
508
|
}
|
|
510
|
-
getReportDescriptors(node.value.expression).
|
|
509
|
+
getReportDescriptors(node.value.expression).map(shared.report(context));
|
|
511
510
|
}
|
|
512
511
|
};
|
|
513
512
|
}
|
|
@@ -1577,7 +1576,7 @@ function create24(context) {
|
|
|
1577
1576
|
};
|
|
1578
1577
|
}
|
|
1579
1578
|
const leftType = typeUtils.getConstrainedTypeAtLocation(services, left);
|
|
1580
|
-
const leftTypeVariants = inspectVariantTypes(tsApiUtils.
|
|
1579
|
+
const leftTypeVariants = inspectVariantTypes(tsApiUtils.unionTypeParts(leftType));
|
|
1581
1580
|
const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
|
|
1582
1581
|
if (isLeftValid) {
|
|
1583
1582
|
return getReportDescriptor(right);
|
|
@@ -1595,7 +1594,7 @@ function create24(context) {
|
|
|
1595
1594
|
return getReportDescriptor(initExpression);
|
|
1596
1595
|
}).otherwise(() => eff._);
|
|
1597
1596
|
}
|
|
1598
|
-
const visitorFunction = eff.flow(getReportDescriptor, shared.
|
|
1597
|
+
const visitorFunction = eff.flow(getReportDescriptor, shared.report(context));
|
|
1599
1598
|
return {
|
|
1600
1599
|
"JSXExpressionContainer > ConditionalExpression": visitorFunction,
|
|
1601
1600
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
@@ -1730,7 +1729,6 @@ var no_missing_key_default = createRule({
|
|
|
1730
1729
|
defaultOptions: []
|
|
1731
1730
|
});
|
|
1732
1731
|
function create27(context) {
|
|
1733
|
-
const report = shared.createReport(context);
|
|
1734
1732
|
const state = { isWithinChildrenToArray: false };
|
|
1735
1733
|
function checkIteratorElement(node) {
|
|
1736
1734
|
switch (node.type) {
|
|
@@ -1794,7 +1792,7 @@ function create27(context) {
|
|
|
1794
1792
|
const initialScope = context.sourceCode.getScope(node);
|
|
1795
1793
|
for (const element of elements) {
|
|
1796
1794
|
if (!JSX8__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1797
|
-
report({
|
|
1795
|
+
shared.report(context)({
|
|
1798
1796
|
messageId: "missingKey",
|
|
1799
1797
|
node: element
|
|
1800
1798
|
});
|
|
@@ -1815,10 +1813,12 @@ function create27(context) {
|
|
|
1815
1813
|
return;
|
|
1816
1814
|
}
|
|
1817
1815
|
if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
|
|
1818
|
-
checkBlockStatement(fn.body)
|
|
1816
|
+
for (const descriptor of checkBlockStatement(fn.body)) {
|
|
1817
|
+
shared.report(context)(descriptor);
|
|
1818
|
+
}
|
|
1819
1819
|
return;
|
|
1820
1820
|
}
|
|
1821
|
-
report(checkExpression(fn.body));
|
|
1821
|
+
shared.report(context)(checkExpression(fn.body));
|
|
1822
1822
|
},
|
|
1823
1823
|
"CallExpression:exit"(node) {
|
|
1824
1824
|
if (!core.isChildrenToArrayCall(context, node)) {
|
|
@@ -1831,7 +1831,7 @@ function create27(context) {
|
|
|
1831
1831
|
return;
|
|
1832
1832
|
}
|
|
1833
1833
|
if (node.parent.type === types.AST_NODE_TYPES.ArrayExpression) {
|
|
1834
|
-
report({
|
|
1834
|
+
shared.report(context)({
|
|
1835
1835
|
messageId: "unexpectedFragmentSyntax",
|
|
1836
1836
|
node
|
|
1837
1837
|
});
|
|
@@ -2952,7 +2952,7 @@ function trimLikeReact(text) {
|
|
|
2952
2952
|
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
2953
2953
|
return text.slice(start, end);
|
|
2954
2954
|
}
|
|
2955
|
-
function
|
|
2955
|
+
function checkAndReport(context, node, allowExpressions) {
|
|
2956
2956
|
function fix(fixer) {
|
|
2957
2957
|
if (node.parent.type !== types.AST_NODE_TYPES.JSXElement && node.parent.type !== types.AST_NODE_TYPES.JSXFragment) {
|
|
2958
2958
|
if (node.children.length === 0) {
|
|
@@ -3076,10 +3076,10 @@ function create44(context, [option]) {
|
|
|
3076
3076
|
return {
|
|
3077
3077
|
JSXElement(node) {
|
|
3078
3078
|
if (!JSX8__namespace.isFragmentElement(node)) return;
|
|
3079
|
-
|
|
3079
|
+
checkAndReport(context, node, allowExpressions);
|
|
3080
3080
|
},
|
|
3081
3081
|
JSXFragment(node) {
|
|
3082
|
-
|
|
3082
|
+
checkAndReport(context, node, allowExpressions);
|
|
3083
3083
|
}
|
|
3084
3084
|
};
|
|
3085
3085
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRuleForPlugin,
|
|
1
|
+
import { createRuleForPlugin, report, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
|
|
2
2
|
import * as JSX8 from '@eslint-react/jsx';
|
|
3
3
|
import * as AST11 from '@eslint-react/ast';
|
|
4
4
|
import { isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isComponentNameLoose, isCreateRefCall, isAssignmentToThisState, isForwardRefCall, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, getInstanceId, isInstanceIdEqual, DISPLAY_NAME_ASSIGNMENT_SELECTOR, isCreateContextCall, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideRenderMethod, isCreateElementCall, isReactHookCall, isReactHookCallWithNameAlias, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
@@ -9,7 +9,7 @@ import { compare } from 'compare-versions';
|
|
|
9
9
|
import * as VAR from '@eslint-react/var';
|
|
10
10
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
|
|
11
11
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
12
|
-
import {
|
|
12
|
+
import { unionTypeParts, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType } from 'ts-api-utils';
|
|
13
13
|
import ts from 'typescript';
|
|
14
14
|
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
@@ -109,7 +109,7 @@ var settings3 = {
|
|
|
109
109
|
|
|
110
110
|
// package.json
|
|
111
111
|
var name4 = "eslint-plugin-react-x";
|
|
112
|
-
var version = "1.37.1-
|
|
112
|
+
var version = "1.37.1-next.0";
|
|
113
113
|
var createRule = createRuleForPlugin("x");
|
|
114
114
|
|
|
115
115
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -387,7 +387,6 @@ var no_array_index_key_default = createRule({
|
|
|
387
387
|
defaultOptions: []
|
|
388
388
|
});
|
|
389
389
|
function create4(context) {
|
|
390
|
-
const report = createReport(context);
|
|
391
390
|
const indexParamNames = [];
|
|
392
391
|
function isArrayIndex(node) {
|
|
393
392
|
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
@@ -464,7 +463,7 @@ function create4(context) {
|
|
|
464
463
|
if (!("value" in prop)) {
|
|
465
464
|
continue;
|
|
466
465
|
}
|
|
467
|
-
getReportDescriptors(prop.value).
|
|
466
|
+
getReportDescriptors(prop.value).map(report(context));
|
|
468
467
|
}
|
|
469
468
|
},
|
|
470
469
|
"CallExpression:exit"() {
|
|
@@ -480,7 +479,7 @@ function create4(context) {
|
|
|
480
479
|
if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
|
|
481
480
|
return;
|
|
482
481
|
}
|
|
483
|
-
getReportDescriptors(node.value.expression).
|
|
482
|
+
getReportDescriptors(node.value.expression).map(report(context));
|
|
484
483
|
}
|
|
485
484
|
};
|
|
486
485
|
}
|
|
@@ -1550,7 +1549,7 @@ function create24(context) {
|
|
|
1550
1549
|
};
|
|
1551
1550
|
}
|
|
1552
1551
|
const leftType = getConstrainedTypeAtLocation(services, left);
|
|
1553
|
-
const leftTypeVariants = inspectVariantTypes(
|
|
1552
|
+
const leftTypeVariants = inspectVariantTypes(unionTypeParts(leftType));
|
|
1554
1553
|
const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
|
|
1555
1554
|
if (isLeftValid) {
|
|
1556
1555
|
return getReportDescriptor(right);
|
|
@@ -1568,7 +1567,7 @@ function create24(context) {
|
|
|
1568
1567
|
return getReportDescriptor(initExpression);
|
|
1569
1568
|
}).otherwise(() => _);
|
|
1570
1569
|
}
|
|
1571
|
-
const visitorFunction = flow(getReportDescriptor,
|
|
1570
|
+
const visitorFunction = flow(getReportDescriptor, report(context));
|
|
1572
1571
|
return {
|
|
1573
1572
|
"JSXExpressionContainer > ConditionalExpression": visitorFunction,
|
|
1574
1573
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
@@ -1703,7 +1702,6 @@ var no_missing_key_default = createRule({
|
|
|
1703
1702
|
defaultOptions: []
|
|
1704
1703
|
});
|
|
1705
1704
|
function create27(context) {
|
|
1706
|
-
const report = createReport(context);
|
|
1707
1705
|
const state = { isWithinChildrenToArray: false };
|
|
1708
1706
|
function checkIteratorElement(node) {
|
|
1709
1707
|
switch (node.type) {
|
|
@@ -1767,7 +1765,7 @@ function create27(context) {
|
|
|
1767
1765
|
const initialScope = context.sourceCode.getScope(node);
|
|
1768
1766
|
for (const element of elements) {
|
|
1769
1767
|
if (!JSX8.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1770
|
-
report({
|
|
1768
|
+
report(context)({
|
|
1771
1769
|
messageId: "missingKey",
|
|
1772
1770
|
node: element
|
|
1773
1771
|
});
|
|
@@ -1788,10 +1786,12 @@ function create27(context) {
|
|
|
1788
1786
|
return;
|
|
1789
1787
|
}
|
|
1790
1788
|
if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
|
|
1791
|
-
checkBlockStatement(fn.body)
|
|
1789
|
+
for (const descriptor of checkBlockStatement(fn.body)) {
|
|
1790
|
+
report(context)(descriptor);
|
|
1791
|
+
}
|
|
1792
1792
|
return;
|
|
1793
1793
|
}
|
|
1794
|
-
report(checkExpression(fn.body));
|
|
1794
|
+
report(context)(checkExpression(fn.body));
|
|
1795
1795
|
},
|
|
1796
1796
|
"CallExpression:exit"(node) {
|
|
1797
1797
|
if (!isChildrenToArrayCall(context, node)) {
|
|
@@ -1804,7 +1804,7 @@ function create27(context) {
|
|
|
1804
1804
|
return;
|
|
1805
1805
|
}
|
|
1806
1806
|
if (node.parent.type === AST_NODE_TYPES.ArrayExpression) {
|
|
1807
|
-
report({
|
|
1807
|
+
report(context)({
|
|
1808
1808
|
messageId: "unexpectedFragmentSyntax",
|
|
1809
1809
|
node
|
|
1810
1810
|
});
|
|
@@ -2925,7 +2925,7 @@ function trimLikeReact(text) {
|
|
|
2925
2925
|
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
2926
2926
|
return text.slice(start, end);
|
|
2927
2927
|
}
|
|
2928
|
-
function
|
|
2928
|
+
function checkAndReport(context, node, allowExpressions) {
|
|
2929
2929
|
function fix(fixer) {
|
|
2930
2930
|
if (node.parent.type !== AST_NODE_TYPES.JSXElement && node.parent.type !== AST_NODE_TYPES.JSXFragment) {
|
|
2931
2931
|
if (node.children.length === 0) {
|
|
@@ -3049,10 +3049,10 @@ function create44(context, [option]) {
|
|
|
3049
3049
|
return {
|
|
3050
3050
|
JSXElement(node) {
|
|
3051
3051
|
if (!JSX8.isFragmentElement(node)) return;
|
|
3052
|
-
|
|
3052
|
+
checkAndReport(context, node, allowExpressions);
|
|
3053
3053
|
},
|
|
3054
3054
|
JSXFragment(node) {
|
|
3055
|
-
|
|
3055
|
+
checkAndReport(context, node, allowExpressions);
|
|
3056
3056
|
}
|
|
3057
3057
|
};
|
|
3058
3058
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.37.1-
|
|
3
|
+
"version": "1.37.1-next.0",
|
|
4
4
|
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
"compare-versions": "^6.1.1",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.6.2",
|
|
52
|
-
"@eslint-react/ast": "1.37.1-
|
|
53
|
-
"@eslint-react/core": "1.37.1-
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.37.1-next.0",
|
|
53
|
+
"@eslint-react/core": "1.37.1-next.0",
|
|
54
|
+
"@eslint-react/eff": "1.37.1-next.0",
|
|
55
|
+
"@eslint-react/jsx": "1.37.1-next.0",
|
|
56
|
+
"@eslint-react/shared": "1.37.1-next.0",
|
|
57
|
+
"@eslint-react/var": "1.37.1-next.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.0.12",
|
|
61
61
|
"@types/react-dom": "^19.0.4",
|
|
62
|
-
"ts-api-utils": "^2.1
|
|
62
|
+
"ts-api-utils": "^2.0.1",
|
|
63
63
|
"tsup": "^8.4.0",
|
|
64
64
|
"@local/configs": "0.0.0"
|
|
65
65
|
},
|