eslint-plugin-react-x 1.24.0-next.8 → 1.24.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 +17 -40
- package/dist/index.mjs +17 -40
- package/package.json +8 -8
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.0
|
|
45
|
+
var version = "1.24.0";
|
|
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({
|
|
@@ -661,12 +661,6 @@ var RULE_NAME12 = "no-class-component";
|
|
|
661
661
|
var RULE_FEATURES12 = [
|
|
662
662
|
"CHK"
|
|
663
663
|
];
|
|
664
|
-
function isComponentDidCatch(node) {
|
|
665
|
-
return (node.type === types.AST_NODE_TYPES.MethodDefinition || node.type === types.AST_NODE_TYPES.PropertyDefinition) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
666
|
-
}
|
|
667
|
-
function isGetDerivedStateFromError(node) {
|
|
668
|
-
return (node.type === types.AST_NODE_TYPES.MethodDefinition || node.type === types.AST_NODE_TYPES.PropertyDefinition) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
669
|
-
}
|
|
670
664
|
var no_class_component_default = createRule({
|
|
671
665
|
meta: {
|
|
672
666
|
type: "problem",
|
|
@@ -690,14 +684,13 @@ var no_class_component_default = createRule({
|
|
|
690
684
|
"Program:exit"(node) {
|
|
691
685
|
const components = ctx.getAllComponents(node);
|
|
692
686
|
for (const { name: name2 = "anonymous", node: component } of components.values()) {
|
|
693
|
-
if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
|
|
687
|
+
if (component.body.body.some((m) => core.isComponentDidCatch(m) || core.isGetDerivedStateFromError(m))) {
|
|
694
688
|
continue;
|
|
695
689
|
}
|
|
696
690
|
context.report({
|
|
697
691
|
messageId: "noClassComponent",
|
|
698
692
|
node: component,
|
|
699
693
|
data: {
|
|
700
|
-
// eslint-disable-next-line eslint-plugin/no-unused-placeholders
|
|
701
694
|
name: name2
|
|
702
695
|
}
|
|
703
696
|
});
|
|
@@ -1018,7 +1011,7 @@ var no_context_provider_default = createRule({
|
|
|
1018
1011
|
}
|
|
1019
1012
|
return {
|
|
1020
1013
|
JSXElement(node) {
|
|
1021
|
-
const elementName = JSX7__namespace.getElementName(node
|
|
1014
|
+
const elementName = JSX7__namespace.getElementName(node);
|
|
1022
1015
|
if (!elementName.endsWith(".Provider")) {
|
|
1023
1016
|
return;
|
|
1024
1017
|
}
|
|
@@ -1444,7 +1437,7 @@ var no_implicit_key_default = createRule({
|
|
|
1444
1437
|
return {
|
|
1445
1438
|
JSXOpeningElement(node) {
|
|
1446
1439
|
const initialScope = context.sourceCode.getScope(node);
|
|
1447
|
-
const keyPropFound = JSX7__namespace.
|
|
1440
|
+
const keyPropFound = JSX7__namespace.getAttribute("key", node.attributes, initialScope);
|
|
1448
1441
|
const keyPropOnElement = node.attributes.some(
|
|
1449
1442
|
(n) => n.type === types.AST_NODE_TYPES.JSXAttribute && n.name.type === types.AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
|
|
1450
1443
|
);
|
|
@@ -1589,7 +1582,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1589
1582
|
return getReportDescriptor(right);
|
|
1590
1583
|
}
|
|
1591
1584
|
const initialScope = context.sourceCode.getScope(left);
|
|
1592
|
-
const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR__namespace.
|
|
1585
|
+
const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR__namespace.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
|
|
1593
1586
|
if (isLeftNan) {
|
|
1594
1587
|
return {
|
|
1595
1588
|
messageId: "noLeakedConditionalRendering",
|
|
@@ -1708,7 +1701,7 @@ var no_missing_key_default = createRule({
|
|
|
1708
1701
|
switch (node.type) {
|
|
1709
1702
|
case types.AST_NODE_TYPES.JSXElement: {
|
|
1710
1703
|
const initialScope = context.sourceCode.getScope(node);
|
|
1711
|
-
if (!JSX7__namespace.hasAttribute("key",
|
|
1704
|
+
if (!JSX7__namespace.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1712
1705
|
return {
|
|
1713
1706
|
messageId: "noMissingKey",
|
|
1714
1707
|
node
|
|
@@ -1769,7 +1762,7 @@ var no_missing_key_default = createRule({
|
|
|
1769
1762
|
}
|
|
1770
1763
|
const initialScope = context.sourceCode.getScope(node);
|
|
1771
1764
|
for (const element of elements) {
|
|
1772
|
-
if (!JSX7__namespace.hasAttribute("key",
|
|
1765
|
+
if (!JSX7__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1773
1766
|
context.report({
|
|
1774
1767
|
messageId: "noMissingKey",
|
|
1775
1768
|
node: element
|
|
@@ -1871,7 +1864,7 @@ var no_nested_components_default = createRule({
|
|
|
1871
1864
|
continue;
|
|
1872
1865
|
}
|
|
1873
1866
|
const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
|
|
1874
|
-
const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.
|
|
1867
|
+
const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.findParentAttribute(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
1875
1868
|
if (isInsideJSXPropValue) {
|
|
1876
1869
|
if (!core.isDeclaredInRenderPropLoose(component)) {
|
|
1877
1870
|
context.report({
|
|
@@ -2680,15 +2673,6 @@ function isAssignmentToThisState2(node) {
|
|
|
2680
2673
|
const { left } = node;
|
|
2681
2674
|
return left.type === types.AST_NODE_TYPES.MemberExpression && AST11__namespace.isThisExpression(left.object) && getName4(left.property) === "state";
|
|
2682
2675
|
}
|
|
2683
|
-
var isGetDerivedStateFromProps = tsPattern.isMatching({
|
|
2684
|
-
key: {
|
|
2685
|
-
name: "getDerivedStateFromProps"
|
|
2686
|
-
},
|
|
2687
|
-
static: true,
|
|
2688
|
-
value: {
|
|
2689
|
-
params: tsPattern.P.array()
|
|
2690
|
-
}
|
|
2691
|
-
});
|
|
2692
2676
|
var no_unused_state_default = createRule({
|
|
2693
2677
|
meta: {
|
|
2694
2678
|
type: "problem",
|
|
@@ -2735,7 +2719,7 @@ var no_unused_state_default = createRule({
|
|
|
2735
2719
|
return;
|
|
2736
2720
|
}
|
|
2737
2721
|
if (node.static) {
|
|
2738
|
-
if (isGetDerivedStateFromProps(node) &&
|
|
2722
|
+
if (core.isGetDerivedStateFromProps(node) && tsPattern.isMatching({ params: [tsPattern.P.nonNullable, ...tsPattern.P.array()] })(node.value)) {
|
|
2739
2723
|
const defNode = stateDefs.get(currentClass)?.node;
|
|
2740
2724
|
stateDefs.set(currentClass, { node: defNode, isUsed: true });
|
|
2741
2725
|
}
|
|
@@ -2908,9 +2892,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2908
2892
|
const { allowExpressions = true } = option;
|
|
2909
2893
|
return {
|
|
2910
2894
|
JSXElement(node) {
|
|
2911
|
-
if (JSX7__namespace.
|
|
2912
|
-
return;
|
|
2913
|
-
}
|
|
2895
|
+
if (!JSX7__namespace.isFragmentElement(node)) return;
|
|
2914
2896
|
checkAndReport(node, context, allowExpressions);
|
|
2915
2897
|
},
|
|
2916
2898
|
JSXFragment(node) {
|
|
@@ -3022,7 +3004,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3022
3004
|
},
|
|
3023
3005
|
name: RULE_NAME46,
|
|
3024
3006
|
create(context) {
|
|
3025
|
-
const importSource = shared.getSettingsFromContext(context)
|
|
3007
|
+
const { importSource } = shared.getSettingsFromContext(context);
|
|
3026
3008
|
return {
|
|
3027
3009
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
3028
3010
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
@@ -3168,9 +3150,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3168
3150
|
create(context) {
|
|
3169
3151
|
return {
|
|
3170
3152
|
JSXElement(node) {
|
|
3171
|
-
if (JSX7__namespace.
|
|
3172
|
-
return;
|
|
3173
|
-
}
|
|
3153
|
+
if (!JSX7__namespace.isFragmentElement(node)) return;
|
|
3174
3154
|
const hasAttributes = node.openingElement.attributes.length > 0;
|
|
3175
3155
|
if (hasAttributes) {
|
|
3176
3156
|
return;
|
|
@@ -3184,9 +3164,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3184
3164
|
return [];
|
|
3185
3165
|
}
|
|
3186
3166
|
return [
|
|
3187
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3188
3167
|
fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
|
|
3189
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3190
3168
|
fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
|
|
3191
3169
|
];
|
|
3192
3170
|
}
|
|
@@ -3202,7 +3180,6 @@ var use_jsx_vars_default = createRule({
|
|
|
3202
3180
|
meta: {
|
|
3203
3181
|
type: "problem",
|
|
3204
3182
|
docs: {
|
|
3205
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
3206
3183
|
description: "helpes `eslint/no-unused-vars` to correctly mark JSX variables as used.",
|
|
3207
3184
|
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3208
3185
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT, ERFunctionComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, ERClassComponentFlag, isReactHookCall, isCreateElementCall, isInitializedFromReact } from '@eslint-react/core';
|
|
4
|
+
import { isForwardRefCall, isThisSetState, isClassComponent, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT, ERFunctionComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, ERClassComponentFlag, isReactHookCall, isCreateElementCall, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
5
5
|
import { _, getOrUpdate } from '@eslint-react/eff';
|
|
6
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
7
7
|
import { isMatching, match, P } from 'ts-pattern';
|
|
@@ -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.0
|
|
18
|
+
var version = "1.24.0";
|
|
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({
|
|
@@ -634,12 +634,6 @@ var RULE_NAME12 = "no-class-component";
|
|
|
634
634
|
var RULE_FEATURES12 = [
|
|
635
635
|
"CHK"
|
|
636
636
|
];
|
|
637
|
-
function isComponentDidCatch(node) {
|
|
638
|
-
return (node.type === AST_NODE_TYPES.MethodDefinition || node.type === AST_NODE_TYPES.PropertyDefinition) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
639
|
-
}
|
|
640
|
-
function isGetDerivedStateFromError(node) {
|
|
641
|
-
return (node.type === AST_NODE_TYPES.MethodDefinition || node.type === AST_NODE_TYPES.PropertyDefinition) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
642
|
-
}
|
|
643
637
|
var no_class_component_default = createRule({
|
|
644
638
|
meta: {
|
|
645
639
|
type: "problem",
|
|
@@ -670,7 +664,6 @@ var no_class_component_default = createRule({
|
|
|
670
664
|
messageId: "noClassComponent",
|
|
671
665
|
node: component,
|
|
672
666
|
data: {
|
|
673
|
-
// eslint-disable-next-line eslint-plugin/no-unused-placeholders
|
|
674
667
|
name: name2
|
|
675
668
|
}
|
|
676
669
|
});
|
|
@@ -991,7 +984,7 @@ var no_context_provider_default = createRule({
|
|
|
991
984
|
}
|
|
992
985
|
return {
|
|
993
986
|
JSXElement(node) {
|
|
994
|
-
const elementName = JSX7.getElementName(node
|
|
987
|
+
const elementName = JSX7.getElementName(node);
|
|
995
988
|
if (!elementName.endsWith(".Provider")) {
|
|
996
989
|
return;
|
|
997
990
|
}
|
|
@@ -1417,7 +1410,7 @@ var no_implicit_key_default = createRule({
|
|
|
1417
1410
|
return {
|
|
1418
1411
|
JSXOpeningElement(node) {
|
|
1419
1412
|
const initialScope = context.sourceCode.getScope(node);
|
|
1420
|
-
const keyPropFound = JSX7.
|
|
1413
|
+
const keyPropFound = JSX7.getAttribute("key", node.attributes, initialScope);
|
|
1421
1414
|
const keyPropOnElement = node.attributes.some(
|
|
1422
1415
|
(n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
|
|
1423
1416
|
);
|
|
@@ -1562,7 +1555,7 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1562
1555
|
return getReportDescriptor(right);
|
|
1563
1556
|
}
|
|
1564
1557
|
const initialScope = context.sourceCode.getScope(left);
|
|
1565
|
-
const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.
|
|
1558
|
+
const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
|
|
1566
1559
|
if (isLeftNan) {
|
|
1567
1560
|
return {
|
|
1568
1561
|
messageId: "noLeakedConditionalRendering",
|
|
@@ -1681,7 +1674,7 @@ var no_missing_key_default = createRule({
|
|
|
1681
1674
|
switch (node.type) {
|
|
1682
1675
|
case AST_NODE_TYPES.JSXElement: {
|
|
1683
1676
|
const initialScope = context.sourceCode.getScope(node);
|
|
1684
|
-
if (!JSX7.hasAttribute("key",
|
|
1677
|
+
if (!JSX7.hasAttribute("key", node.openingElement.attributes, initialScope)) {
|
|
1685
1678
|
return {
|
|
1686
1679
|
messageId: "noMissingKey",
|
|
1687
1680
|
node
|
|
@@ -1742,7 +1735,7 @@ var no_missing_key_default = createRule({
|
|
|
1742
1735
|
}
|
|
1743
1736
|
const initialScope = context.sourceCode.getScope(node);
|
|
1744
1737
|
for (const element of elements) {
|
|
1745
|
-
if (!JSX7.hasAttribute("key",
|
|
1738
|
+
if (!JSX7.hasAttribute("key", element.openingElement.attributes, initialScope)) {
|
|
1746
1739
|
context.report({
|
|
1747
1740
|
messageId: "noMissingKey",
|
|
1748
1741
|
node: element
|
|
@@ -1844,7 +1837,7 @@ var no_nested_components_default = createRule({
|
|
|
1844
1837
|
continue;
|
|
1845
1838
|
}
|
|
1846
1839
|
const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
|
|
1847
|
-
const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || JSX7.
|
|
1840
|
+
const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || JSX7.findParentAttribute(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
|
|
1848
1841
|
if (isInsideJSXPropValue) {
|
|
1849
1842
|
if (!isDeclaredInRenderPropLoose(component)) {
|
|
1850
1843
|
context.report({
|
|
@@ -2653,15 +2646,6 @@ function isAssignmentToThisState2(node) {
|
|
|
2653
2646
|
const { left } = node;
|
|
2654
2647
|
return left.type === AST_NODE_TYPES.MemberExpression && AST11.isThisExpression(left.object) && getName4(left.property) === "state";
|
|
2655
2648
|
}
|
|
2656
|
-
var isGetDerivedStateFromProps = isMatching({
|
|
2657
|
-
key: {
|
|
2658
|
-
name: "getDerivedStateFromProps"
|
|
2659
|
-
},
|
|
2660
|
-
static: true,
|
|
2661
|
-
value: {
|
|
2662
|
-
params: P.array()
|
|
2663
|
-
}
|
|
2664
|
-
});
|
|
2665
2649
|
var no_unused_state_default = createRule({
|
|
2666
2650
|
meta: {
|
|
2667
2651
|
type: "problem",
|
|
@@ -2708,7 +2692,7 @@ var no_unused_state_default = createRule({
|
|
|
2708
2692
|
return;
|
|
2709
2693
|
}
|
|
2710
2694
|
if (node.static) {
|
|
2711
|
-
if (isGetDerivedStateFromProps(node) &&
|
|
2695
|
+
if (isGetDerivedStateFromProps(node) && isMatching({ params: [P.nonNullable, ...P.array()] })(node.value)) {
|
|
2712
2696
|
const defNode = stateDefs.get(currentClass)?.node;
|
|
2713
2697
|
stateDefs.set(currentClass, { node: defNode, isUsed: true });
|
|
2714
2698
|
}
|
|
@@ -2881,9 +2865,7 @@ var no_useless_fragment_default = createRule({
|
|
|
2881
2865
|
const { allowExpressions = true } = option;
|
|
2882
2866
|
return {
|
|
2883
2867
|
JSXElement(node) {
|
|
2884
|
-
if (JSX7.
|
|
2885
|
-
return;
|
|
2886
|
-
}
|
|
2868
|
+
if (!JSX7.isFragmentElement(node)) return;
|
|
2887
2869
|
checkAndReport(node, context, allowExpressions);
|
|
2888
2870
|
},
|
|
2889
2871
|
JSXFragment(node) {
|
|
@@ -2995,7 +2977,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
2995
2977
|
},
|
|
2996
2978
|
name: RULE_NAME46,
|
|
2997
2979
|
create(context) {
|
|
2998
|
-
const importSource = getSettingsFromContext(context)
|
|
2980
|
+
const { importSource } = getSettingsFromContext(context);
|
|
2999
2981
|
return {
|
|
3000
2982
|
[`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
3001
2983
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
@@ -3141,9 +3123,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3141
3123
|
create(context) {
|
|
3142
3124
|
return {
|
|
3143
3125
|
JSXElement(node) {
|
|
3144
|
-
if (JSX7.
|
|
3145
|
-
return;
|
|
3146
|
-
}
|
|
3126
|
+
if (!JSX7.isFragmentElement(node)) return;
|
|
3147
3127
|
const hasAttributes = node.openingElement.attributes.length > 0;
|
|
3148
3128
|
if (hasAttributes) {
|
|
3149
3129
|
return;
|
|
@@ -3157,9 +3137,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3157
3137
|
return [];
|
|
3158
3138
|
}
|
|
3159
3139
|
return [
|
|
3160
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3161
3140
|
fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
|
|
3162
|
-
// eslint-disable-next-line eslint-plugin/prefer-replace-text
|
|
3163
3141
|
fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
|
|
3164
3142
|
];
|
|
3165
3143
|
}
|
|
@@ -3175,7 +3153,6 @@ var use_jsx_vars_default = createRule({
|
|
|
3175
3153
|
meta: {
|
|
3176
3154
|
type: "problem",
|
|
3177
3155
|
docs: {
|
|
3178
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
3179
3156
|
description: "helpes `eslint/no-unused-vars` to correctly mark JSX variables as used.",
|
|
3180
3157
|
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3181
3158
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.24.0
|
|
3
|
+
"version": "1.24.0",
|
|
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",
|
|
@@ -47,13 +47,13 @@
|
|
|
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/
|
|
52
|
-
"@eslint-react/eff": "1.24.0
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/shared": "1.24.0
|
|
50
|
+
"ts-pattern": "^5.6.1",
|
|
51
|
+
"@eslint-react/core": "1.24.0",
|
|
52
|
+
"@eslint-react/eff": "1.24.0",
|
|
53
|
+
"@eslint-react/jsx": "1.24.0",
|
|
54
|
+
"@eslint-react/var": "1.24.0",
|
|
55
|
+
"@eslint-react/ast": "1.24.0",
|
|
56
|
+
"@eslint-react/shared": "1.24.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/react": "^19.0.7",
|