eslint-plugin-react-x 3.0.0-next.71 → 3.0.0-next.76
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 +394 -234
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
|
9
9
|
import { computeObjectType, findEnclosingAssignmentTarget, isAssignmentTargetEqual, resolve } from "@eslint-react/var";
|
|
10
10
|
import { DefinitionType } from "@typescript-eslint/scope-manager";
|
|
11
11
|
import { findVariable, getStaticValue, isIdentifier, isVariableDeclarator } from "@typescript-eslint/utils/ast-utils";
|
|
12
|
-
import { constFalse, constTrue, constVoid, flow, getOrElseUpdate, identity, not } from "@eslint-react/eff";
|
|
13
12
|
import { compare } from "compare-versions";
|
|
14
13
|
import { getConstrainedTypeAtLocation } from "@typescript-eslint/type-utils";
|
|
15
14
|
import { unionConstituents } from "ts-api-utils";
|
|
@@ -51,14 +50,11 @@ const conflictingRules$1 = [
|
|
|
51
50
|
"react/jsx-key",
|
|
52
51
|
"react/jsx-no-comment-textnodes",
|
|
53
52
|
"react/jsx-no-constructed-context-values",
|
|
54
|
-
"react/jsx-no-duplicate-props",
|
|
55
53
|
"react/jsx-no-leaked-render",
|
|
56
54
|
"react/jsx-no-script-url",
|
|
57
55
|
"react/jsx-no-target-blank",
|
|
58
56
|
"react/jsx-no-useless-fragment",
|
|
59
57
|
"react/jsx-pascal-case",
|
|
60
|
-
"react/jsx-uses-react",
|
|
61
|
-
"react/jsx-uses-vars",
|
|
62
58
|
"react/no-access-state-in-setstate",
|
|
63
59
|
"react/no-array-index-key",
|
|
64
60
|
"react/no-children-prop",
|
|
@@ -117,17 +113,17 @@ var disable_experimental_exports = /* @__PURE__ */ __exportAll({
|
|
|
117
113
|
});
|
|
118
114
|
const name$8 = "react-x/disable-experimental";
|
|
119
115
|
const rules$8 = {
|
|
120
|
-
"react-x/exhaustive-deps": "off",
|
|
121
116
|
"react-x/immutability": "off",
|
|
122
117
|
"react-x/jsx-key-before-spread": "off",
|
|
123
118
|
"react-x/no-duplicate-key": "off",
|
|
119
|
+
"react-x/no-implicit-children": "off",
|
|
124
120
|
"react-x/no-implicit-key": "off",
|
|
121
|
+
"react-x/no-implicit-ref": "off",
|
|
125
122
|
"react-x/no-misused-capture-owner-stack": "off",
|
|
126
123
|
"react-x/no-unnecessary-use-callback": "off",
|
|
127
124
|
"react-x/no-unnecessary-use-memo": "off",
|
|
128
125
|
"react-x/no-unused-props": "off",
|
|
129
126
|
"react-x/refs": "off",
|
|
130
|
-
"react-x/rules-of-hooks": "off",
|
|
131
127
|
"react-x/set-state-in-render": "off",
|
|
132
128
|
"react-x/unstable-rules-of-props": "off"
|
|
133
129
|
};
|
|
@@ -140,7 +136,9 @@ var disable_type_checked_exports = /* @__PURE__ */ __exportAll({
|
|
|
140
136
|
});
|
|
141
137
|
const name$7 = "react-x/disable-type-checked";
|
|
142
138
|
const rules$7 = {
|
|
139
|
+
"react-x/no-implicit-children": "off",
|
|
143
140
|
"react-x/no-implicit-key": "off",
|
|
141
|
+
"react-x/no-implicit-ref": "off",
|
|
144
142
|
"react-x/no-leaked-conditional-rendering": "off",
|
|
145
143
|
"react-x/no-unused-props": "off"
|
|
146
144
|
};
|
|
@@ -148,7 +146,7 @@ const rules$7 = {
|
|
|
148
146
|
//#endregion
|
|
149
147
|
//#region package.json
|
|
150
148
|
var name$6 = "eslint-plugin-react-x";
|
|
151
|
-
var version = "3.0.0-next.
|
|
149
|
+
var version = "3.0.0-next.76";
|
|
152
150
|
|
|
153
151
|
//#endregion
|
|
154
152
|
//#region src/utils/create-rule.ts
|
|
@@ -305,7 +303,7 @@ function getTypeVariants(types) {
|
|
|
305
303
|
|
|
306
304
|
//#endregion
|
|
307
305
|
//#region src/rules/component-hook-factories/component-hook-factories.ts
|
|
308
|
-
const RULE_NAME$
|
|
306
|
+
const RULE_NAME$62 = "component-hook-factories";
|
|
309
307
|
var component_hook_factories_default = createRule({
|
|
310
308
|
meta: {
|
|
311
309
|
type: "problem",
|
|
@@ -316,11 +314,11 @@ var component_hook_factories_default = createRule({
|
|
|
316
314
|
},
|
|
317
315
|
schema: []
|
|
318
316
|
},
|
|
319
|
-
name: RULE_NAME$
|
|
320
|
-
create: create$
|
|
317
|
+
name: RULE_NAME$62,
|
|
318
|
+
create: create$62,
|
|
321
319
|
defaultOptions: []
|
|
322
320
|
});
|
|
323
|
-
function create$
|
|
321
|
+
function create$62(context) {
|
|
324
322
|
const hint = core.ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.ComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.ComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
|
|
325
323
|
const fCollector = core.useComponentCollector(context, { hint });
|
|
326
324
|
const cCollector = core.useComponentCollectorLegacy(context);
|
|
@@ -364,7 +362,7 @@ function create$63(context) {
|
|
|
364
362
|
|
|
365
363
|
//#endregion
|
|
366
364
|
//#region src/rules/error-boundaries/error-boundaries.ts
|
|
367
|
-
const RULE_NAME$
|
|
365
|
+
const RULE_NAME$61 = "error-boundaries";
|
|
368
366
|
var error_boundaries_default = createRule({
|
|
369
367
|
meta: {
|
|
370
368
|
type: "problem",
|
|
@@ -375,11 +373,11 @@ var error_boundaries_default = createRule({
|
|
|
375
373
|
},
|
|
376
374
|
schema: []
|
|
377
375
|
},
|
|
378
|
-
name: RULE_NAME$
|
|
379
|
-
create: create$
|
|
376
|
+
name: RULE_NAME$61,
|
|
377
|
+
create: create$61,
|
|
380
378
|
defaultOptions: []
|
|
381
379
|
});
|
|
382
|
-
function create$
|
|
380
|
+
function create$61(context) {
|
|
383
381
|
if (!context.sourceCode.text.includes("try")) return {};
|
|
384
382
|
const { ctx, visitor } = core.useComponentCollector(context);
|
|
385
383
|
const reported = /* @__PURE__ */ new Set();
|
|
@@ -1319,7 +1317,7 @@ function getUnknownDependenciesMessage(reactiveHookName) {
|
|
|
1319
1317
|
|
|
1320
1318
|
//#endregion
|
|
1321
1319
|
//#region src/rules/immutability/immutability.ts
|
|
1322
|
-
const RULE_NAME$
|
|
1320
|
+
const RULE_NAME$60 = "immutability";
|
|
1323
1321
|
/**
|
|
1324
1322
|
* Array methods that mutate the array in place.
|
|
1325
1323
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
@@ -1345,11 +1343,11 @@ var immutability_default = createRule({
|
|
|
1345
1343
|
},
|
|
1346
1344
|
schema: []
|
|
1347
1345
|
},
|
|
1348
|
-
name: RULE_NAME$
|
|
1349
|
-
create: create$
|
|
1346
|
+
name: RULE_NAME$60,
|
|
1347
|
+
create: create$60,
|
|
1350
1348
|
defaultOptions: []
|
|
1351
1349
|
});
|
|
1352
|
-
function create$
|
|
1350
|
+
function create$60(context) {
|
|
1353
1351
|
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
1354
1352
|
const hCollector = core.useHookCollector(context);
|
|
1355
1353
|
const cCollector = core.useComponentCollector(context);
|
|
@@ -1470,7 +1468,7 @@ function create$61(context) {
|
|
|
1470
1468
|
|
|
1471
1469
|
//#endregion
|
|
1472
1470
|
//#region src/rules/jsx-dollar/jsx-dollar.ts
|
|
1473
|
-
const RULE_NAME$
|
|
1471
|
+
const RULE_NAME$59 = "jsx-dollar";
|
|
1474
1472
|
var jsx_dollar_default = createRule({
|
|
1475
1473
|
meta: {
|
|
1476
1474
|
type: "suggestion",
|
|
@@ -1483,11 +1481,11 @@ var jsx_dollar_default = createRule({
|
|
|
1483
1481
|
},
|
|
1484
1482
|
schema: []
|
|
1485
1483
|
},
|
|
1486
|
-
name: RULE_NAME$
|
|
1487
|
-
create: create$
|
|
1484
|
+
name: RULE_NAME$59,
|
|
1485
|
+
create: create$59,
|
|
1488
1486
|
defaultOptions: []
|
|
1489
1487
|
});
|
|
1490
|
-
function create$
|
|
1488
|
+
function create$59(context) {
|
|
1491
1489
|
/**
|
|
1492
1490
|
* Visitor function for JSXElement and JSXFragment nodes
|
|
1493
1491
|
* @param node The JSXElement or JSXFragment node to be checked
|
|
@@ -1528,7 +1526,7 @@ function create$60(context) {
|
|
|
1528
1526
|
|
|
1529
1527
|
//#endregion
|
|
1530
1528
|
//#region src/rules/jsx-key-before-spread/jsx-key-before-spread.ts
|
|
1531
|
-
const RULE_NAME$
|
|
1529
|
+
const RULE_NAME$58 = "jsx-key-before-spread";
|
|
1532
1530
|
var jsx_key_before_spread_default = createRule({
|
|
1533
1531
|
meta: {
|
|
1534
1532
|
type: "problem",
|
|
@@ -1536,11 +1534,11 @@ var jsx_key_before_spread_default = createRule({
|
|
|
1536
1534
|
messages: { default: "The 'key' prop must be placed before any spread props when using the new JSX transform." },
|
|
1537
1535
|
schema: []
|
|
1538
1536
|
},
|
|
1539
|
-
name: RULE_NAME$
|
|
1540
|
-
create: create$
|
|
1537
|
+
name: RULE_NAME$58,
|
|
1538
|
+
create: create$58,
|
|
1541
1539
|
defaultOptions: []
|
|
1542
1540
|
});
|
|
1543
|
-
function create$
|
|
1541
|
+
function create$58(context) {
|
|
1544
1542
|
const { jsx } = JsxInspector.from(context).jsxConfig;
|
|
1545
1543
|
if (jsx !== JsxEmit.ReactJSX && jsx !== JsxEmit.ReactJSXDev) return {};
|
|
1546
1544
|
return defineRuleListener({ JSXOpeningElement(node) {
|
|
@@ -1561,7 +1559,7 @@ function create$59(context) {
|
|
|
1561
1559
|
|
|
1562
1560
|
//#endregion
|
|
1563
1561
|
//#region src/rules/jsx-no-comment-textnodes/jsx-no-comment-textnodes.ts
|
|
1564
|
-
const RULE_NAME$
|
|
1562
|
+
const RULE_NAME$57 = "jsx-no-comment-textnodes";
|
|
1565
1563
|
var jsx_no_comment_textnodes_default = createRule({
|
|
1566
1564
|
meta: {
|
|
1567
1565
|
type: "problem",
|
|
@@ -1569,11 +1567,11 @@ var jsx_no_comment_textnodes_default = createRule({
|
|
|
1569
1567
|
messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
|
|
1570
1568
|
schema: []
|
|
1571
1569
|
},
|
|
1572
|
-
name: RULE_NAME$
|
|
1573
|
-
create: create$
|
|
1570
|
+
name: RULE_NAME$57,
|
|
1571
|
+
create: create$57,
|
|
1574
1572
|
defaultOptions: []
|
|
1575
1573
|
});
|
|
1576
|
-
function create$
|
|
1574
|
+
function create$57(context) {
|
|
1577
1575
|
function hasCommentLike(node) {
|
|
1578
1576
|
if (ast.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
|
|
1579
1577
|
return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
|
|
@@ -1592,39 +1590,6 @@ function create$58(context) {
|
|
|
1592
1590
|
});
|
|
1593
1591
|
}
|
|
1594
1592
|
|
|
1595
|
-
//#endregion
|
|
1596
|
-
//#region src/rules/jsx-no-duplicate-props/jsx-no-duplicate-props.ts
|
|
1597
|
-
const RULE_NAME$57 = "jsx-no-duplicate-props";
|
|
1598
|
-
var jsx_no_duplicate_props_default = createRule({
|
|
1599
|
-
meta: {
|
|
1600
|
-
type: "problem",
|
|
1601
|
-
docs: { description: "Disallows duplicate props in JSX elements." },
|
|
1602
|
-
messages: { default: "This JSX property is assigned multiple times." },
|
|
1603
|
-
schema: []
|
|
1604
|
-
},
|
|
1605
|
-
name: RULE_NAME$57,
|
|
1606
|
-
create: create$57,
|
|
1607
|
-
defaultOptions: []
|
|
1608
|
-
});
|
|
1609
|
-
function create$57(context) {
|
|
1610
|
-
return defineRuleListener({ JSXOpeningElement(node) {
|
|
1611
|
-
const props = [];
|
|
1612
|
-
for (const attr of node.attributes) {
|
|
1613
|
-
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
|
|
1614
|
-
const name = attr.name.name;
|
|
1615
|
-
if (typeof name !== "string") continue;
|
|
1616
|
-
if (!props.includes(name)) {
|
|
1617
|
-
props.push(name);
|
|
1618
|
-
continue;
|
|
1619
|
-
}
|
|
1620
|
-
context.report({
|
|
1621
|
-
messageId: "default",
|
|
1622
|
-
node: attr
|
|
1623
|
-
});
|
|
1624
|
-
}
|
|
1625
|
-
} });
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
1593
|
//#endregion
|
|
1629
1594
|
//#region src/rules/jsx-shorthand-boolean/jsx-shorthand-boolean.ts
|
|
1630
1595
|
const RULE_NAME$56 = "jsx-shorthand-boolean";
|
|
@@ -1723,78 +1688,193 @@ function create$55(context) {
|
|
|
1723
1688
|
}
|
|
1724
1689
|
|
|
1725
1690
|
//#endregion
|
|
1726
|
-
//#region
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1691
|
+
//#region ../../../.pkgs/eff/dist/index.js
|
|
1692
|
+
function not(predicate) {
|
|
1693
|
+
return (data) => !predicate(data);
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Returns its argument.
|
|
1697
|
+
*
|
|
1698
|
+
* @param x - The value to return.
|
|
1699
|
+
* @returns The input value unchanged.
|
|
1700
|
+
*/
|
|
1701
|
+
function identity(x) {
|
|
1702
|
+
return x;
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Creates a function that can be used in a data-last (aka `pipe`able) or
|
|
1706
|
+
* data-first style.
|
|
1707
|
+
*
|
|
1708
|
+
* The first parameter to `dual` is either the arity of the uncurried function
|
|
1709
|
+
* or a predicate that determines if the function is being used in a data-first
|
|
1710
|
+
* or data-last style.
|
|
1711
|
+
*
|
|
1712
|
+
* Using the arity is the most common use case, but there are some cases where
|
|
1713
|
+
* you may want to use a predicate. For example, if you have a function that
|
|
1714
|
+
* takes an optional argument, you can use a predicate to determine if the
|
|
1715
|
+
* function is being used in a data-first or data-last style.
|
|
1716
|
+
*
|
|
1717
|
+
* You can pass either the arity of the uncurried function or a predicate
|
|
1718
|
+
* which determines if the function is being used in a data-first or
|
|
1719
|
+
* data-last style.
|
|
1720
|
+
*
|
|
1721
|
+
* **Example** (Using arity to determine data-first or data-last style)
|
|
1722
|
+
*
|
|
1723
|
+
* ```ts
|
|
1724
|
+
* import { dual, pipe } from "effect/Function"
|
|
1725
|
+
*
|
|
1726
|
+
* const sum = dual<
|
|
1727
|
+
* (that: number) => (self: number) => number,
|
|
1728
|
+
* (self: number, that: number) => number
|
|
1729
|
+
* >(2, (self, that) => self + that)
|
|
1730
|
+
*
|
|
1731
|
+
* console.log(sum(2, 3)) // 5
|
|
1732
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
1733
|
+
* ```
|
|
1734
|
+
*
|
|
1735
|
+
* **Example** (Using call signatures to define the overloads)
|
|
1736
|
+
*
|
|
1737
|
+
* ```ts
|
|
1738
|
+
* import { dual, pipe } from "effect/Function"
|
|
1739
|
+
*
|
|
1740
|
+
* const sum: {
|
|
1741
|
+
* (that: number): (self: number) => number
|
|
1742
|
+
* (self: number, that: number): number
|
|
1743
|
+
* } = dual(2, (self: number, that: number): number => self + that)
|
|
1744
|
+
*
|
|
1745
|
+
* console.log(sum(2, 3)) // 5
|
|
1746
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
1747
|
+
* ```
|
|
1748
|
+
*
|
|
1749
|
+
* **Example** (Using a predicate to determine data-first or data-last style)
|
|
1750
|
+
*
|
|
1751
|
+
* ```ts
|
|
1752
|
+
* import { dual, pipe } from "effect/Function"
|
|
1753
|
+
*
|
|
1754
|
+
* const sum = dual<
|
|
1755
|
+
* (that: number) => (self: number) => number,
|
|
1756
|
+
* (self: number, that: number) => number
|
|
1757
|
+
* >(
|
|
1758
|
+
* (args) => args.length === 2,
|
|
1759
|
+
* (self, that) => self + that
|
|
1760
|
+
* )
|
|
1761
|
+
*
|
|
1762
|
+
* console.log(sum(2, 3)) // 5
|
|
1763
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
1764
|
+
* ```
|
|
1765
|
+
*
|
|
1766
|
+
* @param arity - The arity of the uncurried function or a predicate that determines if the function is being used in a data-first or data-last style.
|
|
1767
|
+
* @param body - The function to be curried.
|
|
1768
|
+
* @since 1.0.0
|
|
1769
|
+
*/
|
|
1770
|
+
const dual = function(arity, body) {
|
|
1771
|
+
if (typeof arity === "function") return function() {
|
|
1772
|
+
return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
|
|
1773
|
+
};
|
|
1774
|
+
switch (arity) {
|
|
1775
|
+
case 0:
|
|
1776
|
+
case 1: throw new RangeError(`Invalid arity ${arity}`);
|
|
1777
|
+
case 2: return function(a, b) {
|
|
1778
|
+
if (arguments.length >= 2) return body(a, b);
|
|
1779
|
+
return function(self) {
|
|
1780
|
+
return body(self, a);
|
|
1781
|
+
};
|
|
1782
|
+
};
|
|
1783
|
+
case 3: return function(a, b, c) {
|
|
1784
|
+
if (arguments.length >= 3) return body(a, b, c);
|
|
1785
|
+
return function(self) {
|
|
1786
|
+
return body(self, a, b);
|
|
1787
|
+
};
|
|
1788
|
+
};
|
|
1789
|
+
default: return function() {
|
|
1790
|
+
if (arguments.length >= arity) return body.apply(this, arguments);
|
|
1791
|
+
const args = arguments;
|
|
1792
|
+
return function(self) {
|
|
1793
|
+
return body(self, ...args);
|
|
1794
|
+
};
|
|
1795
|
+
};
|
|
1749
1796
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1797
|
+
};
|
|
1798
|
+
/**
|
|
1799
|
+
* Do nothing and return `void`.
|
|
1800
|
+
*/
|
|
1801
|
+
function constVoid() {}
|
|
1802
|
+
/**
|
|
1803
|
+
* Do nothing and return `true`.
|
|
1804
|
+
*
|
|
1805
|
+
* @returns true
|
|
1806
|
+
*/
|
|
1807
|
+
function constTrue() {
|
|
1808
|
+
return true;
|
|
1755
1809
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1810
|
+
/**
|
|
1811
|
+
* Do nothing and return `false`.
|
|
1812
|
+
*
|
|
1813
|
+
* @returns false
|
|
1814
|
+
*/
|
|
1815
|
+
function constFalse() {
|
|
1816
|
+
return false;
|
|
1763
1817
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1818
|
+
/**
|
|
1819
|
+
* Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.
|
|
1820
|
+
* The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
|
|
1821
|
+
*
|
|
1822
|
+
* @param self - The first function to apply (or the composed function in data-last style).
|
|
1823
|
+
* @param bc - The second function to apply.
|
|
1824
|
+
* @returns A composed function that applies both functions in sequence.
|
|
1825
|
+
* @example
|
|
1826
|
+
* ```ts
|
|
1827
|
+
* import * as assert from "node:assert"
|
|
1828
|
+
* import { compose } from "effect/Function"
|
|
1829
|
+
*
|
|
1830
|
+
* const increment = (n: number) => n + 1;
|
|
1831
|
+
* const square = (n: number) => n * n;
|
|
1832
|
+
*
|
|
1833
|
+
* assert.strictEqual(compose(increment, square)(2), 9);
|
|
1834
|
+
* ```
|
|
1835
|
+
*
|
|
1836
|
+
* @since 1.0.0
|
|
1837
|
+
*/
|
|
1838
|
+
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
1839
|
+
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
|
|
1840
|
+
switch (arguments.length) {
|
|
1841
|
+
case 1: return ab;
|
|
1842
|
+
case 2: return function() {
|
|
1843
|
+
return bc(ab.apply(this, arguments));
|
|
1844
|
+
};
|
|
1845
|
+
case 3: return function() {
|
|
1846
|
+
return cd(bc(ab.apply(this, arguments)));
|
|
1847
|
+
};
|
|
1848
|
+
case 4: return function() {
|
|
1849
|
+
return de(cd(bc(ab.apply(this, arguments))));
|
|
1850
|
+
};
|
|
1851
|
+
case 5: return function() {
|
|
1852
|
+
return ef(de(cd(bc(ab.apply(this, arguments)))));
|
|
1853
|
+
};
|
|
1854
|
+
case 6: return function() {
|
|
1855
|
+
return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
|
|
1856
|
+
};
|
|
1857
|
+
case 7: return function() {
|
|
1858
|
+
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
|
|
1859
|
+
};
|
|
1860
|
+
case 8: return function() {
|
|
1861
|
+
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
|
|
1862
|
+
};
|
|
1863
|
+
case 9: return function() {
|
|
1864
|
+
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
function getOrElseUpdate(map, key, callback) {
|
|
1869
|
+
if (map.has(key)) return map.get(key);
|
|
1870
|
+
const value = callback();
|
|
1871
|
+
map.set(key, value);
|
|
1872
|
+
return value;
|
|
1793
1873
|
}
|
|
1794
1874
|
|
|
1795
1875
|
//#endregion
|
|
1796
1876
|
//#region src/rules/no-access-state-in-setstate/no-access-state-in-setstate.ts
|
|
1797
|
-
const RULE_NAME$
|
|
1877
|
+
const RULE_NAME$54 = "no-access-state-in-setstate";
|
|
1798
1878
|
function isKeyLiteral$2(node, key) {
|
|
1799
1879
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
|
|
1800
1880
|
type: AST_NODE_TYPES.TemplateLiteral,
|
|
@@ -1808,11 +1888,11 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
1808
1888
|
messages: { default: "Do not access 'this.state' within 'setState'. Use the update function instead." },
|
|
1809
1889
|
schema: []
|
|
1810
1890
|
},
|
|
1811
|
-
name: RULE_NAME$
|
|
1812
|
-
create: create$
|
|
1891
|
+
name: RULE_NAME$54,
|
|
1892
|
+
create: create$54,
|
|
1813
1893
|
defaultOptions: []
|
|
1814
1894
|
});
|
|
1815
|
-
function create$
|
|
1895
|
+
function create$54(context) {
|
|
1816
1896
|
if (!context.sourceCode.text.includes("setState")) return {};
|
|
1817
1897
|
const classStack = [];
|
|
1818
1898
|
const methodStack = [];
|
|
@@ -1883,7 +1963,7 @@ function create$52(context) {
|
|
|
1883
1963
|
|
|
1884
1964
|
//#endregion
|
|
1885
1965
|
//#region src/rules/no-array-index-key/no-array-index-key.ts
|
|
1886
|
-
const RULE_NAME$
|
|
1966
|
+
const RULE_NAME$53 = "no-array-index-key";
|
|
1887
1967
|
function getIndexParamPosition(methodName) {
|
|
1888
1968
|
switch (methodName) {
|
|
1889
1969
|
case "every":
|
|
@@ -1928,11 +2008,11 @@ var no_array_index_key_default = createRule({
|
|
|
1928
2008
|
messages: { default: "Do not use item index in the array as its key." },
|
|
1929
2009
|
schema: []
|
|
1930
2010
|
},
|
|
1931
|
-
name: RULE_NAME$
|
|
1932
|
-
create: create$
|
|
2011
|
+
name: RULE_NAME$53,
|
|
2012
|
+
create: create$53,
|
|
1933
2013
|
defaultOptions: []
|
|
1934
2014
|
});
|
|
1935
|
-
function create$
|
|
2015
|
+
function create$53(context) {
|
|
1936
2016
|
const indexParamNames = [];
|
|
1937
2017
|
function isArrayIndex(node) {
|
|
1938
2018
|
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name) => name != null && name === node.name);
|
|
@@ -1998,7 +2078,7 @@ function create$51(context) {
|
|
|
1998
2078
|
|
|
1999
2079
|
//#endregion
|
|
2000
2080
|
//#region src/rules/no-children-count/no-children-count.ts
|
|
2001
|
-
const RULE_NAME$
|
|
2081
|
+
const RULE_NAME$52 = "no-children-count";
|
|
2002
2082
|
var no_children_count_default = createRule({
|
|
2003
2083
|
meta: {
|
|
2004
2084
|
type: "suggestion",
|
|
@@ -2006,11 +2086,11 @@ var no_children_count_default = createRule({
|
|
|
2006
2086
|
messages: { default: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
2007
2087
|
schema: []
|
|
2008
2088
|
},
|
|
2009
|
-
name: RULE_NAME$
|
|
2010
|
-
create: create$
|
|
2089
|
+
name: RULE_NAME$52,
|
|
2090
|
+
create: create$52,
|
|
2011
2091
|
defaultOptions: []
|
|
2012
2092
|
});
|
|
2013
|
-
function create$
|
|
2093
|
+
function create$52(context) {
|
|
2014
2094
|
return defineRuleListener({ MemberExpression(node) {
|
|
2015
2095
|
if (core.isChildrenCount(context, node)) context.report({
|
|
2016
2096
|
messageId: "default",
|
|
@@ -2021,7 +2101,7 @@ function create$50(context) {
|
|
|
2021
2101
|
|
|
2022
2102
|
//#endregion
|
|
2023
2103
|
//#region src/rules/no-children-for-each/no-children-for-each.ts
|
|
2024
|
-
const RULE_NAME$
|
|
2104
|
+
const RULE_NAME$51 = "no-children-for-each";
|
|
2025
2105
|
var no_children_for_each_default = createRule({
|
|
2026
2106
|
meta: {
|
|
2027
2107
|
type: "suggestion",
|
|
@@ -2029,11 +2109,11 @@ var no_children_for_each_default = createRule({
|
|
|
2029
2109
|
messages: { default: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
2030
2110
|
schema: []
|
|
2031
2111
|
},
|
|
2032
|
-
name: RULE_NAME$
|
|
2033
|
-
create: create$
|
|
2112
|
+
name: RULE_NAME$51,
|
|
2113
|
+
create: create$51,
|
|
2034
2114
|
defaultOptions: []
|
|
2035
2115
|
});
|
|
2036
|
-
function create$
|
|
2116
|
+
function create$51(context) {
|
|
2037
2117
|
return defineRuleListener({ MemberExpression(node) {
|
|
2038
2118
|
if (core.isChildrenForEach(context, node)) context.report({
|
|
2039
2119
|
messageId: "default",
|
|
@@ -2044,7 +2124,7 @@ function create$49(context) {
|
|
|
2044
2124
|
|
|
2045
2125
|
//#endregion
|
|
2046
2126
|
//#region src/rules/no-children-map/no-children-map.ts
|
|
2047
|
-
const RULE_NAME$
|
|
2127
|
+
const RULE_NAME$50 = "no-children-map";
|
|
2048
2128
|
var no_children_map_default = createRule({
|
|
2049
2129
|
meta: {
|
|
2050
2130
|
type: "suggestion",
|
|
@@ -2052,11 +2132,11 @@ var no_children_map_default = createRule({
|
|
|
2052
2132
|
messages: { default: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
2053
2133
|
schema: []
|
|
2054
2134
|
},
|
|
2055
|
-
name: RULE_NAME$
|
|
2056
|
-
create: create$
|
|
2135
|
+
name: RULE_NAME$50,
|
|
2136
|
+
create: create$50,
|
|
2057
2137
|
defaultOptions: []
|
|
2058
2138
|
});
|
|
2059
|
-
function create$
|
|
2139
|
+
function create$50(context) {
|
|
2060
2140
|
return defineRuleListener({ MemberExpression(node) {
|
|
2061
2141
|
if (core.isChildrenMap(context, node)) context.report({
|
|
2062
2142
|
messageId: "default",
|
|
@@ -2067,7 +2147,7 @@ function create$48(context) {
|
|
|
2067
2147
|
|
|
2068
2148
|
//#endregion
|
|
2069
2149
|
//#region src/rules/no-children-only/no-children-only.ts
|
|
2070
|
-
const RULE_NAME$
|
|
2150
|
+
const RULE_NAME$49 = "no-children-only";
|
|
2071
2151
|
var no_children_only_default = createRule({
|
|
2072
2152
|
meta: {
|
|
2073
2153
|
type: "suggestion",
|
|
@@ -2075,11 +2155,11 @@ var no_children_only_default = createRule({
|
|
|
2075
2155
|
messages: { default: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
2076
2156
|
schema: []
|
|
2077
2157
|
},
|
|
2078
|
-
name: RULE_NAME$
|
|
2079
|
-
create: create$
|
|
2158
|
+
name: RULE_NAME$49,
|
|
2159
|
+
create: create$49,
|
|
2080
2160
|
defaultOptions: []
|
|
2081
2161
|
});
|
|
2082
|
-
function create$
|
|
2162
|
+
function create$49(context) {
|
|
2083
2163
|
return defineRuleListener({ MemberExpression(node) {
|
|
2084
2164
|
if (core.isChildrenOnly(context, node)) context.report({
|
|
2085
2165
|
messageId: "default",
|
|
@@ -2090,7 +2170,7 @@ function create$47(context) {
|
|
|
2090
2170
|
|
|
2091
2171
|
//#endregion
|
|
2092
2172
|
//#region src/rules/no-children-prop/no-children-prop.ts
|
|
2093
|
-
const RULE_NAME$
|
|
2173
|
+
const RULE_NAME$48 = "no-children-prop";
|
|
2094
2174
|
var no_children_prop_default = createRule({
|
|
2095
2175
|
meta: {
|
|
2096
2176
|
type: "suggestion",
|
|
@@ -2098,11 +2178,11 @@ var no_children_prop_default = createRule({
|
|
|
2098
2178
|
messages: { default: "Do not pass 'children' as props." },
|
|
2099
2179
|
schema: []
|
|
2100
2180
|
},
|
|
2101
|
-
name: RULE_NAME$
|
|
2102
|
-
create: create$
|
|
2181
|
+
name: RULE_NAME$48,
|
|
2182
|
+
create: create$48,
|
|
2103
2183
|
defaultOptions: []
|
|
2104
2184
|
});
|
|
2105
|
-
function create$
|
|
2185
|
+
function create$48(context) {
|
|
2106
2186
|
const jsx = JsxInspector.from(context);
|
|
2107
2187
|
return defineRuleListener({ JSXElement(node) {
|
|
2108
2188
|
const childrenProp = jsx.findAttribute(node, "children");
|
|
@@ -2115,7 +2195,7 @@ function create$46(context) {
|
|
|
2115
2195
|
|
|
2116
2196
|
//#endregion
|
|
2117
2197
|
//#region src/rules/no-children-to-array/no-children-to-array.ts
|
|
2118
|
-
const RULE_NAME$
|
|
2198
|
+
const RULE_NAME$47 = "no-children-to-array";
|
|
2119
2199
|
var no_children_to_array_default = createRule({
|
|
2120
2200
|
meta: {
|
|
2121
2201
|
type: "suggestion",
|
|
@@ -2123,11 +2203,11 @@ var no_children_to_array_default = createRule({
|
|
|
2123
2203
|
messages: { default: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
2124
2204
|
schema: []
|
|
2125
2205
|
},
|
|
2126
|
-
name: RULE_NAME$
|
|
2127
|
-
create: create$
|
|
2206
|
+
name: RULE_NAME$47,
|
|
2207
|
+
create: create$47,
|
|
2128
2208
|
defaultOptions: []
|
|
2129
2209
|
});
|
|
2130
|
-
function create$
|
|
2210
|
+
function create$47(context) {
|
|
2131
2211
|
return defineRuleListener({ MemberExpression(node) {
|
|
2132
2212
|
if (core.isChildrenToArray(context, node)) context.report({
|
|
2133
2213
|
messageId: "default",
|
|
@@ -2138,7 +2218,7 @@ function create$45(context) {
|
|
|
2138
2218
|
|
|
2139
2219
|
//#endregion
|
|
2140
2220
|
//#region src/rules/no-class-component/no-class-component.ts
|
|
2141
|
-
const RULE_NAME$
|
|
2221
|
+
const RULE_NAME$46 = "no-class-component";
|
|
2142
2222
|
var no_class_component_default = createRule({
|
|
2143
2223
|
meta: {
|
|
2144
2224
|
type: "suggestion",
|
|
@@ -2146,11 +2226,11 @@ var no_class_component_default = createRule({
|
|
|
2146
2226
|
messages: { default: "Avoid using class components. Use function components instead." },
|
|
2147
2227
|
schema: []
|
|
2148
2228
|
},
|
|
2149
|
-
name: RULE_NAME$
|
|
2150
|
-
create: create$
|
|
2229
|
+
name: RULE_NAME$46,
|
|
2230
|
+
create: create$46,
|
|
2151
2231
|
defaultOptions: []
|
|
2152
2232
|
});
|
|
2153
|
-
function create$
|
|
2233
|
+
function create$46(context) {
|
|
2154
2234
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
2155
2235
|
const { ctx, visitor } = core.useComponentCollectorLegacy(context);
|
|
2156
2236
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -2167,7 +2247,7 @@ function create$44(context) {
|
|
|
2167
2247
|
|
|
2168
2248
|
//#endregion
|
|
2169
2249
|
//#region src/rules/no-clone-element/no-clone-element.ts
|
|
2170
|
-
const RULE_NAME$
|
|
2250
|
+
const RULE_NAME$45 = "no-clone-element";
|
|
2171
2251
|
var no_clone_element_default = createRule({
|
|
2172
2252
|
meta: {
|
|
2173
2253
|
type: "suggestion",
|
|
@@ -2175,11 +2255,11 @@ var no_clone_element_default = createRule({
|
|
|
2175
2255
|
messages: { default: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
2176
2256
|
schema: []
|
|
2177
2257
|
},
|
|
2178
|
-
name: RULE_NAME$
|
|
2179
|
-
create: create$
|
|
2258
|
+
name: RULE_NAME$45,
|
|
2259
|
+
create: create$45,
|
|
2180
2260
|
defaultOptions: []
|
|
2181
2261
|
});
|
|
2182
|
-
function create$
|
|
2262
|
+
function create$45(context) {
|
|
2183
2263
|
return defineRuleListener({ CallExpression(node) {
|
|
2184
2264
|
if (core.isCloneElementCall(context, node)) context.report({
|
|
2185
2265
|
messageId: "default",
|
|
@@ -2190,7 +2270,7 @@ function create$43(context) {
|
|
|
2190
2270
|
|
|
2191
2271
|
//#endregion
|
|
2192
2272
|
//#region src/rules/no-component-will-mount/no-component-will-mount.ts
|
|
2193
|
-
const RULE_NAME$
|
|
2273
|
+
const RULE_NAME$44 = "no-component-will-mount";
|
|
2194
2274
|
var no_component_will_mount_default = createRule({
|
|
2195
2275
|
meta: {
|
|
2196
2276
|
type: "problem",
|
|
@@ -2199,11 +2279,11 @@ var no_component_will_mount_default = createRule({
|
|
|
2199
2279
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
|
|
2200
2280
|
schema: []
|
|
2201
2281
|
},
|
|
2202
|
-
name: RULE_NAME$
|
|
2203
|
-
create: create$
|
|
2282
|
+
name: RULE_NAME$44,
|
|
2283
|
+
create: create$44,
|
|
2204
2284
|
defaultOptions: []
|
|
2205
2285
|
});
|
|
2206
|
-
function create$
|
|
2286
|
+
function create$44(context) {
|
|
2207
2287
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
2208
2288
|
const { ctx, visitor } = core.useComponentCollectorLegacy(context);
|
|
2209
2289
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -2223,7 +2303,7 @@ function create$42(context) {
|
|
|
2223
2303
|
|
|
2224
2304
|
//#endregion
|
|
2225
2305
|
//#region src/rules/no-component-will-receive-props/no-component-will-receive-props.ts
|
|
2226
|
-
const RULE_NAME$
|
|
2306
|
+
const RULE_NAME$43 = "no-component-will-receive-props";
|
|
2227
2307
|
var no_component_will_receive_props_default = createRule({
|
|
2228
2308
|
meta: {
|
|
2229
2309
|
type: "problem",
|
|
@@ -2232,11 +2312,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
2232
2312
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
|
|
2233
2313
|
schema: []
|
|
2234
2314
|
},
|
|
2235
|
-
name: RULE_NAME$
|
|
2236
|
-
create: create$
|
|
2315
|
+
name: RULE_NAME$43,
|
|
2316
|
+
create: create$43,
|
|
2237
2317
|
defaultOptions: []
|
|
2238
2318
|
});
|
|
2239
|
-
function create$
|
|
2319
|
+
function create$43(context) {
|
|
2240
2320
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
2241
2321
|
const { ctx, visitor } = core.useComponentCollectorLegacy(context);
|
|
2242
2322
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -2256,7 +2336,7 @@ function create$41(context) {
|
|
|
2256
2336
|
|
|
2257
2337
|
//#endregion
|
|
2258
2338
|
//#region src/rules/no-component-will-update/no-component-will-update.ts
|
|
2259
|
-
const RULE_NAME$
|
|
2339
|
+
const RULE_NAME$42 = "no-component-will-update";
|
|
2260
2340
|
var no_component_will_update_default = createRule({
|
|
2261
2341
|
meta: {
|
|
2262
2342
|
type: "problem",
|
|
@@ -2265,11 +2345,11 @@ var no_component_will_update_default = createRule({
|
|
|
2265
2345
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
|
|
2266
2346
|
schema: []
|
|
2267
2347
|
},
|
|
2268
|
-
name: RULE_NAME$
|
|
2269
|
-
create: create$
|
|
2348
|
+
name: RULE_NAME$42,
|
|
2349
|
+
create: create$42,
|
|
2270
2350
|
defaultOptions: []
|
|
2271
2351
|
});
|
|
2272
|
-
function create$
|
|
2352
|
+
function create$42(context) {
|
|
2273
2353
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2274
2354
|
const { ctx, visitor } = core.useComponentCollectorLegacy(context);
|
|
2275
2355
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -2289,7 +2369,7 @@ function create$40(context) {
|
|
|
2289
2369
|
|
|
2290
2370
|
//#endregion
|
|
2291
2371
|
//#region src/rules/no-context-provider/no-context-provider.ts
|
|
2292
|
-
const RULE_NAME$
|
|
2372
|
+
const RULE_NAME$41 = "no-context-provider";
|
|
2293
2373
|
var no_context_provider_default = createRule({
|
|
2294
2374
|
meta: {
|
|
2295
2375
|
type: "suggestion",
|
|
@@ -2302,11 +2382,11 @@ var no_context_provider_default = createRule({
|
|
|
2302
2382
|
},
|
|
2303
2383
|
schema: []
|
|
2304
2384
|
},
|
|
2305
|
-
name: RULE_NAME$
|
|
2306
|
-
create: create$
|
|
2385
|
+
name: RULE_NAME$41,
|
|
2386
|
+
create: create$41,
|
|
2307
2387
|
defaultOptions: []
|
|
2308
2388
|
});
|
|
2309
|
-
function create$
|
|
2389
|
+
function create$41(context) {
|
|
2310
2390
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
2311
2391
|
const { version } = getSettingsFromContext(context);
|
|
2312
2392
|
if (compare(version, "19.0.0", "<")) return {};
|
|
@@ -2337,7 +2417,7 @@ function create$39(context) {
|
|
|
2337
2417
|
|
|
2338
2418
|
//#endregion
|
|
2339
2419
|
//#region src/rules/no-create-ref/no-create-ref.ts
|
|
2340
|
-
const RULE_NAME$
|
|
2420
|
+
const RULE_NAME$40 = "no-create-ref";
|
|
2341
2421
|
var no_create_ref_default = createRule({
|
|
2342
2422
|
meta: {
|
|
2343
2423
|
type: "suggestion",
|
|
@@ -2345,11 +2425,11 @@ var no_create_ref_default = createRule({
|
|
|
2345
2425
|
messages: { default: "[Deprecated] Use 'useRef' instead." },
|
|
2346
2426
|
schema: []
|
|
2347
2427
|
},
|
|
2348
|
-
name: RULE_NAME$
|
|
2349
|
-
create: create$
|
|
2428
|
+
name: RULE_NAME$40,
|
|
2429
|
+
create: create$40,
|
|
2350
2430
|
defaultOptions: []
|
|
2351
2431
|
});
|
|
2352
|
-
function create$
|
|
2432
|
+
function create$40(context) {
|
|
2353
2433
|
return defineRuleListener({ CallExpression(node) {
|
|
2354
2434
|
if (core.isCreateRefCall(context, node) && ast.findParentNode(node, core.isClassComponent) == null) context.report({
|
|
2355
2435
|
messageId: "default",
|
|
@@ -2360,7 +2440,7 @@ function create$38(context) {
|
|
|
2360
2440
|
|
|
2361
2441
|
//#endregion
|
|
2362
2442
|
//#region src/rules/no-direct-mutation-state/no-direct-mutation-state.ts
|
|
2363
|
-
const RULE_NAME$
|
|
2443
|
+
const RULE_NAME$39 = "no-direct-mutation-state";
|
|
2364
2444
|
function isConstructorFunction(node) {
|
|
2365
2445
|
return ast.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && ast.isMethodOrProperty(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
2366
2446
|
}
|
|
@@ -2371,11 +2451,11 @@ var no_direct_mutation_state_default = createRule({
|
|
|
2371
2451
|
messages: { default: "Do not mutate state directly. Use 'setState()' instead." },
|
|
2372
2452
|
schema: []
|
|
2373
2453
|
},
|
|
2374
|
-
name: RULE_NAME$
|
|
2375
|
-
create: create$
|
|
2454
|
+
name: RULE_NAME$39,
|
|
2455
|
+
create: create$39,
|
|
2376
2456
|
defaultOptions: []
|
|
2377
2457
|
});
|
|
2378
|
-
function create$
|
|
2458
|
+
function create$39(context) {
|
|
2379
2459
|
return defineRuleListener({ AssignmentExpression(node) {
|
|
2380
2460
|
if (!core.isAssignmentToThisState(node)) return;
|
|
2381
2461
|
const parentClass = ast.findParentNode(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
|
|
@@ -2389,7 +2469,7 @@ function create$37(context) {
|
|
|
2389
2469
|
|
|
2390
2470
|
//#endregion
|
|
2391
2471
|
//#region src/rules/no-duplicate-key/no-duplicate-key.ts
|
|
2392
|
-
const RULE_NAME$
|
|
2472
|
+
const RULE_NAME$38 = "no-duplicate-key";
|
|
2393
2473
|
var no_duplicate_key_default = createRule({
|
|
2394
2474
|
meta: {
|
|
2395
2475
|
type: "problem",
|
|
@@ -2397,11 +2477,11 @@ var no_duplicate_key_default = createRule({
|
|
|
2397
2477
|
messages: { default: "The 'key' prop must be unique to its sibling elements." },
|
|
2398
2478
|
schema: []
|
|
2399
2479
|
},
|
|
2400
|
-
name: RULE_NAME$
|
|
2401
|
-
create: create$
|
|
2480
|
+
name: RULE_NAME$38,
|
|
2481
|
+
create: create$38,
|
|
2402
2482
|
defaultOptions: []
|
|
2403
2483
|
});
|
|
2404
|
-
function create$
|
|
2484
|
+
function create$38(context) {
|
|
2405
2485
|
if (!context.sourceCode.text.includes("key=")) return {};
|
|
2406
2486
|
const keyedEntries = /* @__PURE__ */ new Map();
|
|
2407
2487
|
function isKeyValueEqual(a, b) {
|
|
@@ -2456,7 +2536,7 @@ function create$36(context) {
|
|
|
2456
2536
|
|
|
2457
2537
|
//#endregion
|
|
2458
2538
|
//#region src/rules/no-forward-ref/no-forward-ref.ts
|
|
2459
|
-
const RULE_NAME$
|
|
2539
|
+
const RULE_NAME$37 = "no-forward-ref";
|
|
2460
2540
|
var no_forward_ref_default = createRule({
|
|
2461
2541
|
meta: {
|
|
2462
2542
|
type: "suggestion",
|
|
@@ -2469,11 +2549,11 @@ var no_forward_ref_default = createRule({
|
|
|
2469
2549
|
},
|
|
2470
2550
|
schema: []
|
|
2471
2551
|
},
|
|
2472
|
-
name: RULE_NAME$
|
|
2473
|
-
create: create$
|
|
2552
|
+
name: RULE_NAME$37,
|
|
2553
|
+
create: create$37,
|
|
2474
2554
|
defaultOptions: []
|
|
2475
2555
|
});
|
|
2476
|
-
function create$
|
|
2556
|
+
function create$37(context) {
|
|
2477
2557
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
2478
2558
|
const { version } = getSettingsFromContext(context);
|
|
2479
2559
|
if (compare(version, "19.0.0", "<")) return {};
|
|
@@ -2576,9 +2656,47 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
2576
2656
|
].join(" ")), ...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]];
|
|
2577
2657
|
}
|
|
2578
2658
|
|
|
2659
|
+
//#endregion
|
|
2660
|
+
//#region src/rules/no-implicit-children/no-implicit-children.ts
|
|
2661
|
+
const RULE_NAME$36 = "no-implicit-children";
|
|
2662
|
+
const RE_REACT_CHILDREN_TYPE = /react\.(reactnode|reactelement|reactportal)$/i;
|
|
2663
|
+
var no_implicit_children_default = createRule({
|
|
2664
|
+
meta: {
|
|
2665
|
+
type: "problem",
|
|
2666
|
+
docs: { description: "Prevents implicitly passing the 'children' prop to components." },
|
|
2667
|
+
messages: { default: "This spread attribute implicitly passes the 'children' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'children' prop, use 'children={value}'." },
|
|
2668
|
+
schema: []
|
|
2669
|
+
},
|
|
2670
|
+
name: RULE_NAME$36,
|
|
2671
|
+
create: create$36,
|
|
2672
|
+
defaultOptions: []
|
|
2673
|
+
});
|
|
2674
|
+
function create$36(context) {
|
|
2675
|
+
const services = ESLintUtils.getParserServices(context, false);
|
|
2676
|
+
const checker = services.program.getTypeChecker();
|
|
2677
|
+
return defineRuleListener({ JSXSpreadAttribute(node) {
|
|
2678
|
+
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
2679
|
+
const children = type.getProperty("children");
|
|
2680
|
+
if (children == null) continue;
|
|
2681
|
+
const fqn = getFullyQualifiedNameEx(checker, children).toLowerCase();
|
|
2682
|
+
if (fqn.endsWith("attributes.children") || fqn.endsWith("propswithchildren.children")) continue;
|
|
2683
|
+
const childrenType = checker.getTypeOfSymbol(children);
|
|
2684
|
+
const typeSymbol = childrenType.aliasSymbol ?? childrenType.symbol;
|
|
2685
|
+
if (typeSymbol != null) {
|
|
2686
|
+
const typeFqn = checker.getFullyQualifiedName(typeSymbol);
|
|
2687
|
+
if (RE_REACT_CHILDREN_TYPE.test(typeFqn) || /^JSX\.Element$/i.test(typeFqn)) continue;
|
|
2688
|
+
}
|
|
2689
|
+
context.report({
|
|
2690
|
+
messageId: "default",
|
|
2691
|
+
node
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
} });
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2579
2697
|
//#endregion
|
|
2580
2698
|
//#region src/rules/no-implicit-key/no-implicit-key.ts
|
|
2581
|
-
const RULE_NAME$
|
|
2699
|
+
const RULE_NAME$35 = "no-implicit-key";
|
|
2582
2700
|
var no_implicit_key_default = createRule({
|
|
2583
2701
|
meta: {
|
|
2584
2702
|
type: "problem",
|
|
@@ -2586,11 +2704,11 @@ var no_implicit_key_default = createRule({
|
|
|
2586
2704
|
messages: { default: "This spread attribute implicitly passes the 'key' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'key' prop, use 'key={value}'." },
|
|
2587
2705
|
schema: []
|
|
2588
2706
|
},
|
|
2589
|
-
name: RULE_NAME$
|
|
2590
|
-
create: create$
|
|
2707
|
+
name: RULE_NAME$35,
|
|
2708
|
+
create: create$35,
|
|
2591
2709
|
defaultOptions: []
|
|
2592
2710
|
});
|
|
2593
|
-
function create$
|
|
2711
|
+
function create$35(context) {
|
|
2594
2712
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2595
2713
|
const checker = services.program.getTypeChecker();
|
|
2596
2714
|
return defineRuleListener({ JSXSpreadAttribute(node) {
|
|
@@ -2598,6 +2716,47 @@ function create$34(context) {
|
|
|
2598
2716
|
const key = type.getProperty("key");
|
|
2599
2717
|
if (key == null) continue;
|
|
2600
2718
|
if (getFullyQualifiedNameEx(checker, key).toLowerCase().endsWith("react.attributes.key")) continue;
|
|
2719
|
+
const keyType = checker.getTypeOfSymbol(key);
|
|
2720
|
+
if (keyType.aliasSymbol != null) {
|
|
2721
|
+
if (checker.getFullyQualifiedName(keyType.aliasSymbol).toLowerCase().endsWith("react.key")) continue;
|
|
2722
|
+
}
|
|
2723
|
+
context.report({
|
|
2724
|
+
messageId: "default",
|
|
2725
|
+
node
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2728
|
+
} });
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
//#endregion
|
|
2732
|
+
//#region src/rules/no-implicit-ref/no-implicit-ref.ts
|
|
2733
|
+
const RULE_NAME$34 = "no-implicit-ref";
|
|
2734
|
+
const RE_REACT_REF_TYPE = /react\.(ref|legacyref|refcallback|refobject)$/i;
|
|
2735
|
+
var no_implicit_ref_default = createRule({
|
|
2736
|
+
meta: {
|
|
2737
|
+
type: "problem",
|
|
2738
|
+
docs: { description: "Prevents implicitly passing the 'ref' prop to components." },
|
|
2739
|
+
messages: { default: "This spread attribute implicitly passes the 'ref' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'ref' prop, use 'ref={value}'." },
|
|
2740
|
+
schema: []
|
|
2741
|
+
},
|
|
2742
|
+
name: RULE_NAME$34,
|
|
2743
|
+
create: create$34,
|
|
2744
|
+
defaultOptions: []
|
|
2745
|
+
});
|
|
2746
|
+
function create$34(context) {
|
|
2747
|
+
const services = ESLintUtils.getParserServices(context, false);
|
|
2748
|
+
const checker = services.program.getTypeChecker();
|
|
2749
|
+
return defineRuleListener({ JSXSpreadAttribute(node) {
|
|
2750
|
+
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
2751
|
+
const ref = type.getProperty("ref");
|
|
2752
|
+
if (ref == null) continue;
|
|
2753
|
+
if (getFullyQualifiedNameEx(checker, ref).toLowerCase().endsWith("attributes.ref")) continue;
|
|
2754
|
+
const refType = checker.getTypeOfSymbol(ref);
|
|
2755
|
+
const typeSymbol = refType.aliasSymbol ?? refType.symbol;
|
|
2756
|
+
if (typeSymbol != null) {
|
|
2757
|
+
const typeFqn = checker.getFullyQualifiedName(typeSymbol);
|
|
2758
|
+
if (RE_REACT_REF_TYPE.test(typeFqn)) continue;
|
|
2759
|
+
}
|
|
2601
2760
|
context.report({
|
|
2602
2761
|
messageId: "default",
|
|
2603
2762
|
node
|
|
@@ -4235,24 +4394,35 @@ var purity_default = createRule({
|
|
|
4235
4394
|
function create$7(context) {
|
|
4236
4395
|
const hCollector = core.useHookCollector(context);
|
|
4237
4396
|
const cCollector = core.useComponentCollector(context);
|
|
4238
|
-
const
|
|
4239
|
-
const
|
|
4397
|
+
const cEntries = [];
|
|
4398
|
+
const nEntries = [];
|
|
4240
4399
|
return defineRuleListener(hCollector.visitor, cCollector.visitor, {
|
|
4241
4400
|
CallExpression(node) {
|
|
4242
|
-
if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
4243
4401
|
const expr = ast.getUnderlyingExpression(node.callee);
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4402
|
+
switch (true) {
|
|
4403
|
+
case expr.type === AST_NODE_TYPES.Identifier: {
|
|
4404
|
+
if (!IMPURE_FUNCS.get("globalThis")?.has(expr.name)) return;
|
|
4405
|
+
const func = ast.findParentNode(node, ast.isFunction);
|
|
4406
|
+
if (func == null) return;
|
|
4407
|
+
cEntries.push({
|
|
4408
|
+
func,
|
|
4409
|
+
node
|
|
4410
|
+
});
|
|
4411
|
+
break;
|
|
4412
|
+
}
|
|
4413
|
+
case expr.type === AST_NODE_TYPES.MemberExpression && expr.object.type === AST_NODE_TYPES.Identifier && expr.property.type === AST_NODE_TYPES.Identifier: {
|
|
4414
|
+
const objectName = expr.object.name;
|
|
4415
|
+
const propertyName = expr.property.name;
|
|
4416
|
+
if (!IMPURE_FUNCS.get(objectName)?.has(propertyName)) return;
|
|
4417
|
+
const func = ast.findParentNode(node, ast.isFunction);
|
|
4418
|
+
if (func == null) return;
|
|
4419
|
+
cEntries.push({
|
|
4420
|
+
func,
|
|
4421
|
+
node
|
|
4422
|
+
});
|
|
4423
|
+
break;
|
|
4424
|
+
}
|
|
4425
|
+
}
|
|
4256
4426
|
},
|
|
4257
4427
|
NewExpression(node) {
|
|
4258
4428
|
const expr = ast.getUnderlyingExpression(node.callee);
|
|
@@ -4260,7 +4430,7 @@ function create$7(context) {
|
|
|
4260
4430
|
if (!IMPURE_CTORS.has(expr.name)) return;
|
|
4261
4431
|
const func = ast.findParentNode(node, ast.isFunction);
|
|
4262
4432
|
if (func == null) return;
|
|
4263
|
-
|
|
4433
|
+
nEntries.push({
|
|
4264
4434
|
func,
|
|
4265
4435
|
node
|
|
4266
4436
|
});
|
|
@@ -4269,7 +4439,7 @@ function create$7(context) {
|
|
|
4269
4439
|
const comps = cCollector.ctx.getAllComponents(node);
|
|
4270
4440
|
const hooks = hCollector.ctx.getAllHooks(node);
|
|
4271
4441
|
const funcs = [...comps, ...hooks];
|
|
4272
|
-
for (const { func, node } of [...
|
|
4442
|
+
for (const { func, node } of [...cEntries, ...nEntries]) {
|
|
4273
4443
|
if (!funcs.some((f) => f.node === func)) continue;
|
|
4274
4444
|
context.report({
|
|
4275
4445
|
data: { name: context.sourceCode.getText(node) },
|
|
@@ -7232,11 +7402,8 @@ const plugin = {
|
|
|
7232
7402
|
"jsx-dollar": jsx_dollar_default,
|
|
7233
7403
|
"jsx-key-before-spread": jsx_key_before_spread_default,
|
|
7234
7404
|
"jsx-no-comment-textnodes": jsx_no_comment_textnodes_default,
|
|
7235
|
-
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
7236
7405
|
"jsx-shorthand-boolean": jsx_shorthand_boolean_default,
|
|
7237
7406
|
"jsx-shorthand-fragment": jsx_shorthand_fragment_default,
|
|
7238
|
-
"jsx-uses-react": jsx_uses_react_default,
|
|
7239
|
-
"jsx-uses-vars": jsx_uses_vars_default,
|
|
7240
7407
|
"no-access-state-in-setstate": no_access_state_in_setstate_default,
|
|
7241
7408
|
"no-array-index-key": no_array_index_key_default,
|
|
7242
7409
|
"no-children-count": no_children_count_default,
|
|
@@ -7255,7 +7422,9 @@ const plugin = {
|
|
|
7255
7422
|
"no-direct-mutation-state": no_direct_mutation_state_default,
|
|
7256
7423
|
"no-duplicate-key": no_duplicate_key_default,
|
|
7257
7424
|
"no-forward-ref": no_forward_ref_default,
|
|
7425
|
+
"no-implicit-children": no_implicit_children_default,
|
|
7258
7426
|
"no-implicit-key": no_implicit_key_default,
|
|
7427
|
+
"no-implicit-ref": no_implicit_ref_default,
|
|
7259
7428
|
"no-leaked-conditional-rendering": no_leaked_conditional_rendering_default,
|
|
7260
7429
|
"no-missing-component-display-name": no_missing_component_display_name_default,
|
|
7261
7430
|
"no-missing-context-display-name": no_missing_context_display_name_default,
|
|
@@ -7309,9 +7478,6 @@ const rules$6 = {
|
|
|
7309
7478
|
"react-x/exhaustive-deps": "warn",
|
|
7310
7479
|
"react-x/jsx-key-before-spread": "warn",
|
|
7311
7480
|
"react-x/jsx-no-comment-textnodes": "warn",
|
|
7312
|
-
"react-x/jsx-no-duplicate-props": "warn",
|
|
7313
|
-
"react-x/jsx-uses-react": "warn",
|
|
7314
|
-
"react-x/jsx-uses-vars": "warn",
|
|
7315
7481
|
"react-x/no-access-state-in-setstate": "error",
|
|
7316
7482
|
"react-x/no-array-index-key": "warn",
|
|
7317
7483
|
"react-x/no-children-count": "warn",
|
|
@@ -7356,11 +7522,7 @@ const settings$5 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
|
7356
7522
|
/**
|
|
7357
7523
|
* Disables rules that are already handled by TypeScript
|
|
7358
7524
|
*/
|
|
7359
|
-
const rules$5 = {
|
|
7360
|
-
"react-x/jsx-no-duplicate-props": "off",
|
|
7361
|
-
"react-x/jsx-uses-react": "off",
|
|
7362
|
-
"react-x/jsx-uses-vars": "off"
|
|
7363
|
-
};
|
|
7525
|
+
const rules$5 = {};
|
|
7364
7526
|
|
|
7365
7527
|
//#endregion
|
|
7366
7528
|
//#region src/configs/recommended-typescript.ts
|
|
@@ -7389,7 +7551,6 @@ var recommended_type_checked_exports = /* @__PURE__ */ __exportAll({
|
|
|
7389
7551
|
const name$3 = "react-x/recommended-type-checked";
|
|
7390
7552
|
const rules$3 = {
|
|
7391
7553
|
...rules$4,
|
|
7392
|
-
"react-x/no-implicit-key": "error",
|
|
7393
7554
|
"react-x/no-leaked-conditional-rendering": "error"
|
|
7394
7555
|
};
|
|
7395
7556
|
const plugins$3 = { ...plugins$4 };
|
|
@@ -7447,7 +7608,6 @@ var strict_type_checked_exports = /* @__PURE__ */ __exportAll({
|
|
|
7447
7608
|
const name = "react-x/strict-type-checked";
|
|
7448
7609
|
const rules = {
|
|
7449
7610
|
...rules$1,
|
|
7450
|
-
"react-x/no-implicit-key": "error",
|
|
7451
7611
|
"react-x/no-leaked-conditional-rendering": "error",
|
|
7452
7612
|
"react-x/no-unused-props": "warn"
|
|
7453
7613
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.76",
|
|
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",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-api-utils": "^2.4.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "3.0.0-next.
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@
|
|
52
|
-
"@eslint-react/var": "3.0.0-next.
|
|
48
|
+
"@eslint-react/ast": "3.0.0-next.76",
|
|
49
|
+
"@eslint-react/core": "3.0.0-next.76",
|
|
50
|
+
"@eslint-react/shared": "3.0.0-next.76",
|
|
51
|
+
"@local/eff": "3.0.0-beta.72",
|
|
52
|
+
"@eslint-react/var": "3.0.0-next.76"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.14",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@local/configs": "0.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"eslint": "^
|
|
64
|
-
"typescript": "
|
|
63
|
+
"eslint": "^10.0.0",
|
|
64
|
+
"typescript": "*"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=22.0.0"
|