eslint-plugin-react-x 1.24.0-next.9 → 1.24.1-beta.1
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 +18 -37
- package/dist/index.mjs +20 -39
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
|
42
42
|
|
|
43
43
|
// package.json
|
|
44
44
|
var name = "eslint-plugin-react-x";
|
|
45
|
-
var version = "1.24.
|
|
45
|
+
var version = "1.24.1-beta.1";
|
|
46
46
|
var createRule = shared.createRuleForPlugin("x");
|
|
47
47
|
|
|
48
48
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -301,7 +301,7 @@ function isReactChildrenMethod(name2) {
|
|
|
301
301
|
return reactChildrenMethod.some((method) => method === name2);
|
|
302
302
|
}
|
|
303
303
|
function isUsingReactChildren(node, context) {
|
|
304
|
-
const
|
|
304
|
+
const { importSource = "react" } = shared.unsafeDecodeSettings(context.settings);
|
|
305
305
|
const { callee } = node;
|
|
306
306
|
if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
|
|
307
307
|
return false;
|
|
@@ -314,7 +314,7 @@ function isUsingReactChildren(node, context) {
|
|
|
314
314
|
return true;
|
|
315
315
|
}
|
|
316
316
|
if (callee.object.type === types.AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
|
|
317
|
-
return core.isInitializedFromReact(callee.object.object.name,
|
|
317
|
+
return core.isInitializedFromReact(callee.object.object.name, importSource, initialScope);
|
|
318
318
|
}
|
|
319
319
|
return false;
|
|
320
320
|
}
|
|
@@ -610,10 +610,10 @@ var no_children_prop_default = createRule({
|
|
|
610
610
|
create(context) {
|
|
611
611
|
return {
|
|
612
612
|
JSXElement(node) {
|
|
613
|
-
const attribute = JSX7__namespace.
|
|
613
|
+
const attribute = JSX7__namespace.getAttribute(
|
|
614
614
|
"children",
|
|
615
|
-
|
|
616
|
-
|
|
615
|
+
node.openingElement.attributes,
|
|
616
|
+
context.sourceCode.getScope(node)
|
|
617
617
|
);
|
|
618
618
|
if (attribute != null) {
|
|
619
619
|
context.report({
|
|
@@ -691,7 +691,6 @@ var no_class_component_default = createRule({
|
|
|
691
691
|
messageId: "noClassComponent",
|
|
692
692
|
node: component,
|
|
693
693
|
data: {
|
|
694
|
-
// eslint-disable-next-line eslint-plugin/no-unused-placeholders
|
|
695
694
|
name: name2
|
|
696
695
|
}
|
|
697
696
|
});
|
|
@@ -1012,7 +1011,7 @@ var no_context_provider_default = createRule({
|
|
|
1012
1011
|
}
|
|
1013
1012
|
return {
|
|
1014
1013
|
JSXElement(node) {
|
|
1015
|
-
const elementName = JSX7__namespace.getElementName(node
|
|
1014
|
+
const elementName = JSX7__namespace.getElementName(node);
|
|
1016
1015
|
if (!elementName.endsWith(".Provider")) {
|
|
1017
1016
|
return;
|
|
1018
1017
|
}
|
|
@@ -1438,7 +1437,7 @@ var no_implicit_key_default = createRule({
|
|
|
1438
1437
|
return {
|
|
1439
1438
|
JSXOpeningElement(node) {
|
|
1440
1439
|
const initialScope = context.sourceCode.getScope(node);
|
|
1441
|
-
const keyPropFound = JSX7__namespace.
|
|
1440
|
+
const keyPropFound = JSX7__namespace.getAttribute("key", node.attributes, initialScope);
|
|
1442
1441
|
const keyPropOnElement = node.attributes.some(
|
|
1443
1442
|
(n) => n.type === types.AST_NODE_TYPES.JSXAttribute && n.name.type === types.AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
|
|
1444
1443
|
);
|
|
@@ -1533,17 +1532,6 @@ function inspectVariantTypes(types) {
|
|
|
1533
1532
|
}
|
|
1534
1533
|
return variantTypes;
|
|
1535
1534
|
}
|
|
1536
|
-
function isInitExpression(node) {
|
|
1537
|
-
if (node == null) return false;
|
|
1538
|
-
return node.type !== types.AST_NODE_TYPES.VariableDeclaration;
|
|
1539
|
-
}
|
|
1540
|
-
function getVariableInitExpression(variable, at) {
|
|
1541
|
-
const def = variable?.defs[at];
|
|
1542
|
-
if (def?.node == null || !("init" in def.node)) {
|
|
1543
|
-
return eff._;
|
|
1544
|
-
}
|
|
1545
|
-
return isInitExpression(def.node.init) ? def.node.init : eff._;
|
|
1546
|
-
}
|
|
1547
1535
|
var no_leaked_conditional_rendering_default = createRule({
|
|
1548
1536
|
meta: {
|
|
1549
1537
|
type: "problem",
|
|
@@ -1583,7 +1571,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1583
1571
|
return getReportDescriptor(right);
|
|
1584
1572
|
}
|
|
1585
1573
|
const initialScope = context.sourceCode.getScope(left);
|
|
1586
|
-
const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR__namespace.
|
|
1574
|
+
const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR__namespace.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
|
|
1587
1575
|
if (isLeftNan) {
|
|
1588
1576
|
return {
|
|
1589
1577
|
messageId: "noLeakedConditionalRendering",
|
|
@@ -1606,7 +1594,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1606
1594
|
return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
|
|
1607
1595
|
}).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
|
|
1608
1596
|
const variable = VAR__namespace.findVariable(n.name, context.sourceCode.getScope(n));
|
|
1609
|
-
const initExpression =
|
|
1597
|
+
const initExpression = tsPattern.match(variable?.defs.at(0)?.node).with({ init: tsPattern.P.select({ type: tsPattern.P.not(types.AST_NODE_TYPES.VariableDeclaration) }) }, eff.identity).otherwise(() => eff._);
|
|
1610
1598
|
return getReportDescriptor(initExpression);
|
|
1611
1599
|
}).otherwise(() => eff._);
|
|
1612
1600
|
}
|
|
@@ -1659,7 +1647,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1659
1647
|
"Program:exit"(node) {
|
|
1660
1648
|
const components = ctx.getAllComponents(node);
|
|
1661
1649
|
for (const { node: node2, displayName, flag } of components.values()) {
|
|
1662
|
-
const isMemoOrForwardRef = (flag & (core.
|
|
1650
|
+
const isMemoOrForwardRef = (flag & (core.ERComponentFlag.ForwardRef | core.ERComponentFlag.Memo)) > 0n;
|
|
1663
1651
|
if (AST11__namespace.getFunctionIdentifier(node2) != null) {
|
|
1664
1652
|
continue;
|
|
1665
1653
|
}
|
|
@@ -1702,7 +1690,7 @@ var no_missing_key_default = createRule({
|
|
|
1702
1690
|
switch (node.type) {
|
|
1703
1691
|
case types.AST_NODE_TYPES.JSXElement: {
|
|
1704
1692
|
const initialScope = context.sourceCode.getScope(node);
|
|
1705
|
-
if (!JSX7__namespace.hasAttribute("key",
|
|
1693
|
+
if (!JSX7__namespace.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1706
1694
|
return {
|
|
1707
1695
|
messageId: "noMissingKey",
|
|
1708
1696
|
node
|
|
@@ -1763,7 +1751,7 @@ var no_missing_key_default = createRule({
|
|
|
1763
1751
|
}
|
|
1764
1752
|
const initialScope = context.sourceCode.getScope(node);
|
|
1765
1753
|
for (const element of elements) {
|
|
1766
|
-
if (!JSX7__namespace.hasAttribute("key",
|
|
1754
|
+
if (!JSX7__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1767
1755
|
context.report({
|
|
1768
1756
|
messageId: "noMissingKey",
|
|
1769
1757
|
node: element
|
|
@@ -1865,7 +1853,7 @@ var no_nested_components_default = createRule({
|
|
|
1865
1853
|
continue;
|
|
1866
1854
|
}
|
|
1867
1855
|
const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
|
|
1868
|
-
const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.
|
|
1856
|
+
const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.findParentAttribute(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
1869
1857
|
if (isInsideJSXPropValue) {
|
|
1870
1858
|
if (!core.isDeclaredInRenderPropLoose(component)) {
|
|
1871
1859
|
context.report({
|
|
@@ -2012,7 +2000,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2012
2000
|
"Program:exit"(node) {
|
|
2013
2001
|
const components = ctx.getAllComponents(node);
|
|
2014
2002
|
for (const { name: name2 = "PureComponent", node: component, flag } of components.values()) {
|
|
2015
|
-
if ((flag & core.
|
|
2003
|
+
if ((flag & core.ERComponentFlag.PureComponent) === 0n) {
|
|
2016
2004
|
continue;
|
|
2017
2005
|
}
|
|
2018
2006
|
const { body } = component.body;
|
|
@@ -2893,9 +2881,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2893
2881
|
const { allowExpressions = true } = option;
|
|
2894
2882
|
return {
|
|
2895
2883
|
JSXElement(node) {
|
|
2896
|
-
if (JSX7__namespace.
|
|
2897
|
-
return;
|
|
2898
|
-
}
|
|
2884
|
+
if (!JSX7__namespace.isFragmentElement(node)) return;
|
|
2899
2885
|
checkAndReport(node, context, allowExpressions);
|
|
2900
2886
|
},
|
|
2901
2887
|
JSXFragment(node) {
|
|
@@ -3007,7 +2993,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3007
2993
|
},
|
|
3008
2994
|
name: RULE_NAME46,
|
|
3009
2995
|
create(context) {
|
|
3010
|
-
const importSource = shared.getSettingsFromContext(context)
|
|
2996
|
+
const { importSource } = shared.getSettingsFromContext(context);
|
|
3011
2997
|
return {
|
|
3012
2998
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
3013
2999
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
@@ -3153,9 +3139,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3153
3139
|
create(context) {
|
|
3154
3140
|
return {
|
|
3155
3141
|
JSXElement(node) {
|
|
3156
|
-
if (JSX7__namespace.
|
|
3157
|
-
return;
|
|
3158
|
-
}
|
|
3142
|
+
if (!JSX7__namespace.isFragmentElement(node)) return;
|
|
3159
3143
|
const hasAttributes = node.openingElement.attributes.length > 0;
|
|
3160
3144
|
if (hasAttributes) {
|
|
3161
3145
|
return;
|
|
@@ -3169,9 +3153,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3169
3153
|
return [];
|
|
3170
3154
|
}
|
|
3171
3155
|
return [
|
|
3172
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3173
3156
|
fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
|
|
3174
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3175
3157
|
fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
|
|
3176
3158
|
];
|
|
3177
3159
|
}
|
|
@@ -3187,7 +3169,6 @@ var use_jsx_vars_default = createRule({
|
|
|
3187
3169
|
meta: {
|
|
3188
3170
|
type: "problem",
|
|
3189
3171
|
docs: {
|
|
3190
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
3191
3172
|
description: "helpes `eslint/no-unused-vars` to correctly mark JSX variables as used.",
|
|
3192
3173
|
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3193
3174
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as JSX7 from '@eslint-react/jsx';
|
|
2
2
|
import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings } from '@eslint-react/shared';
|
|
3
3
|
import * as AST11 from '@eslint-react/ast';
|
|
4
|
-
import { isForwardRefCall, isThisSetState, isClassComponent, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT,
|
|
5
|
-
import { _, getOrUpdate } from '@eslint-react/eff';
|
|
4
|
+
import { isForwardRefCall, isThisSetState, isClassComponent, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, isReactHookCall, isCreateElementCall, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
5
|
+
import { _, getOrUpdate, identity } from '@eslint-react/eff';
|
|
6
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
7
7
|
import { isMatching, match, P } from 'ts-pattern';
|
|
8
8
|
import { compare } from 'compare-versions';
|
|
@@ -15,7 +15,7 @@ import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReado
|
|
|
15
15
|
|
|
16
16
|
// package.json
|
|
17
17
|
var name = "eslint-plugin-react-x";
|
|
18
|
-
var version = "1.24.
|
|
18
|
+
var version = "1.24.1-beta.1";
|
|
19
19
|
var createRule = createRuleForPlugin("x");
|
|
20
20
|
|
|
21
21
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -274,7 +274,7 @@ function isReactChildrenMethod(name2) {
|
|
|
274
274
|
return reactChildrenMethod.some((method) => method === name2);
|
|
275
275
|
}
|
|
276
276
|
function isUsingReactChildren(node, context) {
|
|
277
|
-
const
|
|
277
|
+
const { importSource = "react" } = unsafeDecodeSettings(context.settings);
|
|
278
278
|
const { callee } = node;
|
|
279
279
|
if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
|
|
280
280
|
return false;
|
|
@@ -287,7 +287,7 @@ function isUsingReactChildren(node, context) {
|
|
|
287
287
|
return true;
|
|
288
288
|
}
|
|
289
289
|
if (callee.object.type === AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
|
|
290
|
-
return isInitializedFromReact(callee.object.object.name,
|
|
290
|
+
return isInitializedFromReact(callee.object.object.name, importSource, initialScope);
|
|
291
291
|
}
|
|
292
292
|
return false;
|
|
293
293
|
}
|
|
@@ -583,10 +583,10 @@ var no_children_prop_default = createRule({
|
|
|
583
583
|
create(context) {
|
|
584
584
|
return {
|
|
585
585
|
JSXElement(node) {
|
|
586
|
-
const attribute = JSX7.
|
|
586
|
+
const attribute = JSX7.getAttribute(
|
|
587
587
|
"children",
|
|
588
|
-
|
|
589
|
-
|
|
588
|
+
node.openingElement.attributes,
|
|
589
|
+
context.sourceCode.getScope(node)
|
|
590
590
|
);
|
|
591
591
|
if (attribute != null) {
|
|
592
592
|
context.report({
|
|
@@ -664,7 +664,6 @@ var no_class_component_default = createRule({
|
|
|
664
664
|
messageId: "noClassComponent",
|
|
665
665
|
node: component,
|
|
666
666
|
data: {
|
|
667
|
-
// eslint-disable-next-line eslint-plugin/no-unused-placeholders
|
|
668
667
|
name: name2
|
|
669
668
|
}
|
|
670
669
|
});
|
|
@@ -985,7 +984,7 @@ var no_context_provider_default = createRule({
|
|
|
985
984
|
}
|
|
986
985
|
return {
|
|
987
986
|
JSXElement(node) {
|
|
988
|
-
const elementName = JSX7.getElementName(node
|
|
987
|
+
const elementName = JSX7.getElementName(node);
|
|
989
988
|
if (!elementName.endsWith(".Provider")) {
|
|
990
989
|
return;
|
|
991
990
|
}
|
|
@@ -1411,7 +1410,7 @@ var no_implicit_key_default = createRule({
|
|
|
1411
1410
|
return {
|
|
1412
1411
|
JSXOpeningElement(node) {
|
|
1413
1412
|
const initialScope = context.sourceCode.getScope(node);
|
|
1414
|
-
const keyPropFound = JSX7.
|
|
1413
|
+
const keyPropFound = JSX7.getAttribute("key", node.attributes, initialScope);
|
|
1415
1414
|
const keyPropOnElement = node.attributes.some(
|
|
1416
1415
|
(n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
|
|
1417
1416
|
);
|
|
@@ -1506,17 +1505,6 @@ function inspectVariantTypes(types) {
|
|
|
1506
1505
|
}
|
|
1507
1506
|
return variantTypes;
|
|
1508
1507
|
}
|
|
1509
|
-
function isInitExpression(node) {
|
|
1510
|
-
if (node == null) return false;
|
|
1511
|
-
return node.type !== AST_NODE_TYPES.VariableDeclaration;
|
|
1512
|
-
}
|
|
1513
|
-
function getVariableInitExpression(variable, at) {
|
|
1514
|
-
const def = variable?.defs[at];
|
|
1515
|
-
if (def?.node == null || !("init" in def.node)) {
|
|
1516
|
-
return _;
|
|
1517
|
-
}
|
|
1518
|
-
return isInitExpression(def.node.init) ? def.node.init : _;
|
|
1519
|
-
}
|
|
1520
1508
|
var no_leaked_conditional_rendering_default = createRule({
|
|
1521
1509
|
meta: {
|
|
1522
1510
|
type: "problem",
|
|
@@ -1556,7 +1544,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1556
1544
|
return getReportDescriptor(right);
|
|
1557
1545
|
}
|
|
1558
1546
|
const initialScope = context.sourceCode.getScope(left);
|
|
1559
|
-
const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.
|
|
1547
|
+
const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
|
|
1560
1548
|
if (isLeftNan) {
|
|
1561
1549
|
return {
|
|
1562
1550
|
messageId: "noLeakedConditionalRendering",
|
|
@@ -1579,7 +1567,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1579
1567
|
return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
|
|
1580
1568
|
}).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
1581
1569
|
const variable = VAR.findVariable(n.name, context.sourceCode.getScope(n));
|
|
1582
|
-
const initExpression =
|
|
1570
|
+
const initExpression = match(variable?.defs.at(0)?.node).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, identity).otherwise(() => _);
|
|
1583
1571
|
return getReportDescriptor(initExpression);
|
|
1584
1572
|
}).otherwise(() => _);
|
|
1585
1573
|
}
|
|
@@ -1632,7 +1620,7 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1632
1620
|
"Program:exit"(node) {
|
|
1633
1621
|
const components = ctx.getAllComponents(node);
|
|
1634
1622
|
for (const { node: node2, displayName, flag } of components.values()) {
|
|
1635
|
-
const isMemoOrForwardRef = (flag & (
|
|
1623
|
+
const isMemoOrForwardRef = (flag & (ERComponentFlag.ForwardRef | ERComponentFlag.Memo)) > 0n;
|
|
1636
1624
|
if (AST11.getFunctionIdentifier(node2) != null) {
|
|
1637
1625
|
continue;
|
|
1638
1626
|
}
|
|
@@ -1675,7 +1663,7 @@ var no_missing_key_default = createRule({
|
|
|
1675
1663
|
switch (node.type) {
|
|
1676
1664
|
case AST_NODE_TYPES.JSXElement: {
|
|
1677
1665
|
const initialScope = context.sourceCode.getScope(node);
|
|
1678
|
-
if (!JSX7.hasAttribute("key",
|
|
1666
|
+
if (!JSX7.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1679
1667
|
return {
|
|
1680
1668
|
messageId: "noMissingKey",
|
|
1681
1669
|
node
|
|
@@ -1736,7 +1724,7 @@ var no_missing_key_default = createRule({
|
|
|
1736
1724
|
}
|
|
1737
1725
|
const initialScope = context.sourceCode.getScope(node);
|
|
1738
1726
|
for (const element of elements) {
|
|
1739
|
-
if (!JSX7.hasAttribute("key",
|
|
1727
|
+
if (!JSX7.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1740
1728
|
context.report({
|
|
1741
1729
|
messageId: "noMissingKey",
|
|
1742
1730
|
node: element
|
|
@@ -1838,7 +1826,7 @@ var no_nested_components_default = createRule({
|
|
|
1838
1826
|
continue;
|
|
1839
1827
|
}
|
|
1840
1828
|
const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
|
|
1841
|
-
const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || JSX7.
|
|
1829
|
+
const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || JSX7.findParentAttribute(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
1842
1830
|
if (isInsideJSXPropValue) {
|
|
1843
1831
|
if (!isDeclaredInRenderPropLoose(component)) {
|
|
1844
1832
|
context.report({
|
|
@@ -1985,7 +1973,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1985
1973
|
"Program:exit"(node) {
|
|
1986
1974
|
const components = ctx.getAllComponents(node);
|
|
1987
1975
|
for (const { name: name2 = "PureComponent", node: component, flag } of components.values()) {
|
|
1988
|
-
if ((flag &
|
|
1976
|
+
if ((flag & ERComponentFlag.PureComponent) === 0n) {
|
|
1989
1977
|
continue;
|
|
1990
1978
|
}
|
|
1991
1979
|
const { body } = component.body;
|
|
@@ -2866,9 +2854,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2866
2854
|
const { allowExpressions = true } = option;
|
|
2867
2855
|
return {
|
|
2868
2856
|
JSXElement(node) {
|
|
2869
|
-
if (JSX7.
|
|
2870
|
-
return;
|
|
2871
|
-
}
|
|
2857
|
+
if (!JSX7.isFragmentElement(node)) return;
|
|
2872
2858
|
checkAndReport(node, context, allowExpressions);
|
|
2873
2859
|
},
|
|
2874
2860
|
JSXFragment(node) {
|
|
@@ -2980,7 +2966,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
2980
2966
|
},
|
|
2981
2967
|
name: RULE_NAME46,
|
|
2982
2968
|
create(context) {
|
|
2983
|
-
const importSource = getSettingsFromContext(context)
|
|
2969
|
+
const { importSource } = getSettingsFromContext(context);
|
|
2984
2970
|
return {
|
|
2985
2971
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
2986
2972
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
@@ -3126,9 +3112,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3126
3112
|
create(context) {
|
|
3127
3113
|
return {
|
|
3128
3114
|
JSXElement(node) {
|
|
3129
|
-
if (JSX7.
|
|
3130
|
-
return;
|
|
3131
|
-
}
|
|
3115
|
+
if (!JSX7.isFragmentElement(node)) return;
|
|
3132
3116
|
const hasAttributes = node.openingElement.attributes.length > 0;
|
|
3133
3117
|
if (hasAttributes) {
|
|
3134
3118
|
return;
|
|
@@ -3142,9 +3126,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3142
3126
|
return [];
|
|
3143
3127
|
}
|
|
3144
3128
|
return [
|
|
3145
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3146
3129
|
fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
|
|
3147
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3148
3130
|
fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
|
|
3149
3131
|
];
|
|
3150
3132
|
}
|
|
@@ -3160,7 +3142,6 @@ var use_jsx_vars_default = createRule({
|
|
|
3160
3142
|
meta: {
|
|
3161
3143
|
type: "problem",
|
|
3162
3144
|
docs: {
|
|
3163
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
3164
3145
|
description: "helpes `eslint/no-unused-vars` to correctly mark JSX variables as used.",
|
|
3165
3146
|
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3166
3147
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.1-beta.1",
|
|
4
4
|
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,20 +40,20 @@
|
|
|
40
40
|
"./package.json"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
44
|
-
"@typescript-eslint/type-utils": "^8.
|
|
45
|
-
"@typescript-eslint/types": "^8.
|
|
46
|
-
"@typescript-eslint/utils": "^8.
|
|
43
|
+
"@typescript-eslint/scope-manager": "^8.21.0",
|
|
44
|
+
"@typescript-eslint/type-utils": "^8.21.0",
|
|
45
|
+
"@typescript-eslint/types": "^8.21.0",
|
|
46
|
+
"@typescript-eslint/utils": "^8.21.0",
|
|
47
47
|
"compare-versions": "^6.1.1",
|
|
48
48
|
"is-immutable-type": "^5.0.1",
|
|
49
49
|
"string-ts": "^2.2.0",
|
|
50
|
-
"ts-pattern": "^5.6.
|
|
51
|
-
"@eslint-react/ast": "1.24.
|
|
52
|
-
"@eslint-react/core": "1.24.
|
|
53
|
-
"@eslint-react/eff": "1.24.
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/var": "1.24.
|
|
50
|
+
"ts-pattern": "^5.6.2",
|
|
51
|
+
"@eslint-react/ast": "1.24.1-beta.1",
|
|
52
|
+
"@eslint-react/core": "1.24.1-beta.1",
|
|
53
|
+
"@eslint-react/eff": "1.24.1-beta.1",
|
|
54
|
+
"@eslint-react/jsx": "1.24.1-beta.1",
|
|
55
|
+
"@eslint-react/shared": "1.24.1-beta.1",
|
|
56
|
+
"@eslint-react/var": "1.24.1-beta.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/react": "^19.0.7",
|