eslint-plugin-react-x 2.3.2-beta.0 → 2.3.2-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 +226 -219
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import { findVariable, getChildScopes, getObjectType, getVariableDefinitionNode
|
|
|
9
9
|
import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findParentJsxAttribute, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, isAssignmentToThisState, isCaptureOwnerStackCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUpdate, isCreateContextCall, isCreateElementCall, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRefCall, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInstanceIdEqual, isJsxFragmentElement, isJsxHostElement, isJsxText, isLazyCall, isReactHookCall, isReactHookName, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseMemoCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
|
|
10
10
|
import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
11
11
|
import { compare } from "compare-versions";
|
|
12
|
-
import { camelCase } from "string-ts";
|
|
13
12
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from "@typescript-eslint/type-utils";
|
|
14
13
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
15
14
|
import { getTypeImmutability, isImmutable, isReadonlyDeep, isReadonlyShallow, isUnknown } from "is-immutable-type";
|
|
15
|
+
import { camelCase } from "string-ts";
|
|
16
16
|
|
|
17
17
|
//#region rolldown:runtime
|
|
18
18
|
var __defProp = Object.defineProperty;
|
|
@@ -28,7 +28,7 @@ var __export = (all) => {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region package.json
|
|
30
30
|
var name$6 = "eslint-plugin-react-x";
|
|
31
|
-
var version = "2.3.2-beta.
|
|
31
|
+
var version = "2.3.2-beta.2";
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/utils/create-rule.ts
|
|
@@ -1314,87 +1314,9 @@ function create$35(context) {
|
|
|
1314
1314
|
};
|
|
1315
1315
|
}
|
|
1316
1316
|
|
|
1317
|
-
//#endregion
|
|
1318
|
-
//#region src/rules/no-forbidden-props.ts
|
|
1319
|
-
const RULE_NAME$34 = "no-forbidden-props";
|
|
1320
|
-
const messageId = camelCase(RULE_NAME$34);
|
|
1321
|
-
const defaultOptions$1 = [{ forbid: [{ prop: "/_/" }] }];
|
|
1322
|
-
var no_forbidden_props_default = createRule({
|
|
1323
|
-
meta: {
|
|
1324
|
-
type: "problem",
|
|
1325
|
-
defaultOptions: [...defaultOptions$1],
|
|
1326
|
-
deprecated: true,
|
|
1327
|
-
docs: { description: "Disallow certain props on components." },
|
|
1328
|
-
messages: { [messageId]: "Prop \"{{name}}\" is forbidden." },
|
|
1329
|
-
schema: [{
|
|
1330
|
-
type: "object",
|
|
1331
|
-
additionalProperties: false,
|
|
1332
|
-
properties: { forbid: {
|
|
1333
|
-
type: "array",
|
|
1334
|
-
items: { anyOf: [
|
|
1335
|
-
{ type: "string" },
|
|
1336
|
-
{
|
|
1337
|
-
type: "object",
|
|
1338
|
-
additionalProperties: false,
|
|
1339
|
-
properties: {
|
|
1340
|
-
excludedNodes: {
|
|
1341
|
-
type: "array",
|
|
1342
|
-
items: { type: "string" },
|
|
1343
|
-
uniqueItems: true
|
|
1344
|
-
},
|
|
1345
|
-
prop: { type: "string" }
|
|
1346
|
-
},
|
|
1347
|
-
required: ["prop"]
|
|
1348
|
-
},
|
|
1349
|
-
{
|
|
1350
|
-
type: "object",
|
|
1351
|
-
additionalProperties: false,
|
|
1352
|
-
properties: {
|
|
1353
|
-
includedNodes: {
|
|
1354
|
-
type: "array",
|
|
1355
|
-
items: { type: "string" },
|
|
1356
|
-
uniqueItems: true
|
|
1357
|
-
},
|
|
1358
|
-
prop: { type: "string" }
|
|
1359
|
-
},
|
|
1360
|
-
required: ["prop"]
|
|
1361
|
-
}
|
|
1362
|
-
] }
|
|
1363
|
-
} }
|
|
1364
|
-
}]
|
|
1365
|
-
},
|
|
1366
|
-
name: RULE_NAME$34,
|
|
1367
|
-
create: create$34,
|
|
1368
|
-
defaultOptions: defaultOptions$1
|
|
1369
|
-
});
|
|
1370
|
-
function create$34(context, [option]) {
|
|
1371
|
-
const { forbid = [{ prop: "/_/" }] } = option;
|
|
1372
|
-
return { JSXOpeningElement(node) {
|
|
1373
|
-
let nodeName = null;
|
|
1374
|
-
if (node.name.type === AST_NODE_TYPES.JSXIdentifier) nodeName = node.name.name;
|
|
1375
|
-
else if (node.name.type === AST_NODE_TYPES.JSXNamespacedName) nodeName = node.name.name.name;
|
|
1376
|
-
for (const attr of node.attributes) {
|
|
1377
|
-
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
|
|
1378
|
-
const name$7 = attr.name.name;
|
|
1379
|
-
if (typeof name$7 !== "string") continue;
|
|
1380
|
-
for (const forbiddenPropItem of forbid) {
|
|
1381
|
-
if (typeof forbiddenPropItem !== "string" && nodeName != null) {
|
|
1382
|
-
if ("excludedNodes" in forbiddenPropItem && forbiddenPropItem.excludedNodes.includes(nodeName)) continue;
|
|
1383
|
-
if ("includedNodes" in forbiddenPropItem && !forbiddenPropItem.includedNodes.includes(nodeName)) continue;
|
|
1384
|
-
}
|
|
1385
|
-
if (toRegExp(typeof forbiddenPropItem === "string" ? forbiddenPropItem : forbiddenPropItem.prop).test(name$7)) context.report({
|
|
1386
|
-
messageId,
|
|
1387
|
-
node: attr,
|
|
1388
|
-
data: { name: name$7 }
|
|
1389
|
-
});
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
} };
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
1317
|
//#endregion
|
|
1396
1318
|
//#region src/rules/no-forward-ref.ts
|
|
1397
|
-
const RULE_NAME$
|
|
1319
|
+
const RULE_NAME$34 = "no-forward-ref";
|
|
1398
1320
|
const RULE_FEATURES$32 = ["MOD"];
|
|
1399
1321
|
var no_forward_ref_default = createRule({
|
|
1400
1322
|
meta: {
|
|
@@ -1407,11 +1329,11 @@ var no_forward_ref_default = createRule({
|
|
|
1407
1329
|
messages: { noForwardRef: "In React 19, 'forwardRef' is no longer necessary. Pass 'ref' as a prop instead." },
|
|
1408
1330
|
schema: []
|
|
1409
1331
|
},
|
|
1410
|
-
name: RULE_NAME$
|
|
1411
|
-
create: create$
|
|
1332
|
+
name: RULE_NAME$34,
|
|
1333
|
+
create: create$34,
|
|
1412
1334
|
defaultOptions: []
|
|
1413
1335
|
});
|
|
1414
|
-
function create$
|
|
1336
|
+
function create$34(context) {
|
|
1415
1337
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
1416
1338
|
const { version: version$1 } = getSettingsFromContext(context);
|
|
1417
1339
|
if (compare(version$1, "19.0.0", "<")) return {};
|
|
@@ -1506,7 +1428,7 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1506
1428
|
|
|
1507
1429
|
//#endregion
|
|
1508
1430
|
//#region src/rules/no-implicit-key.ts
|
|
1509
|
-
const RULE_NAME$
|
|
1431
|
+
const RULE_NAME$33 = "no-implicit-key";
|
|
1510
1432
|
const RULE_FEATURES$31 = ["EXP"];
|
|
1511
1433
|
var no_implicit_key_default = createRule({
|
|
1512
1434
|
meta: {
|
|
@@ -1518,11 +1440,11 @@ var no_implicit_key_default = createRule({
|
|
|
1518
1440
|
messages: { noImplicitKey: "Do not use implicit 'key' props." },
|
|
1519
1441
|
schema: []
|
|
1520
1442
|
},
|
|
1521
|
-
name: RULE_NAME$
|
|
1522
|
-
create: create$
|
|
1443
|
+
name: RULE_NAME$33,
|
|
1444
|
+
create: create$33,
|
|
1523
1445
|
defaultOptions: []
|
|
1524
1446
|
});
|
|
1525
|
-
function create$
|
|
1447
|
+
function create$33(context) {
|
|
1526
1448
|
return { JSXOpeningElement(node) {
|
|
1527
1449
|
const keyProp = getJsxAttribute(context, node.parent)("key");
|
|
1528
1450
|
const isKeyPropOnElement = node.attributes.some((n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key");
|
|
@@ -1535,7 +1457,7 @@ function create$32(context) {
|
|
|
1535
1457
|
|
|
1536
1458
|
//#endregion
|
|
1537
1459
|
//#region src/rules/no-leaked-conditional-rendering.ts
|
|
1538
|
-
const RULE_NAME$
|
|
1460
|
+
const RULE_NAME$32 = "no-leaked-conditional-rendering";
|
|
1539
1461
|
const RULE_FEATURES$30 = ["TSC"];
|
|
1540
1462
|
var no_leaked_conditional_rendering_default = createRule({
|
|
1541
1463
|
meta: {
|
|
@@ -1547,11 +1469,11 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
1547
1469
|
messages: { noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
|
|
1548
1470
|
schema: []
|
|
1549
1471
|
},
|
|
1550
|
-
name: RULE_NAME$
|
|
1551
|
-
create: create$
|
|
1472
|
+
name: RULE_NAME$32,
|
|
1473
|
+
create: create$32,
|
|
1552
1474
|
defaultOptions: []
|
|
1553
1475
|
});
|
|
1554
|
-
function create$
|
|
1476
|
+
function create$32(context) {
|
|
1555
1477
|
if (!context.sourceCode.text.includes("&&")) return {};
|
|
1556
1478
|
const { version: version$1 } = getSettingsFromContext(context);
|
|
1557
1479
|
const allowedVariants = [
|
|
@@ -1607,7 +1529,7 @@ function create$31(context) {
|
|
|
1607
1529
|
|
|
1608
1530
|
//#endregion
|
|
1609
1531
|
//#region src/rules/no-missing-component-display-name.ts
|
|
1610
|
-
const RULE_NAME$
|
|
1532
|
+
const RULE_NAME$31 = "no-missing-component-display-name";
|
|
1611
1533
|
const RULE_FEATURES$29 = [];
|
|
1612
1534
|
var no_missing_component_display_name_default = createRule({
|
|
1613
1535
|
meta: {
|
|
@@ -1619,11 +1541,11 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1619
1541
|
messages: { noMissingComponentDisplayName: "Add missing 'displayName' for component." },
|
|
1620
1542
|
schema: []
|
|
1621
1543
|
},
|
|
1622
|
-
name: RULE_NAME$
|
|
1623
|
-
create: create$
|
|
1544
|
+
name: RULE_NAME$31,
|
|
1545
|
+
create: create$31,
|
|
1624
1546
|
defaultOptions: []
|
|
1625
1547
|
});
|
|
1626
|
-
function create$
|
|
1548
|
+
function create$31(context) {
|
|
1627
1549
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1628
1550
|
const { ctx, listeners } = useComponentCollector(context, {
|
|
1629
1551
|
collectDisplayName: true,
|
|
@@ -1652,7 +1574,7 @@ function create$30(context) {
|
|
|
1652
1574
|
|
|
1653
1575
|
//#endregion
|
|
1654
1576
|
//#region src/rules/no-missing-context-display-name.ts
|
|
1655
|
-
const RULE_NAME$
|
|
1577
|
+
const RULE_NAME$30 = "no-missing-context-display-name";
|
|
1656
1578
|
const RULE_FEATURES$28 = ["FIX"];
|
|
1657
1579
|
var no_missing_context_display_name_default = createRule({
|
|
1658
1580
|
meta: {
|
|
@@ -1665,11 +1587,11 @@ var no_missing_context_display_name_default = createRule({
|
|
|
1665
1587
|
messages: { noMissingContextDisplayName: "Add missing 'displayName' for context." },
|
|
1666
1588
|
schema: []
|
|
1667
1589
|
},
|
|
1668
|
-
name: RULE_NAME$
|
|
1669
|
-
create: create$
|
|
1590
|
+
name: RULE_NAME$30,
|
|
1591
|
+
create: create$30,
|
|
1670
1592
|
defaultOptions: []
|
|
1671
1593
|
});
|
|
1672
|
-
function create$
|
|
1594
|
+
function create$30(context) {
|
|
1673
1595
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1674
1596
|
const createCalls = [];
|
|
1675
1597
|
const displayNameAssignments = [];
|
|
@@ -1721,7 +1643,7 @@ function create$29(context) {
|
|
|
1721
1643
|
|
|
1722
1644
|
//#endregion
|
|
1723
1645
|
//#region src/rules/no-missing-key.ts
|
|
1724
|
-
const RULE_NAME$
|
|
1646
|
+
const RULE_NAME$29 = "no-missing-key";
|
|
1725
1647
|
const RULE_FEATURES$27 = [];
|
|
1726
1648
|
var no_missing_key_default = createRule({
|
|
1727
1649
|
meta: {
|
|
@@ -1736,11 +1658,11 @@ var no_missing_key_default = createRule({
|
|
|
1736
1658
|
},
|
|
1737
1659
|
schema: []
|
|
1738
1660
|
},
|
|
1739
|
-
name: RULE_NAME$
|
|
1740
|
-
create: create$
|
|
1661
|
+
name: RULE_NAME$29,
|
|
1662
|
+
create: create$29,
|
|
1741
1663
|
defaultOptions: []
|
|
1742
1664
|
});
|
|
1743
|
-
function create$
|
|
1665
|
+
function create$29(context) {
|
|
1744
1666
|
const state = { isWithinChildrenToArray: false };
|
|
1745
1667
|
function checkIteratorElement(node) {
|
|
1746
1668
|
switch (node.type) {
|
|
@@ -1818,7 +1740,7 @@ function create$28(context) {
|
|
|
1818
1740
|
|
|
1819
1741
|
//#endregion
|
|
1820
1742
|
//#region src/rules/no-misused-capture-owner-stack.ts
|
|
1821
|
-
const RULE_NAME$
|
|
1743
|
+
const RULE_NAME$28 = "no-misused-capture-owner-stack";
|
|
1822
1744
|
const RULE_FEATURES$26 = ["EXP"];
|
|
1823
1745
|
var no_misused_capture_owner_stack_default = createRule({
|
|
1824
1746
|
meta: {
|
|
@@ -1834,11 +1756,11 @@ var no_misused_capture_owner_stack_default = createRule({
|
|
|
1834
1756
|
},
|
|
1835
1757
|
schema: []
|
|
1836
1758
|
},
|
|
1837
|
-
name: RULE_NAME$
|
|
1838
|
-
create: create$
|
|
1759
|
+
name: RULE_NAME$28,
|
|
1760
|
+
create: create$28,
|
|
1839
1761
|
defaultOptions: []
|
|
1840
1762
|
});
|
|
1841
|
-
function create$
|
|
1763
|
+
function create$28(context) {
|
|
1842
1764
|
if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
|
|
1843
1765
|
const { importSource } = getSettingsFromContext(context);
|
|
1844
1766
|
return {
|
|
@@ -1870,7 +1792,7 @@ function isDevelopmentOnlyCheck(node) {
|
|
|
1870
1792
|
|
|
1871
1793
|
//#endregion
|
|
1872
1794
|
//#region src/rules/no-nested-component-definitions.ts
|
|
1873
|
-
const RULE_NAME$
|
|
1795
|
+
const RULE_NAME$27 = "no-nested-component-definitions";
|
|
1874
1796
|
const RULE_FEATURES$25 = [];
|
|
1875
1797
|
var no_nested_component_definitions_default = createRule({
|
|
1876
1798
|
meta: {
|
|
@@ -1882,11 +1804,11 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1882
1804
|
messages: { noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}" },
|
|
1883
1805
|
schema: []
|
|
1884
1806
|
},
|
|
1885
|
-
name: RULE_NAME$
|
|
1886
|
-
create: create$
|
|
1807
|
+
name: RULE_NAME$27,
|
|
1808
|
+
create: create$27,
|
|
1887
1809
|
defaultOptions: []
|
|
1888
1810
|
});
|
|
1889
|
-
function create$
|
|
1811
|
+
function create$27(context) {
|
|
1890
1812
|
const collector = useComponentCollector(context, { hint: ComponentDetectionHint.SkipArrayMapArgument | ComponentDetectionHint.SkipNullLiteral | ComponentDetectionHint.SkipUndefined | ComponentDetectionHint.SkipBooleanLiteral | ComponentDetectionHint.SkipStringLiteral | ComponentDetectionHint.SkipNumberLiteral | ComponentDetectionHint.StrictLogical | ComponentDetectionHint.StrictConditional });
|
|
1891
1813
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
1892
1814
|
return {
|
|
@@ -1994,7 +1916,7 @@ function isInsideCreateElementProps(context, node) {
|
|
|
1994
1916
|
|
|
1995
1917
|
//#endregion
|
|
1996
1918
|
//#region src/rules/no-nested-lazy-component-declarations.ts
|
|
1997
|
-
const RULE_NAME$
|
|
1919
|
+
const RULE_NAME$26 = "no-nested-lazy-component-declarations";
|
|
1998
1920
|
const RULE_FEATURES$24 = [];
|
|
1999
1921
|
var no_nested_lazy_component_declarations_default = createRule({
|
|
2000
1922
|
meta: {
|
|
@@ -2006,11 +1928,11 @@ var no_nested_lazy_component_declarations_default = createRule({
|
|
|
2006
1928
|
messages: { noNestedLazyComponentDeclarations: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module." },
|
|
2007
1929
|
schema: []
|
|
2008
1930
|
},
|
|
2009
|
-
name: RULE_NAME$
|
|
2010
|
-
create: create$
|
|
1931
|
+
name: RULE_NAME$26,
|
|
1932
|
+
create: create$26,
|
|
2011
1933
|
defaultOptions: []
|
|
2012
1934
|
});
|
|
2013
|
-
function create$
|
|
1935
|
+
function create$26(context) {
|
|
2014
1936
|
const hint = ComponentDetectionHint.None;
|
|
2015
1937
|
const collector = useComponentCollector(context, { hint });
|
|
2016
1938
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
@@ -2041,7 +1963,7 @@ function create$25(context) {
|
|
|
2041
1963
|
|
|
2042
1964
|
//#endregion
|
|
2043
1965
|
//#region src/rules/no-prop-types.ts
|
|
2044
|
-
const RULE_NAME$
|
|
1966
|
+
const RULE_NAME$25 = "no-prop-types";
|
|
2045
1967
|
const RULE_FEATURES$23 = [];
|
|
2046
1968
|
var no_prop_types_default = createRule({
|
|
2047
1969
|
meta: {
|
|
@@ -2053,11 +1975,11 @@ var no_prop_types_default = createRule({
|
|
|
2053
1975
|
messages: { noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead." },
|
|
2054
1976
|
schema: []
|
|
2055
1977
|
},
|
|
2056
|
-
name: RULE_NAME$
|
|
2057
|
-
create: create$
|
|
1978
|
+
name: RULE_NAME$25,
|
|
1979
|
+
create: create$25,
|
|
2058
1980
|
defaultOptions: []
|
|
2059
1981
|
});
|
|
2060
|
-
function create$
|
|
1982
|
+
function create$25(context) {
|
|
2061
1983
|
if (!context.sourceCode.text.includes("propTypes")) return {};
|
|
2062
1984
|
return {
|
|
2063
1985
|
AssignmentExpression(node) {
|
|
@@ -2085,7 +2007,7 @@ function create$24(context) {
|
|
|
2085
2007
|
|
|
2086
2008
|
//#endregion
|
|
2087
2009
|
//#region src/rules/no-redundant-should-component-update.ts
|
|
2088
|
-
const RULE_NAME$
|
|
2010
|
+
const RULE_NAME$24 = "no-redundant-should-component-update";
|
|
2089
2011
|
const RULE_FEATURES$22 = [];
|
|
2090
2012
|
function isShouldComponentUpdate(node) {
|
|
2091
2013
|
return AST.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
@@ -2100,11 +2022,11 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2100
2022
|
messages: { noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'." },
|
|
2101
2023
|
schema: []
|
|
2102
2024
|
},
|
|
2103
|
-
name: RULE_NAME$
|
|
2104
|
-
create: create$
|
|
2025
|
+
name: RULE_NAME$24,
|
|
2026
|
+
create: create$24,
|
|
2105
2027
|
defaultOptions: []
|
|
2106
2028
|
});
|
|
2107
|
-
function create$
|
|
2029
|
+
function create$24(context) {
|
|
2108
2030
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
|
|
2109
2031
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2110
2032
|
return {
|
|
@@ -2126,7 +2048,7 @@ function create$23(context) {
|
|
|
2126
2048
|
|
|
2127
2049
|
//#endregion
|
|
2128
2050
|
//#region src/rules/no-set-state-in-component-did-mount.ts
|
|
2129
|
-
const RULE_NAME$
|
|
2051
|
+
const RULE_NAME$23 = "no-set-state-in-component-did-mount";
|
|
2130
2052
|
const RULE_FEATURES$21 = [];
|
|
2131
2053
|
var no_set_state_in_component_did_mount_default = createRule({
|
|
2132
2054
|
meta: {
|
|
@@ -2138,11 +2060,11 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2138
2060
|
messages: { noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks." },
|
|
2139
2061
|
schema: []
|
|
2140
2062
|
},
|
|
2141
|
-
name: RULE_NAME$
|
|
2142
|
-
create: create$
|
|
2063
|
+
name: RULE_NAME$23,
|
|
2064
|
+
create: create$23,
|
|
2143
2065
|
defaultOptions: []
|
|
2144
2066
|
});
|
|
2145
|
-
function create$
|
|
2067
|
+
function create$23(context) {
|
|
2146
2068
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2147
2069
|
return { CallExpression(node) {
|
|
2148
2070
|
if (!isThisSetState(node)) return;
|
|
@@ -2160,7 +2082,7 @@ function create$22(context) {
|
|
|
2160
2082
|
|
|
2161
2083
|
//#endregion
|
|
2162
2084
|
//#region src/rules/no-set-state-in-component-did-update.ts
|
|
2163
|
-
const RULE_NAME$
|
|
2085
|
+
const RULE_NAME$22 = "no-set-state-in-component-did-update";
|
|
2164
2086
|
const RULE_FEATURES$20 = [];
|
|
2165
2087
|
var no_set_state_in_component_did_update_default = createRule({
|
|
2166
2088
|
meta: {
|
|
@@ -2172,11 +2094,11 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2172
2094
|
messages: { noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks." },
|
|
2173
2095
|
schema: []
|
|
2174
2096
|
},
|
|
2175
|
-
name: RULE_NAME$
|
|
2176
|
-
create: create$
|
|
2097
|
+
name: RULE_NAME$22,
|
|
2098
|
+
create: create$22,
|
|
2177
2099
|
defaultOptions: []
|
|
2178
2100
|
});
|
|
2179
|
-
function create$
|
|
2101
|
+
function create$22(context) {
|
|
2180
2102
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2181
2103
|
return { CallExpression(node) {
|
|
2182
2104
|
if (!isThisSetState(node)) return;
|
|
@@ -2194,7 +2116,7 @@ function create$21(context) {
|
|
|
2194
2116
|
|
|
2195
2117
|
//#endregion
|
|
2196
2118
|
//#region src/rules/no-set-state-in-component-will-update.ts
|
|
2197
|
-
const RULE_NAME$
|
|
2119
|
+
const RULE_NAME$21 = "no-set-state-in-component-will-update";
|
|
2198
2120
|
const RULE_FEATURES$19 = [];
|
|
2199
2121
|
var no_set_state_in_component_will_update_default = createRule({
|
|
2200
2122
|
meta: {
|
|
@@ -2206,11 +2128,11 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2206
2128
|
messages: { noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks." },
|
|
2207
2129
|
schema: []
|
|
2208
2130
|
},
|
|
2209
|
-
name: RULE_NAME$
|
|
2210
|
-
create: create$
|
|
2131
|
+
name: RULE_NAME$21,
|
|
2132
|
+
create: create$21,
|
|
2211
2133
|
defaultOptions: []
|
|
2212
2134
|
});
|
|
2213
|
-
function create$
|
|
2135
|
+
function create$21(context) {
|
|
2214
2136
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2215
2137
|
return { CallExpression(node) {
|
|
2216
2138
|
if (!isThisSetState(node)) return;
|
|
@@ -2228,7 +2150,7 @@ function create$20(context) {
|
|
|
2228
2150
|
|
|
2229
2151
|
//#endregion
|
|
2230
2152
|
//#region src/rules/no-string-refs.ts
|
|
2231
|
-
const RULE_NAME$
|
|
2153
|
+
const RULE_NAME$20 = "no-string-refs";
|
|
2232
2154
|
const RULE_FEATURES$18 = ["MOD"];
|
|
2233
2155
|
var no_string_refs_default = createRule({
|
|
2234
2156
|
meta: {
|
|
@@ -2241,11 +2163,11 @@ var no_string_refs_default = createRule({
|
|
|
2241
2163
|
messages: { noStringRefs: "[Deprecated] Use callback refs instead." },
|
|
2242
2164
|
schema: []
|
|
2243
2165
|
},
|
|
2244
|
-
name: RULE_NAME$
|
|
2245
|
-
create: create$
|
|
2166
|
+
name: RULE_NAME$20,
|
|
2167
|
+
create: create$20,
|
|
2246
2168
|
defaultOptions: []
|
|
2247
2169
|
});
|
|
2248
|
-
function create$
|
|
2170
|
+
function create$20(context) {
|
|
2249
2171
|
const state = { isWithinClassComponent: false };
|
|
2250
2172
|
function onClassBodyEnter(node) {
|
|
2251
2173
|
if (isClassComponent(node.parent)) state.isWithinClassComponent = true;
|
|
@@ -2290,7 +2212,7 @@ function getJsxAttributeValueText(context, node) {
|
|
|
2290
2212
|
|
|
2291
2213
|
//#endregion
|
|
2292
2214
|
//#region src/rules/no-unnecessary-key.ts
|
|
2293
|
-
const RULE_NAME$
|
|
2215
|
+
const RULE_NAME$19 = "no-unnecessary-key";
|
|
2294
2216
|
const RULE_FEATURES$17 = ["EXP"];
|
|
2295
2217
|
var no_unnecessary_key_default = createRule({
|
|
2296
2218
|
meta: {
|
|
@@ -2302,11 +2224,11 @@ var no_unnecessary_key_default = createRule({
|
|
|
2302
2224
|
messages: { noUnnecessaryKey: "Unnecessary `key` prop on this element. The `key` should be on the top-level element returned from the array." },
|
|
2303
2225
|
schema: []
|
|
2304
2226
|
},
|
|
2305
|
-
name: RULE_NAME$
|
|
2306
|
-
create: create$
|
|
2227
|
+
name: RULE_NAME$19,
|
|
2228
|
+
create: create$19,
|
|
2307
2229
|
defaultOptions: []
|
|
2308
2230
|
});
|
|
2309
|
-
function create$
|
|
2231
|
+
function create$19(context) {
|
|
2310
2232
|
if (!context.sourceCode.text.includes("key=")) return {};
|
|
2311
2233
|
return { JSXAttribute(node) {
|
|
2312
2234
|
if (node.name.name !== "key") return;
|
|
@@ -2338,7 +2260,7 @@ function isMapCallback(node) {
|
|
|
2338
2260
|
|
|
2339
2261
|
//#endregion
|
|
2340
2262
|
//#region src/rules/no-unnecessary-use-callback.ts
|
|
2341
|
-
const RULE_NAME$
|
|
2263
|
+
const RULE_NAME$18 = "no-unnecessary-use-callback";
|
|
2342
2264
|
const RULE_FEATURES$16 = ["EXP"];
|
|
2343
2265
|
var no_unnecessary_use_callback_default = createRule({
|
|
2344
2266
|
meta: {
|
|
@@ -2350,11 +2272,11 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
2350
2272
|
messages: { noUnnecessaryUseCallback: "An 'useCallback' with empty deps and no references to the component scope may be unnecessary." },
|
|
2351
2273
|
schema: []
|
|
2352
2274
|
},
|
|
2353
|
-
name: RULE_NAME$
|
|
2354
|
-
create: create$
|
|
2275
|
+
name: RULE_NAME$18,
|
|
2276
|
+
create: create$18,
|
|
2355
2277
|
defaultOptions: []
|
|
2356
2278
|
});
|
|
2357
|
-
function create$
|
|
2279
|
+
function create$18(context) {
|
|
2358
2280
|
if (!context.sourceCode.text.includes("useCallback")) return {};
|
|
2359
2281
|
return { CallExpression(node) {
|
|
2360
2282
|
if (!isUseCallbackCall(node)) return;
|
|
@@ -2386,7 +2308,7 @@ function create$17(context) {
|
|
|
2386
2308
|
|
|
2387
2309
|
//#endregion
|
|
2388
2310
|
//#region src/rules/no-unnecessary-use-memo.ts
|
|
2389
|
-
const RULE_NAME$
|
|
2311
|
+
const RULE_NAME$17 = "no-unnecessary-use-memo";
|
|
2390
2312
|
const RULE_FEATURES$15 = ["EXP"];
|
|
2391
2313
|
var no_unnecessary_use_memo_default = createRule({
|
|
2392
2314
|
meta: {
|
|
@@ -2398,11 +2320,11 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
2398
2320
|
messages: { noUnnecessaryUseMemo: "An 'useMemo' with empty deps and no references to the component scope may be unnecessary." },
|
|
2399
2321
|
schema: []
|
|
2400
2322
|
},
|
|
2401
|
-
name: RULE_NAME$
|
|
2402
|
-
create: create$
|
|
2323
|
+
name: RULE_NAME$17,
|
|
2324
|
+
create: create$17,
|
|
2403
2325
|
defaultOptions: []
|
|
2404
2326
|
});
|
|
2405
|
-
function create$
|
|
2327
|
+
function create$17(context) {
|
|
2406
2328
|
if (!context.sourceCode.text.includes("useMemo")) return {};
|
|
2407
2329
|
return { CallExpression(node) {
|
|
2408
2330
|
const initialScope = context.sourceCode.getScope(node);
|
|
@@ -2435,7 +2357,7 @@ function create$16(context) {
|
|
|
2435
2357
|
|
|
2436
2358
|
//#endregion
|
|
2437
2359
|
//#region src/rules/no-unnecessary-use-prefix.ts
|
|
2438
|
-
const RULE_NAME$
|
|
2360
|
+
const RULE_NAME$16 = "no-unnecessary-use-prefix";
|
|
2439
2361
|
const RULE_FEATURES$14 = ["EXP"];
|
|
2440
2362
|
const WELL_KNOWN_HOOKS = ["useMDXComponents"];
|
|
2441
2363
|
function containsUseComments(context, node) {
|
|
@@ -2451,11 +2373,11 @@ var no_unnecessary_use_prefix_default = createRule({
|
|
|
2451
2373
|
messages: { noUnnecessaryUsePrefix: "If your function doesn't call any Hooks, avoid the 'use' prefix. Instead, write it as a regular function without the 'use' prefix." },
|
|
2452
2374
|
schema: []
|
|
2453
2375
|
},
|
|
2454
|
-
name: RULE_NAME$
|
|
2455
|
-
create: create$
|
|
2376
|
+
name: RULE_NAME$16,
|
|
2377
|
+
create: create$16,
|
|
2456
2378
|
defaultOptions: []
|
|
2457
2379
|
});
|
|
2458
|
-
function create$
|
|
2380
|
+
function create$16(context) {
|
|
2459
2381
|
const { ctx, listeners } = useHookCollector();
|
|
2460
2382
|
return {
|
|
2461
2383
|
...listeners,
|
|
@@ -2479,7 +2401,7 @@ function create$15(context) {
|
|
|
2479
2401
|
|
|
2480
2402
|
//#endregion
|
|
2481
2403
|
//#region src/rules/no-unsafe-component-will-mount.ts
|
|
2482
|
-
const RULE_NAME$
|
|
2404
|
+
const RULE_NAME$15 = "no-unsafe-component-will-mount";
|
|
2483
2405
|
const RULE_FEATURES$13 = [];
|
|
2484
2406
|
var no_unsafe_component_will_mount_default = createRule({
|
|
2485
2407
|
meta: {
|
|
@@ -2491,11 +2413,11 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2491
2413
|
messages: { noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'." },
|
|
2492
2414
|
schema: []
|
|
2493
2415
|
},
|
|
2494
|
-
name: RULE_NAME$
|
|
2495
|
-
create: create$
|
|
2416
|
+
name: RULE_NAME$15,
|
|
2417
|
+
create: create$15,
|
|
2496
2418
|
defaultOptions: []
|
|
2497
2419
|
});
|
|
2498
|
-
function create$
|
|
2420
|
+
function create$15(context) {
|
|
2499
2421
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
2500
2422
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2501
2423
|
return {
|
|
@@ -2515,7 +2437,7 @@ function create$14(context) {
|
|
|
2515
2437
|
|
|
2516
2438
|
//#endregion
|
|
2517
2439
|
//#region src/rules/no-unsafe-component-will-receive-props.ts
|
|
2518
|
-
const RULE_NAME$
|
|
2440
|
+
const RULE_NAME$14 = "no-unsafe-component-will-receive-props";
|
|
2519
2441
|
const RULE_FEATURES$12 = [];
|
|
2520
2442
|
var no_unsafe_component_will_receive_props_default = createRule({
|
|
2521
2443
|
meta: {
|
|
@@ -2527,11 +2449,11 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2527
2449
|
messages: { noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'." },
|
|
2528
2450
|
schema: []
|
|
2529
2451
|
},
|
|
2530
|
-
name: RULE_NAME$
|
|
2531
|
-
create: create$
|
|
2452
|
+
name: RULE_NAME$14,
|
|
2453
|
+
create: create$14,
|
|
2532
2454
|
defaultOptions: []
|
|
2533
2455
|
});
|
|
2534
|
-
function create$
|
|
2456
|
+
function create$14(context) {
|
|
2535
2457
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
|
|
2536
2458
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2537
2459
|
return {
|
|
@@ -2551,7 +2473,7 @@ function create$13(context) {
|
|
|
2551
2473
|
|
|
2552
2474
|
//#endregion
|
|
2553
2475
|
//#region src/rules/no-unsafe-component-will-update.ts
|
|
2554
|
-
const RULE_NAME$
|
|
2476
|
+
const RULE_NAME$13 = "no-unsafe-component-will-update";
|
|
2555
2477
|
const RULE_FEATURES$11 = [];
|
|
2556
2478
|
var no_unsafe_component_will_update_default = createRule({
|
|
2557
2479
|
meta: {
|
|
@@ -2563,11 +2485,11 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2563
2485
|
messages: { noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'." },
|
|
2564
2486
|
schema: []
|
|
2565
2487
|
},
|
|
2566
|
-
name: RULE_NAME$
|
|
2567
|
-
create: create$
|
|
2488
|
+
name: RULE_NAME$13,
|
|
2489
|
+
create: create$13,
|
|
2568
2490
|
defaultOptions: []
|
|
2569
2491
|
});
|
|
2570
|
-
function create$
|
|
2492
|
+
function create$13(context) {
|
|
2571
2493
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
2572
2494
|
const { ctx, listeners } = useComponentCollectorLegacy();
|
|
2573
2495
|
return {
|
|
@@ -2587,7 +2509,7 @@ function create$12(context) {
|
|
|
2587
2509
|
|
|
2588
2510
|
//#endregion
|
|
2589
2511
|
//#region src/rules/no-unstable-context-value.ts
|
|
2590
|
-
const RULE_NAME$
|
|
2512
|
+
const RULE_NAME$12 = "no-unstable-context-value";
|
|
2591
2513
|
const RULE_FEATURES$10 = [];
|
|
2592
2514
|
var no_unstable_context_value_default = createRule({
|
|
2593
2515
|
meta: {
|
|
@@ -2599,11 +2521,11 @@ var no_unstable_context_value_default = createRule({
|
|
|
2599
2521
|
messages: { unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}" },
|
|
2600
2522
|
schema: []
|
|
2601
2523
|
},
|
|
2602
|
-
name: RULE_NAME$
|
|
2603
|
-
create: create$
|
|
2524
|
+
name: RULE_NAME$12,
|
|
2525
|
+
create: create$12,
|
|
2604
2526
|
defaultOptions: []
|
|
2605
2527
|
});
|
|
2606
|
-
function create$
|
|
2528
|
+
function create$12(context) {
|
|
2607
2529
|
const { version: version$1 } = getSettingsFromContext(context);
|
|
2608
2530
|
const isReact18OrBelow = compare(version$1, "19.0.0", "<");
|
|
2609
2531
|
const { ctx, listeners } = useComponentCollector(context);
|
|
@@ -2651,7 +2573,7 @@ function isContextName(name$7, isReact18OrBelow) {
|
|
|
2651
2573
|
|
|
2652
2574
|
//#endregion
|
|
2653
2575
|
//#region src/rules/no-unstable-default-props.ts
|
|
2654
|
-
const RULE_NAME$
|
|
2576
|
+
const RULE_NAME$11 = "no-unstable-default-props";
|
|
2655
2577
|
const RULE_FEATURES$9 = [];
|
|
2656
2578
|
var no_unstable_default_props_default = createRule({
|
|
2657
2579
|
meta: {
|
|
@@ -2663,11 +2585,11 @@ var no_unstable_default_props_default = createRule({
|
|
|
2663
2585
|
messages: { noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'." },
|
|
2664
2586
|
schema: []
|
|
2665
2587
|
},
|
|
2666
|
-
name: RULE_NAME$
|
|
2667
|
-
create: create$
|
|
2588
|
+
name: RULE_NAME$11,
|
|
2589
|
+
create: create$11,
|
|
2668
2590
|
defaultOptions: []
|
|
2669
2591
|
});
|
|
2670
|
-
function create$
|
|
2592
|
+
function create$11(context) {
|
|
2671
2593
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2672
2594
|
const declarators = /* @__PURE__ */ new WeakMap();
|
|
2673
2595
|
return {
|
|
@@ -2707,7 +2629,7 @@ function create$10(context) {
|
|
|
2707
2629
|
|
|
2708
2630
|
//#endregion
|
|
2709
2631
|
//#region src/rules/no-unused-class-component-members.ts
|
|
2710
|
-
const RULE_NAME$
|
|
2632
|
+
const RULE_NAME$10 = "no-unused-class-component-members";
|
|
2711
2633
|
const RULE_FEATURES$8 = [];
|
|
2712
2634
|
const LIFECYCLE_METHODS = new Set([
|
|
2713
2635
|
"componentDidCatch",
|
|
@@ -2742,11 +2664,11 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2742
2664
|
messages: { noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'." },
|
|
2743
2665
|
schema: []
|
|
2744
2666
|
},
|
|
2745
|
-
name: RULE_NAME$
|
|
2746
|
-
create: create$
|
|
2667
|
+
name: RULE_NAME$10,
|
|
2668
|
+
create: create$10,
|
|
2747
2669
|
defaultOptions: []
|
|
2748
2670
|
});
|
|
2749
|
-
function create$
|
|
2671
|
+
function create$10(context) {
|
|
2750
2672
|
const classStack = [];
|
|
2751
2673
|
const methodStack = [];
|
|
2752
2674
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2827,7 +2749,7 @@ function create$9(context) {
|
|
|
2827
2749
|
|
|
2828
2750
|
//#endregion
|
|
2829
2751
|
//#region src/rules/no-unused-props.ts
|
|
2830
|
-
const RULE_NAME$
|
|
2752
|
+
const RULE_NAME$9 = "no-unused-props";
|
|
2831
2753
|
const RULE_FEATURES$7 = ["TSC", "EXP"];
|
|
2832
2754
|
var no_unused_props_default = createRule({
|
|
2833
2755
|
meta: {
|
|
@@ -2839,11 +2761,11 @@ var no_unused_props_default = createRule({
|
|
|
2839
2761
|
messages: { noUnusedProps: "Prop `{{name}}` is declared but never used" },
|
|
2840
2762
|
schema: []
|
|
2841
2763
|
},
|
|
2842
|
-
name: RULE_NAME$
|
|
2843
|
-
create: create$
|
|
2764
|
+
name: RULE_NAME$9,
|
|
2765
|
+
create: create$9,
|
|
2844
2766
|
defaultOptions: []
|
|
2845
2767
|
});
|
|
2846
|
-
function create$
|
|
2768
|
+
function create$9(context) {
|
|
2847
2769
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2848
2770
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2849
2771
|
return {
|
|
@@ -2945,7 +2867,7 @@ function reportUnusedProp(context, services, prop) {
|
|
|
2945
2867
|
|
|
2946
2868
|
//#endregion
|
|
2947
2869
|
//#region src/rules/no-unused-state.ts
|
|
2948
|
-
const RULE_NAME$
|
|
2870
|
+
const RULE_NAME$8 = "no-unused-state";
|
|
2949
2871
|
const RULE_FEATURES$6 = [];
|
|
2950
2872
|
function isKeyLiteral(node, key) {
|
|
2951
2873
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
|
|
@@ -2963,11 +2885,11 @@ var no_unused_state_default = createRule({
|
|
|
2963
2885
|
messages: { noUnusedState: "Unused class component state in '{{className}}'" },
|
|
2964
2886
|
schema: []
|
|
2965
2887
|
},
|
|
2966
|
-
name: RULE_NAME$
|
|
2967
|
-
create: create$
|
|
2888
|
+
name: RULE_NAME$8,
|
|
2889
|
+
create: create$8,
|
|
2968
2890
|
defaultOptions: []
|
|
2969
2891
|
});
|
|
2970
|
-
function create$
|
|
2892
|
+
function create$8(context) {
|
|
2971
2893
|
const classStack = [];
|
|
2972
2894
|
const methodStack = [];
|
|
2973
2895
|
const constructorStack = [];
|
|
@@ -3076,7 +2998,7 @@ function create$7(context) {
|
|
|
3076
2998
|
|
|
3077
2999
|
//#endregion
|
|
3078
3000
|
//#region src/rules/no-use-context.ts
|
|
3079
|
-
const RULE_NAME$
|
|
3001
|
+
const RULE_NAME$7 = "no-use-context";
|
|
3080
3002
|
const RULE_FEATURES$5 = ["MOD"];
|
|
3081
3003
|
var no_use_context_default = createRule({
|
|
3082
3004
|
meta: {
|
|
@@ -3089,11 +3011,11 @@ var no_use_context_default = createRule({
|
|
|
3089
3011
|
messages: { noUseContext: "In React 19, 'use' is preferred over 'useContext' because it is more flexible." },
|
|
3090
3012
|
schema: []
|
|
3091
3013
|
},
|
|
3092
|
-
name: RULE_NAME$
|
|
3093
|
-
create: create$
|
|
3014
|
+
name: RULE_NAME$7,
|
|
3015
|
+
create: create$7,
|
|
3094
3016
|
defaultOptions: []
|
|
3095
3017
|
});
|
|
3096
|
-
function create$
|
|
3018
|
+
function create$7(context) {
|
|
3097
3019
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
3098
3020
|
const settings$6 = getSettingsFromContext(context);
|
|
3099
3021
|
if (compare(settings$6.version, "19.0.0", "<")) return {};
|
|
@@ -3158,7 +3080,7 @@ function getCorrelativeTokens(context, node) {
|
|
|
3158
3080
|
|
|
3159
3081
|
//#endregion
|
|
3160
3082
|
//#region src/rules/no-useless-forward-ref.ts
|
|
3161
|
-
const RULE_NAME$
|
|
3083
|
+
const RULE_NAME$6 = "no-useless-forward-ref";
|
|
3162
3084
|
const RULE_FEATURES$4 = [];
|
|
3163
3085
|
var no_useless_forward_ref_default = createRule({
|
|
3164
3086
|
meta: {
|
|
@@ -3170,11 +3092,11 @@ var no_useless_forward_ref_default = createRule({
|
|
|
3170
3092
|
messages: { noUselessForwardRef: "A 'forwardRef' is used with this component but no 'ref' parameter is set." },
|
|
3171
3093
|
schema: []
|
|
3172
3094
|
},
|
|
3173
|
-
name: RULE_NAME$
|
|
3174
|
-
create: create$
|
|
3095
|
+
name: RULE_NAME$6,
|
|
3096
|
+
create: create$6,
|
|
3175
3097
|
defaultOptions: []
|
|
3176
3098
|
});
|
|
3177
|
-
function create$
|
|
3099
|
+
function create$6(context) {
|
|
3178
3100
|
return { CallExpression(node) {
|
|
3179
3101
|
if (!isForwardRefCall(context, node)) return;
|
|
3180
3102
|
const [component] = node.arguments;
|
|
@@ -3189,12 +3111,12 @@ function create$5(context) {
|
|
|
3189
3111
|
|
|
3190
3112
|
//#endregion
|
|
3191
3113
|
//#region src/rules/no-useless-fragment.ts
|
|
3192
|
-
const RULE_NAME$
|
|
3193
|
-
const defaultOptions = [{ allowExpressions: true }];
|
|
3114
|
+
const RULE_NAME$5 = "no-useless-fragment";
|
|
3115
|
+
const defaultOptions$1 = [{ allowExpressions: true }];
|
|
3194
3116
|
var no_useless_fragment_default = createRule({
|
|
3195
3117
|
meta: {
|
|
3196
3118
|
type: "problem",
|
|
3197
|
-
defaultOptions: [...defaultOptions],
|
|
3119
|
+
defaultOptions: [...defaultOptions$1],
|
|
3198
3120
|
docs: { description: "Disallow useless fragment elements." },
|
|
3199
3121
|
fixable: "code",
|
|
3200
3122
|
messages: { uselessFragment: "A fragment {{reason}} is useless." },
|
|
@@ -3207,11 +3129,11 @@ var no_useless_fragment_default = createRule({
|
|
|
3207
3129
|
} }
|
|
3208
3130
|
}]
|
|
3209
3131
|
},
|
|
3210
|
-
name: RULE_NAME$
|
|
3211
|
-
create: create$
|
|
3212
|
-
defaultOptions
|
|
3132
|
+
name: RULE_NAME$5,
|
|
3133
|
+
create: create$5,
|
|
3134
|
+
defaultOptions: defaultOptions$1
|
|
3213
3135
|
});
|
|
3214
|
-
function create$
|
|
3136
|
+
function create$5(context, [option]) {
|
|
3215
3137
|
const { allowExpressions = true } = option;
|
|
3216
3138
|
return {
|
|
3217
3139
|
JSXElement(node) {
|
|
@@ -3314,7 +3236,7 @@ function canFix(context, node) {
|
|
|
3314
3236
|
|
|
3315
3237
|
//#endregion
|
|
3316
3238
|
//#region src/rules/prefer-destructuring-assignment.ts
|
|
3317
|
-
const RULE_NAME$
|
|
3239
|
+
const RULE_NAME$4 = "prefer-destructuring-assignment";
|
|
3318
3240
|
const RULE_FEATURES$3 = [];
|
|
3319
3241
|
function isMemberExpressionWithObjectName(node) {
|
|
3320
3242
|
return node.object.type === AST_NODE_TYPES.Identifier && "name" in node.object;
|
|
@@ -3329,11 +3251,11 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3329
3251
|
messages: { preferDestructuringAssignment: "Use destructuring assignment for {{name}}." },
|
|
3330
3252
|
schema: []
|
|
3331
3253
|
},
|
|
3332
|
-
name: RULE_NAME$
|
|
3333
|
-
create: create$
|
|
3254
|
+
name: RULE_NAME$4,
|
|
3255
|
+
create: create$4,
|
|
3334
3256
|
defaultOptions: []
|
|
3335
3257
|
});
|
|
3336
|
-
function create$
|
|
3258
|
+
function create$4(context) {
|
|
3337
3259
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3338
3260
|
const memberExpressionWithNames = [];
|
|
3339
3261
|
return {
|
|
@@ -3380,7 +3302,7 @@ function create$3(context) {
|
|
|
3380
3302
|
|
|
3381
3303
|
//#endregion
|
|
3382
3304
|
//#region src/rules/prefer-namespace-import.ts
|
|
3383
|
-
const RULE_NAME$
|
|
3305
|
+
const RULE_NAME$3 = "prefer-namespace-import";
|
|
3384
3306
|
const RULE_FEATURES$2 = ["FIX"];
|
|
3385
3307
|
var prefer_namespace_import_default = createRule({
|
|
3386
3308
|
meta: {
|
|
@@ -3393,11 +3315,11 @@ var prefer_namespace_import_default = createRule({
|
|
|
3393
3315
|
messages: { preferNamespaceImport: "Prefer importing React as 'import * as React from \"{{importSource}}\"';" },
|
|
3394
3316
|
schema: []
|
|
3395
3317
|
},
|
|
3396
|
-
name: RULE_NAME$
|
|
3397
|
-
create: create$
|
|
3318
|
+
name: RULE_NAME$3,
|
|
3319
|
+
create: create$3,
|
|
3398
3320
|
defaultOptions: []
|
|
3399
3321
|
});
|
|
3400
|
-
function create$
|
|
3322
|
+
function create$3(context) {
|
|
3401
3323
|
const { importSource } = getSettingsFromContext(context);
|
|
3402
3324
|
return { [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
|
|
3403
3325
|
const hasOtherSpecifiers = node.parent.specifiers.length > 1;
|
|
@@ -3421,7 +3343,7 @@ function create$2(context) {
|
|
|
3421
3343
|
|
|
3422
3344
|
//#endregion
|
|
3423
3345
|
//#region src/rules/prefer-read-only-props.ts
|
|
3424
|
-
const RULE_NAME$
|
|
3346
|
+
const RULE_NAME$2 = "prefer-read-only-props";
|
|
3425
3347
|
const RULE_FEATURES$1 = ["TSC", "EXP"];
|
|
3426
3348
|
var prefer_read_only_props_default = createRule({
|
|
3427
3349
|
meta: {
|
|
@@ -3433,11 +3355,11 @@ var prefer_read_only_props_default = createRule({
|
|
|
3433
3355
|
messages: { preferReadOnlyProps: "A function component's props should be read-only." },
|
|
3434
3356
|
schema: []
|
|
3435
3357
|
},
|
|
3436
|
-
name: RULE_NAME$
|
|
3437
|
-
create: create$
|
|
3358
|
+
name: RULE_NAME$2,
|
|
3359
|
+
create: create$2,
|
|
3438
3360
|
defaultOptions: []
|
|
3439
3361
|
});
|
|
3440
|
-
function create$
|
|
3362
|
+
function create$2(context) {
|
|
3441
3363
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3442
3364
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3443
3365
|
return {
|
|
@@ -3470,7 +3392,7 @@ function isTypeReadonlyLoose(services, type) {
|
|
|
3470
3392
|
|
|
3471
3393
|
//#endregion
|
|
3472
3394
|
//#region src/rules/prefer-use-state-lazy-initialization.ts
|
|
3473
|
-
const RULE_NAME = "prefer-use-state-lazy-initialization";
|
|
3395
|
+
const RULE_NAME$1 = "prefer-use-state-lazy-initialization";
|
|
3474
3396
|
const RULE_FEATURES = ["EXP"];
|
|
3475
3397
|
const ALLOW_LIST = [
|
|
3476
3398
|
"Boolean",
|
|
@@ -3487,11 +3409,11 @@ var prefer_use_state_lazy_initialization_default = createRule({
|
|
|
3487
3409
|
messages: { preferUseStateLazyInitialization: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'." },
|
|
3488
3410
|
schema: []
|
|
3489
3411
|
},
|
|
3490
|
-
name: RULE_NAME,
|
|
3491
|
-
create,
|
|
3412
|
+
name: RULE_NAME$1,
|
|
3413
|
+
create: create$1,
|
|
3492
3414
|
defaultOptions: []
|
|
3493
3415
|
});
|
|
3494
|
-
function create(context) {
|
|
3416
|
+
function create$1(context) {
|
|
3495
3417
|
return { CallExpression(node) {
|
|
3496
3418
|
if (!isUseStateCall(node)) return;
|
|
3497
3419
|
const [useStateInput] = node.arguments;
|
|
@@ -3518,6 +3440,91 @@ function create(context) {
|
|
|
3518
3440
|
} };
|
|
3519
3441
|
}
|
|
3520
3442
|
|
|
3443
|
+
//#endregion
|
|
3444
|
+
//#region src/rules-removed/no-forbidden-props.ts
|
|
3445
|
+
const RULE_NAME = "no-forbidden-props";
|
|
3446
|
+
const messageId = camelCase(RULE_NAME);
|
|
3447
|
+
const defaultOptions = [{ forbid: [{ prop: "/_/" }] }];
|
|
3448
|
+
var no_forbidden_props_default = createRule({
|
|
3449
|
+
meta: {
|
|
3450
|
+
type: "problem",
|
|
3451
|
+
defaultOptions: [...defaultOptions],
|
|
3452
|
+
deprecated: {
|
|
3453
|
+
deprecatedSince: "2.3.2",
|
|
3454
|
+
message: "This rule is deprecated and will be removed in future versions.",
|
|
3455
|
+
replacedBy: [{ rule: {
|
|
3456
|
+
name: "no-restricted-syntax",
|
|
3457
|
+
url: "https://eslint.org/docs/latest/rules/no-restricted-syntax"
|
|
3458
|
+
} }]
|
|
3459
|
+
},
|
|
3460
|
+
docs: { description: "Disallow certain props on components." },
|
|
3461
|
+
messages: { [messageId]: "Prop \"{{name}}\" is forbidden." },
|
|
3462
|
+
schema: [{
|
|
3463
|
+
type: "object",
|
|
3464
|
+
additionalProperties: false,
|
|
3465
|
+
properties: { forbid: {
|
|
3466
|
+
type: "array",
|
|
3467
|
+
items: { anyOf: [
|
|
3468
|
+
{ type: "string" },
|
|
3469
|
+
{
|
|
3470
|
+
type: "object",
|
|
3471
|
+
additionalProperties: false,
|
|
3472
|
+
properties: {
|
|
3473
|
+
excludedNodes: {
|
|
3474
|
+
type: "array",
|
|
3475
|
+
items: { type: "string" },
|
|
3476
|
+
uniqueItems: true
|
|
3477
|
+
},
|
|
3478
|
+
prop: { type: "string" }
|
|
3479
|
+
},
|
|
3480
|
+
required: ["prop"]
|
|
3481
|
+
},
|
|
3482
|
+
{
|
|
3483
|
+
type: "object",
|
|
3484
|
+
additionalProperties: false,
|
|
3485
|
+
properties: {
|
|
3486
|
+
includedNodes: {
|
|
3487
|
+
type: "array",
|
|
3488
|
+
items: { type: "string" },
|
|
3489
|
+
uniqueItems: true
|
|
3490
|
+
},
|
|
3491
|
+
prop: { type: "string" }
|
|
3492
|
+
},
|
|
3493
|
+
required: ["prop"]
|
|
3494
|
+
}
|
|
3495
|
+
] }
|
|
3496
|
+
} }
|
|
3497
|
+
}]
|
|
3498
|
+
},
|
|
3499
|
+
name: RULE_NAME,
|
|
3500
|
+
create,
|
|
3501
|
+
defaultOptions
|
|
3502
|
+
});
|
|
3503
|
+
function create(context, [option]) {
|
|
3504
|
+
const { forbid = [{ prop: "/_/" }] } = option;
|
|
3505
|
+
return { JSXOpeningElement(node) {
|
|
3506
|
+
let nodeName = null;
|
|
3507
|
+
if (node.name.type === AST_NODE_TYPES.JSXIdentifier) nodeName = node.name.name;
|
|
3508
|
+
else if (node.name.type === AST_NODE_TYPES.JSXNamespacedName) nodeName = node.name.name.name;
|
|
3509
|
+
for (const attr of node.attributes) {
|
|
3510
|
+
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
|
|
3511
|
+
const name$7 = attr.name.name;
|
|
3512
|
+
if (typeof name$7 !== "string") continue;
|
|
3513
|
+
for (const forbiddenPropItem of forbid) {
|
|
3514
|
+
if (typeof forbiddenPropItem !== "string" && nodeName != null) {
|
|
3515
|
+
if ("excludedNodes" in forbiddenPropItem && forbiddenPropItem.excludedNodes.includes(nodeName)) continue;
|
|
3516
|
+
if ("includedNodes" in forbiddenPropItem && !forbiddenPropItem.includedNodes.includes(nodeName)) continue;
|
|
3517
|
+
}
|
|
3518
|
+
if (toRegExp(typeof forbiddenPropItem === "string" ? forbiddenPropItem : forbiddenPropItem.prop).test(name$7)) context.report({
|
|
3519
|
+
messageId,
|
|
3520
|
+
node: attr,
|
|
3521
|
+
data: { name: name$7 }
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
} };
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3521
3528
|
//#endregion
|
|
3522
3529
|
//#region src/plugin.ts
|
|
3523
3530
|
const plugin = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.3.2-beta.
|
|
3
|
+
"version": "2.3.2-beta.2",
|
|
4
4
|
"description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"string-ts": "^2.2.1",
|
|
47
47
|
"ts-api-utils": "^2.1.0",
|
|
48
48
|
"ts-pattern": "^5.9.0",
|
|
49
|
-
"@eslint-react/ast": "2.3.2-beta.
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/var": "2.3.2-beta.
|
|
49
|
+
"@eslint-react/ast": "2.3.2-beta.2",
|
|
50
|
+
"@eslint-react/core": "2.3.2-beta.2",
|
|
51
|
+
"@eslint-react/eff": "2.3.2-beta.2",
|
|
52
|
+
"@eslint-react/shared": "2.3.2-beta.2",
|
|
53
|
+
"@eslint-react/var": "2.3.2-beta.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.2",
|