eslint-plugin-react-x 1.37.0-next.0 → 1.37.1-beta.2
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.
|
|
139
|
+
var version = "1.37.1-beta.2";
|
|
140
140
|
var createRule = shared.createRuleForPlugin("x");
|
|
141
141
|
|
|
142
142
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -414,6 +414,7 @@ var no_array_index_key_default = createRule({
|
|
|
414
414
|
defaultOptions: []
|
|
415
415
|
});
|
|
416
416
|
function create4(context) {
|
|
417
|
+
const report = shared.createReport(context);
|
|
417
418
|
const indexParamNames = [];
|
|
418
419
|
function isArrayIndex(node) {
|
|
419
420
|
return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
@@ -490,7 +491,7 @@ function create4(context) {
|
|
|
490
491
|
if (!("value" in prop)) {
|
|
491
492
|
continue;
|
|
492
493
|
}
|
|
493
|
-
getReportDescriptors(prop.value).
|
|
494
|
+
getReportDescriptors(prop.value).forEach(report);
|
|
494
495
|
}
|
|
495
496
|
},
|
|
496
497
|
"CallExpression:exit"() {
|
|
@@ -506,7 +507,7 @@ function create4(context) {
|
|
|
506
507
|
if (node.value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
507
508
|
return;
|
|
508
509
|
}
|
|
509
|
-
getReportDescriptors(node.value.expression).
|
|
510
|
+
getReportDescriptors(node.value.expression).forEach(report);
|
|
510
511
|
}
|
|
511
512
|
};
|
|
512
513
|
}
|
|
@@ -1576,7 +1577,7 @@ function create24(context) {
|
|
|
1576
1577
|
};
|
|
1577
1578
|
}
|
|
1578
1579
|
const leftType = typeUtils.getConstrainedTypeAtLocation(services, left);
|
|
1579
|
-
const leftTypeVariants = inspectVariantTypes(tsApiUtils.
|
|
1580
|
+
const leftTypeVariants = inspectVariantTypes(tsApiUtils.unionConstituents(leftType));
|
|
1580
1581
|
const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
|
|
1581
1582
|
if (isLeftValid) {
|
|
1582
1583
|
return getReportDescriptor(right);
|
|
@@ -1594,7 +1595,7 @@ function create24(context) {
|
|
|
1594
1595
|
return getReportDescriptor(initExpression);
|
|
1595
1596
|
}).otherwise(() => eff._);
|
|
1596
1597
|
}
|
|
1597
|
-
const visitorFunction = eff.flow(getReportDescriptor, shared.
|
|
1598
|
+
const visitorFunction = eff.flow(getReportDescriptor, shared.createReport(context));
|
|
1598
1599
|
return {
|
|
1599
1600
|
"JSXExpressionContainer > ConditionalExpression": visitorFunction,
|
|
1600
1601
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
@@ -1729,6 +1730,7 @@ var no_missing_key_default = createRule({
|
|
|
1729
1730
|
defaultOptions: []
|
|
1730
1731
|
});
|
|
1731
1732
|
function create27(context) {
|
|
1733
|
+
const report = shared.createReport(context);
|
|
1732
1734
|
const state = { isWithinChildrenToArray: false };
|
|
1733
1735
|
function checkIteratorElement(node) {
|
|
1734
1736
|
switch (node.type) {
|
|
@@ -1792,7 +1794,7 @@ function create27(context) {
|
|
|
1792
1794
|
const initialScope = context.sourceCode.getScope(node);
|
|
1793
1795
|
for (const element of elements) {
|
|
1794
1796
|
if (!JSX8__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1795
|
-
|
|
1797
|
+
report({
|
|
1796
1798
|
messageId: "missingKey",
|
|
1797
1799
|
node: element
|
|
1798
1800
|
});
|
|
@@ -1813,12 +1815,10 @@ function create27(context) {
|
|
|
1813
1815
|
return;
|
|
1814
1816
|
}
|
|
1815
1817
|
if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
|
|
1816
|
-
|
|
1817
|
-
shared.report(context)(descriptor);
|
|
1818
|
-
}
|
|
1818
|
+
checkBlockStatement(fn.body).forEach(report);
|
|
1819
1819
|
return;
|
|
1820
1820
|
}
|
|
1821
|
-
|
|
1821
|
+
report(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
|
-
|
|
1834
|
+
report({
|
|
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 doCheck(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
|
+
doCheck(context, node, allowExpressions);
|
|
3080
3080
|
},
|
|
3081
3081
|
JSXFragment(node) {
|
|
3082
|
-
|
|
3082
|
+
doCheck(context, node, allowExpressions);
|
|
3083
3083
|
}
|
|
3084
3084
|
};
|
|
3085
3085
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRuleForPlugin,
|
|
1
|
+
import { createRuleForPlugin, createReport, 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 { unionConstituents, 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.
|
|
112
|
+
var version = "1.37.1-beta.2";
|
|
113
113
|
var createRule = createRuleForPlugin("x");
|
|
114
114
|
|
|
115
115
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -387,6 +387,7 @@ var no_array_index_key_default = createRule({
|
|
|
387
387
|
defaultOptions: []
|
|
388
388
|
});
|
|
389
389
|
function create4(context) {
|
|
390
|
+
const report = createReport(context);
|
|
390
391
|
const indexParamNames = [];
|
|
391
392
|
function isArrayIndex(node) {
|
|
392
393
|
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
@@ -463,7 +464,7 @@ function create4(context) {
|
|
|
463
464
|
if (!("value" in prop)) {
|
|
464
465
|
continue;
|
|
465
466
|
}
|
|
466
|
-
getReportDescriptors(prop.value).
|
|
467
|
+
getReportDescriptors(prop.value).forEach(report);
|
|
467
468
|
}
|
|
468
469
|
},
|
|
469
470
|
"CallExpression:exit"() {
|
|
@@ -479,7 +480,7 @@ function create4(context) {
|
|
|
479
480
|
if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
|
|
480
481
|
return;
|
|
481
482
|
}
|
|
482
|
-
getReportDescriptors(node.value.expression).
|
|
483
|
+
getReportDescriptors(node.value.expression).forEach(report);
|
|
483
484
|
}
|
|
484
485
|
};
|
|
485
486
|
}
|
|
@@ -1549,7 +1550,7 @@ function create24(context) {
|
|
|
1549
1550
|
};
|
|
1550
1551
|
}
|
|
1551
1552
|
const leftType = getConstrainedTypeAtLocation(services, left);
|
|
1552
|
-
const leftTypeVariants = inspectVariantTypes(
|
|
1553
|
+
const leftTypeVariants = inspectVariantTypes(unionConstituents(leftType));
|
|
1553
1554
|
const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
|
|
1554
1555
|
if (isLeftValid) {
|
|
1555
1556
|
return getReportDescriptor(right);
|
|
@@ -1567,7 +1568,7 @@ function create24(context) {
|
|
|
1567
1568
|
return getReportDescriptor(initExpression);
|
|
1568
1569
|
}).otherwise(() => _);
|
|
1569
1570
|
}
|
|
1570
|
-
const visitorFunction = flow(getReportDescriptor,
|
|
1571
|
+
const visitorFunction = flow(getReportDescriptor, createReport(context));
|
|
1571
1572
|
return {
|
|
1572
1573
|
"JSXExpressionContainer > ConditionalExpression": visitorFunction,
|
|
1573
1574
|
"JSXExpressionContainer > LogicalExpression": visitorFunction
|
|
@@ -1702,6 +1703,7 @@ var no_missing_key_default = createRule({
|
|
|
1702
1703
|
defaultOptions: []
|
|
1703
1704
|
});
|
|
1704
1705
|
function create27(context) {
|
|
1706
|
+
const report = createReport(context);
|
|
1705
1707
|
const state = { isWithinChildrenToArray: false };
|
|
1706
1708
|
function checkIteratorElement(node) {
|
|
1707
1709
|
switch (node.type) {
|
|
@@ -1765,7 +1767,7 @@ function create27(context) {
|
|
|
1765
1767
|
const initialScope = context.sourceCode.getScope(node);
|
|
1766
1768
|
for (const element of elements) {
|
|
1767
1769
|
if (!JSX8.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1768
|
-
report(
|
|
1770
|
+
report({
|
|
1769
1771
|
messageId: "missingKey",
|
|
1770
1772
|
node: element
|
|
1771
1773
|
});
|
|
@@ -1786,12 +1788,10 @@ function create27(context) {
|
|
|
1786
1788
|
return;
|
|
1787
1789
|
}
|
|
1788
1790
|
if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
|
|
1789
|
-
|
|
1790
|
-
report(context)(descriptor);
|
|
1791
|
-
}
|
|
1791
|
+
checkBlockStatement(fn.body).forEach(report);
|
|
1792
1792
|
return;
|
|
1793
1793
|
}
|
|
1794
|
-
report(
|
|
1794
|
+
report(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({
|
|
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 doCheck(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
|
+
doCheck(context, node, allowExpressions);
|
|
3053
3053
|
},
|
|
3054
3054
|
JSXFragment(node) {
|
|
3055
|
-
|
|
3055
|
+
doCheck(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.
|
|
3
|
+
"version": "1.37.1-beta.2",
|
|
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/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/shared": "1.37.
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/var": "1.37.
|
|
52
|
+
"@eslint-react/ast": "1.37.1-beta.2",
|
|
53
|
+
"@eslint-react/core": "1.37.1-beta.2",
|
|
54
|
+
"@eslint-react/jsx": "1.37.1-beta.2",
|
|
55
|
+
"@eslint-react/shared": "1.37.1-beta.2",
|
|
56
|
+
"@eslint-react/eff": "1.37.1-beta.2",
|
|
57
|
+
"@eslint-react/var": "1.37.1-beta.2"
|
|
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.0
|
|
62
|
+
"ts-api-utils": "^2.1.0",
|
|
63
63
|
"tsup": "^8.4.0",
|
|
64
64
|
"@local/configs": "0.0.0"
|
|
65
65
|
},
|