eslint-plugin-react-x 3.0.0-next.71 → 3.0.0-next.74
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 +241 -126
- 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";
|
|
@@ -57,8 +56,6 @@ const conflictingRules$1 = [
|
|
|
57
56
|
"react/jsx-no-target-blank",
|
|
58
57
|
"react/jsx-no-useless-fragment",
|
|
59
58
|
"react/jsx-pascal-case",
|
|
60
|
-
"react/jsx-uses-react",
|
|
61
|
-
"react/jsx-uses-vars",
|
|
62
59
|
"react/no-access-state-in-setstate",
|
|
63
60
|
"react/no-array-index-key",
|
|
64
61
|
"react/no-children-prop",
|
|
@@ -148,7 +145,7 @@ const rules$7 = {
|
|
|
148
145
|
//#endregion
|
|
149
146
|
//#region package.json
|
|
150
147
|
var name$6 = "eslint-plugin-react-x";
|
|
151
|
-
var version = "3.0.0-next.
|
|
148
|
+
var version = "3.0.0-next.74";
|
|
152
149
|
|
|
153
150
|
//#endregion
|
|
154
151
|
//#region src/utils/create-rule.ts
|
|
@@ -305,7 +302,7 @@ function getTypeVariants(types) {
|
|
|
305
302
|
|
|
306
303
|
//#endregion
|
|
307
304
|
//#region src/rules/component-hook-factories/component-hook-factories.ts
|
|
308
|
-
const RULE_NAME$
|
|
305
|
+
const RULE_NAME$61 = "component-hook-factories";
|
|
309
306
|
var component_hook_factories_default = createRule({
|
|
310
307
|
meta: {
|
|
311
308
|
type: "problem",
|
|
@@ -316,11 +313,11 @@ var component_hook_factories_default = createRule({
|
|
|
316
313
|
},
|
|
317
314
|
schema: []
|
|
318
315
|
},
|
|
319
|
-
name: RULE_NAME$
|
|
320
|
-
create: create$
|
|
316
|
+
name: RULE_NAME$61,
|
|
317
|
+
create: create$61,
|
|
321
318
|
defaultOptions: []
|
|
322
319
|
});
|
|
323
|
-
function create$
|
|
320
|
+
function create$61(context) {
|
|
324
321
|
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
322
|
const fCollector = core.useComponentCollector(context, { hint });
|
|
326
323
|
const cCollector = core.useComponentCollectorLegacy(context);
|
|
@@ -364,7 +361,7 @@ function create$63(context) {
|
|
|
364
361
|
|
|
365
362
|
//#endregion
|
|
366
363
|
//#region src/rules/error-boundaries/error-boundaries.ts
|
|
367
|
-
const RULE_NAME$
|
|
364
|
+
const RULE_NAME$60 = "error-boundaries";
|
|
368
365
|
var error_boundaries_default = createRule({
|
|
369
366
|
meta: {
|
|
370
367
|
type: "problem",
|
|
@@ -375,11 +372,11 @@ var error_boundaries_default = createRule({
|
|
|
375
372
|
},
|
|
376
373
|
schema: []
|
|
377
374
|
},
|
|
378
|
-
name: RULE_NAME$
|
|
379
|
-
create: create$
|
|
375
|
+
name: RULE_NAME$60,
|
|
376
|
+
create: create$60,
|
|
380
377
|
defaultOptions: []
|
|
381
378
|
});
|
|
382
|
-
function create$
|
|
379
|
+
function create$60(context) {
|
|
383
380
|
if (!context.sourceCode.text.includes("try")) return {};
|
|
384
381
|
const { ctx, visitor } = core.useComponentCollector(context);
|
|
385
382
|
const reported = /* @__PURE__ */ new Set();
|
|
@@ -1319,7 +1316,7 @@ function getUnknownDependenciesMessage(reactiveHookName) {
|
|
|
1319
1316
|
|
|
1320
1317
|
//#endregion
|
|
1321
1318
|
//#region src/rules/immutability/immutability.ts
|
|
1322
|
-
const RULE_NAME$
|
|
1319
|
+
const RULE_NAME$59 = "immutability";
|
|
1323
1320
|
/**
|
|
1324
1321
|
* Array methods that mutate the array in place.
|
|
1325
1322
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
@@ -1345,11 +1342,11 @@ var immutability_default = createRule({
|
|
|
1345
1342
|
},
|
|
1346
1343
|
schema: []
|
|
1347
1344
|
},
|
|
1348
|
-
name: RULE_NAME$
|
|
1349
|
-
create: create$
|
|
1345
|
+
name: RULE_NAME$59,
|
|
1346
|
+
create: create$59,
|
|
1350
1347
|
defaultOptions: []
|
|
1351
1348
|
});
|
|
1352
|
-
function create$
|
|
1349
|
+
function create$59(context) {
|
|
1353
1350
|
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
1354
1351
|
const hCollector = core.useHookCollector(context);
|
|
1355
1352
|
const cCollector = core.useComponentCollector(context);
|
|
@@ -1470,7 +1467,7 @@ function create$61(context) {
|
|
|
1470
1467
|
|
|
1471
1468
|
//#endregion
|
|
1472
1469
|
//#region src/rules/jsx-dollar/jsx-dollar.ts
|
|
1473
|
-
const RULE_NAME$
|
|
1470
|
+
const RULE_NAME$58 = "jsx-dollar";
|
|
1474
1471
|
var jsx_dollar_default = createRule({
|
|
1475
1472
|
meta: {
|
|
1476
1473
|
type: "suggestion",
|
|
@@ -1483,11 +1480,11 @@ var jsx_dollar_default = createRule({
|
|
|
1483
1480
|
},
|
|
1484
1481
|
schema: []
|
|
1485
1482
|
},
|
|
1486
|
-
name: RULE_NAME$
|
|
1487
|
-
create: create$
|
|
1483
|
+
name: RULE_NAME$58,
|
|
1484
|
+
create: create$58,
|
|
1488
1485
|
defaultOptions: []
|
|
1489
1486
|
});
|
|
1490
|
-
function create$
|
|
1487
|
+
function create$58(context) {
|
|
1491
1488
|
/**
|
|
1492
1489
|
* Visitor function for JSXElement and JSXFragment nodes
|
|
1493
1490
|
* @param node The JSXElement or JSXFragment node to be checked
|
|
@@ -1528,7 +1525,7 @@ function create$60(context) {
|
|
|
1528
1525
|
|
|
1529
1526
|
//#endregion
|
|
1530
1527
|
//#region src/rules/jsx-key-before-spread/jsx-key-before-spread.ts
|
|
1531
|
-
const RULE_NAME$
|
|
1528
|
+
const RULE_NAME$57 = "jsx-key-before-spread";
|
|
1532
1529
|
var jsx_key_before_spread_default = createRule({
|
|
1533
1530
|
meta: {
|
|
1534
1531
|
type: "problem",
|
|
@@ -1536,11 +1533,11 @@ var jsx_key_before_spread_default = createRule({
|
|
|
1536
1533
|
messages: { default: "The 'key' prop must be placed before any spread props when using the new JSX transform." },
|
|
1537
1534
|
schema: []
|
|
1538
1535
|
},
|
|
1539
|
-
name: RULE_NAME$
|
|
1540
|
-
create: create$
|
|
1536
|
+
name: RULE_NAME$57,
|
|
1537
|
+
create: create$57,
|
|
1541
1538
|
defaultOptions: []
|
|
1542
1539
|
});
|
|
1543
|
-
function create$
|
|
1540
|
+
function create$57(context) {
|
|
1544
1541
|
const { jsx } = JsxInspector.from(context).jsxConfig;
|
|
1545
1542
|
if (jsx !== JsxEmit.ReactJSX && jsx !== JsxEmit.ReactJSXDev) return {};
|
|
1546
1543
|
return defineRuleListener({ JSXOpeningElement(node) {
|
|
@@ -1561,7 +1558,7 @@ function create$59(context) {
|
|
|
1561
1558
|
|
|
1562
1559
|
//#endregion
|
|
1563
1560
|
//#region src/rules/jsx-no-comment-textnodes/jsx-no-comment-textnodes.ts
|
|
1564
|
-
const RULE_NAME$
|
|
1561
|
+
const RULE_NAME$56 = "jsx-no-comment-textnodes";
|
|
1565
1562
|
var jsx_no_comment_textnodes_default = createRule({
|
|
1566
1563
|
meta: {
|
|
1567
1564
|
type: "problem",
|
|
@@ -1569,11 +1566,11 @@ var jsx_no_comment_textnodes_default = createRule({
|
|
|
1569
1566
|
messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
|
|
1570
1567
|
schema: []
|
|
1571
1568
|
},
|
|
1572
|
-
name: RULE_NAME$
|
|
1573
|
-
create: create$
|
|
1569
|
+
name: RULE_NAME$56,
|
|
1570
|
+
create: create$56,
|
|
1574
1571
|
defaultOptions: []
|
|
1575
1572
|
});
|
|
1576
|
-
function create$
|
|
1573
|
+
function create$56(context) {
|
|
1577
1574
|
function hasCommentLike(node) {
|
|
1578
1575
|
if (ast.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
|
|
1579
1576
|
return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
|
|
@@ -1594,7 +1591,7 @@ function create$58(context) {
|
|
|
1594
1591
|
|
|
1595
1592
|
//#endregion
|
|
1596
1593
|
//#region src/rules/jsx-no-duplicate-props/jsx-no-duplicate-props.ts
|
|
1597
|
-
const RULE_NAME$
|
|
1594
|
+
const RULE_NAME$55 = "jsx-no-duplicate-props";
|
|
1598
1595
|
var jsx_no_duplicate_props_default = createRule({
|
|
1599
1596
|
meta: {
|
|
1600
1597
|
type: "problem",
|
|
@@ -1602,11 +1599,11 @@ var jsx_no_duplicate_props_default = createRule({
|
|
|
1602
1599
|
messages: { default: "This JSX property is assigned multiple times." },
|
|
1603
1600
|
schema: []
|
|
1604
1601
|
},
|
|
1605
|
-
name: RULE_NAME$
|
|
1606
|
-
create: create$
|
|
1602
|
+
name: RULE_NAME$55,
|
|
1603
|
+
create: create$55,
|
|
1607
1604
|
defaultOptions: []
|
|
1608
1605
|
});
|
|
1609
|
-
function create$
|
|
1606
|
+
function create$55(context) {
|
|
1610
1607
|
return defineRuleListener({ JSXOpeningElement(node) {
|
|
1611
1608
|
const props = [];
|
|
1612
1609
|
for (const attr of node.attributes) {
|
|
@@ -1627,7 +1624,7 @@ function create$57(context) {
|
|
|
1627
1624
|
|
|
1628
1625
|
//#endregion
|
|
1629
1626
|
//#region src/rules/jsx-shorthand-boolean/jsx-shorthand-boolean.ts
|
|
1630
|
-
const RULE_NAME$
|
|
1627
|
+
const RULE_NAME$54 = "jsx-shorthand-boolean";
|
|
1631
1628
|
const defaultOptions$4 = [1];
|
|
1632
1629
|
const schema$4 = [{
|
|
1633
1630
|
type: "integer",
|
|
@@ -1641,11 +1638,11 @@ var jsx_shorthand_boolean_default = createRule({
|
|
|
1641
1638
|
messages: { default: "{{message}}" },
|
|
1642
1639
|
schema: schema$4
|
|
1643
1640
|
},
|
|
1644
|
-
name: RULE_NAME$
|
|
1645
|
-
create: create$
|
|
1641
|
+
name: RULE_NAME$54,
|
|
1642
|
+
create: create$54,
|
|
1646
1643
|
defaultOptions: defaultOptions$4
|
|
1647
1644
|
});
|
|
1648
|
-
function create$
|
|
1645
|
+
function create$54(context) {
|
|
1649
1646
|
const policy = context.options[0] ?? defaultOptions$4[0];
|
|
1650
1647
|
const jsx = JsxInspector.from(context);
|
|
1651
1648
|
return defineRuleListener({ JSXAttribute(node) {
|
|
@@ -1674,7 +1671,7 @@ function create$56(context) {
|
|
|
1674
1671
|
|
|
1675
1672
|
//#endregion
|
|
1676
1673
|
//#region src/rules/jsx-shorthand-fragment/jsx-shorthand-fragment.ts
|
|
1677
|
-
const RULE_NAME$
|
|
1674
|
+
const RULE_NAME$53 = "jsx-shorthand-fragment";
|
|
1678
1675
|
const defaultOptions$3 = [1];
|
|
1679
1676
|
const schema$3 = [{
|
|
1680
1677
|
type: "integer",
|
|
@@ -1688,11 +1685,11 @@ var jsx_shorthand_fragment_default = createRule({
|
|
|
1688
1685
|
messages: { default: "{{message}}" },
|
|
1689
1686
|
schema: schema$3
|
|
1690
1687
|
},
|
|
1691
|
-
name: RULE_NAME$
|
|
1692
|
-
create: create$
|
|
1688
|
+
name: RULE_NAME$53,
|
|
1689
|
+
create: create$53,
|
|
1693
1690
|
defaultOptions: defaultOptions$3
|
|
1694
1691
|
});
|
|
1695
|
-
function create$
|
|
1692
|
+
function create$53(context) {
|
|
1696
1693
|
const policy = context.options[0] ?? defaultOptions$3[0];
|
|
1697
1694
|
const jsx = JsxInspector.from(context);
|
|
1698
1695
|
const { jsxFragmentFactory } = jsx.jsxConfig;
|
|
@@ -1723,73 +1720,188 @@ function create$55(context) {
|
|
|
1723
1720
|
}
|
|
1724
1721
|
|
|
1725
1722
|
//#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
|
-
|
|
1723
|
+
//#region ../../../.pkgs/eff/dist/index.js
|
|
1724
|
+
function not(predicate) {
|
|
1725
|
+
return (data) => !predicate(data);
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Returns its argument.
|
|
1729
|
+
*
|
|
1730
|
+
* @param x - The value to return.
|
|
1731
|
+
* @returns The input value unchanged.
|
|
1732
|
+
*/
|
|
1733
|
+
function identity(x) {
|
|
1734
|
+
return x;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Creates a function that can be used in a data-last (aka `pipe`able) or
|
|
1738
|
+
* data-first style.
|
|
1739
|
+
*
|
|
1740
|
+
* The first parameter to `dual` is either the arity of the uncurried function
|
|
1741
|
+
* or a predicate that determines if the function is being used in a data-first
|
|
1742
|
+
* or data-last style.
|
|
1743
|
+
*
|
|
1744
|
+
* Using the arity is the most common use case, but there are some cases where
|
|
1745
|
+
* you may want to use a predicate. For example, if you have a function that
|
|
1746
|
+
* takes an optional argument, you can use a predicate to determine if the
|
|
1747
|
+
* function is being used in a data-first or data-last style.
|
|
1748
|
+
*
|
|
1749
|
+
* You can pass either the arity of the uncurried function or a predicate
|
|
1750
|
+
* which determines if the function is being used in a data-first or
|
|
1751
|
+
* data-last style.
|
|
1752
|
+
*
|
|
1753
|
+
* **Example** (Using arity to determine data-first or data-last style)
|
|
1754
|
+
*
|
|
1755
|
+
* ```ts
|
|
1756
|
+
* import { dual, pipe } from "effect/Function"
|
|
1757
|
+
*
|
|
1758
|
+
* const sum = dual<
|
|
1759
|
+
* (that: number) => (self: number) => number,
|
|
1760
|
+
* (self: number, that: number) => number
|
|
1761
|
+
* >(2, (self, that) => self + that)
|
|
1762
|
+
*
|
|
1763
|
+
* console.log(sum(2, 3)) // 5
|
|
1764
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
1765
|
+
* ```
|
|
1766
|
+
*
|
|
1767
|
+
* **Example** (Using call signatures to define the overloads)
|
|
1768
|
+
*
|
|
1769
|
+
* ```ts
|
|
1770
|
+
* import { dual, pipe } from "effect/Function"
|
|
1771
|
+
*
|
|
1772
|
+
* const sum: {
|
|
1773
|
+
* (that: number): (self: number) => number
|
|
1774
|
+
* (self: number, that: number): number
|
|
1775
|
+
* } = dual(2, (self: number, that: number): number => self + that)
|
|
1776
|
+
*
|
|
1777
|
+
* console.log(sum(2, 3)) // 5
|
|
1778
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
1779
|
+
* ```
|
|
1780
|
+
*
|
|
1781
|
+
* **Example** (Using a predicate to determine data-first or data-last style)
|
|
1782
|
+
*
|
|
1783
|
+
* ```ts
|
|
1784
|
+
* import { dual, pipe } from "effect/Function"
|
|
1785
|
+
*
|
|
1786
|
+
* const sum = dual<
|
|
1787
|
+
* (that: number) => (self: number) => number,
|
|
1788
|
+
* (self: number, that: number) => number
|
|
1789
|
+
* >(
|
|
1790
|
+
* (args) => args.length === 2,
|
|
1791
|
+
* (self, that) => self + that
|
|
1792
|
+
* )
|
|
1793
|
+
*
|
|
1794
|
+
* console.log(sum(2, 3)) // 5
|
|
1795
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
1796
|
+
* ```
|
|
1797
|
+
*
|
|
1798
|
+
* @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.
|
|
1799
|
+
* @param body - The function to be curried.
|
|
1800
|
+
* @since 1.0.0
|
|
1801
|
+
*/
|
|
1802
|
+
const dual = function(arity, body) {
|
|
1803
|
+
if (typeof arity === "function") return function() {
|
|
1804
|
+
return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
|
|
1805
|
+
};
|
|
1806
|
+
switch (arity) {
|
|
1807
|
+
case 0:
|
|
1808
|
+
case 1: throw new RangeError(`Invalid arity ${arity}`);
|
|
1809
|
+
case 2: return function(a, b) {
|
|
1810
|
+
if (arguments.length >= 2) return body(a, b);
|
|
1811
|
+
return function(self) {
|
|
1812
|
+
return body(self, a);
|
|
1813
|
+
};
|
|
1814
|
+
};
|
|
1815
|
+
case 3: return function(a, b, c) {
|
|
1816
|
+
if (arguments.length >= 3) return body(a, b, c);
|
|
1817
|
+
return function(self) {
|
|
1818
|
+
return body(self, a, b);
|
|
1819
|
+
};
|
|
1820
|
+
};
|
|
1821
|
+
default: return function() {
|
|
1822
|
+
if (arguments.length >= arity) return body.apply(this, arguments);
|
|
1823
|
+
const args = arguments;
|
|
1824
|
+
return function(self) {
|
|
1825
|
+
return body(self, ...args);
|
|
1826
|
+
};
|
|
1827
|
+
};
|
|
1749
1828
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1829
|
+
};
|
|
1830
|
+
/**
|
|
1831
|
+
* Do nothing and return `void`.
|
|
1832
|
+
*/
|
|
1833
|
+
function constVoid() {}
|
|
1834
|
+
/**
|
|
1835
|
+
* Do nothing and return `true`.
|
|
1836
|
+
*
|
|
1837
|
+
* @returns true
|
|
1838
|
+
*/
|
|
1839
|
+
function constTrue() {
|
|
1840
|
+
return true;
|
|
1755
1841
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1842
|
+
/**
|
|
1843
|
+
* Do nothing and return `false`.
|
|
1844
|
+
*
|
|
1845
|
+
* @returns false
|
|
1846
|
+
*/
|
|
1847
|
+
function constFalse() {
|
|
1848
|
+
return false;
|
|
1763
1849
|
}
|
|
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
|
-
|
|
1850
|
+
/**
|
|
1851
|
+
* 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`.
|
|
1852
|
+
* The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
|
|
1853
|
+
*
|
|
1854
|
+
* @param self - The first function to apply (or the composed function in data-last style).
|
|
1855
|
+
* @param bc - The second function to apply.
|
|
1856
|
+
* @returns A composed function that applies both functions in sequence.
|
|
1857
|
+
* @example
|
|
1858
|
+
* ```ts
|
|
1859
|
+
* import * as assert from "node:assert"
|
|
1860
|
+
* import { compose } from "effect/Function"
|
|
1861
|
+
*
|
|
1862
|
+
* const increment = (n: number) => n + 1;
|
|
1863
|
+
* const square = (n: number) => n * n;
|
|
1864
|
+
*
|
|
1865
|
+
* assert.strictEqual(compose(increment, square)(2), 9);
|
|
1866
|
+
* ```
|
|
1867
|
+
*
|
|
1868
|
+
* @since 1.0.0
|
|
1869
|
+
*/
|
|
1870
|
+
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
1871
|
+
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
|
|
1872
|
+
switch (arguments.length) {
|
|
1873
|
+
case 1: return ab;
|
|
1874
|
+
case 2: return function() {
|
|
1875
|
+
return bc(ab.apply(this, arguments));
|
|
1876
|
+
};
|
|
1877
|
+
case 3: return function() {
|
|
1878
|
+
return cd(bc(ab.apply(this, arguments)));
|
|
1879
|
+
};
|
|
1880
|
+
case 4: return function() {
|
|
1881
|
+
return de(cd(bc(ab.apply(this, arguments))));
|
|
1882
|
+
};
|
|
1883
|
+
case 5: return function() {
|
|
1884
|
+
return ef(de(cd(bc(ab.apply(this, arguments)))));
|
|
1885
|
+
};
|
|
1886
|
+
case 6: return function() {
|
|
1887
|
+
return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
|
|
1888
|
+
};
|
|
1889
|
+
case 7: return function() {
|
|
1890
|
+
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
|
|
1891
|
+
};
|
|
1892
|
+
case 8: return function() {
|
|
1893
|
+
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
|
|
1894
|
+
};
|
|
1895
|
+
case 9: return function() {
|
|
1896
|
+
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
function getOrElseUpdate(map, key, callback) {
|
|
1901
|
+
if (map.has(key)) return map.get(key);
|
|
1902
|
+
const value = callback();
|
|
1903
|
+
map.set(key, value);
|
|
1904
|
+
return value;
|
|
1793
1905
|
}
|
|
1794
1906
|
|
|
1795
1907
|
//#endregion
|
|
@@ -4239,20 +4351,31 @@ function create$7(context) {
|
|
|
4239
4351
|
const nExprs = [];
|
|
4240
4352
|
return defineRuleListener(hCollector.visitor, cCollector.visitor, {
|
|
4241
4353
|
CallExpression(node) {
|
|
4242
|
-
if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
4243
4354
|
const expr = ast.getUnderlyingExpression(node.callee);
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4355
|
+
switch (true) {
|
|
4356
|
+
case expr.type === AST_NODE_TYPES.Identifier: {
|
|
4357
|
+
if (!IMPURE_FUNCS.get("globalThis")?.has(expr.name)) return;
|
|
4358
|
+
const func = ast.findParentNode(node, ast.isFunction);
|
|
4359
|
+
if (func == null) return;
|
|
4360
|
+
cExprs.push({
|
|
4361
|
+
func,
|
|
4362
|
+
node
|
|
4363
|
+
});
|
|
4364
|
+
break;
|
|
4365
|
+
}
|
|
4366
|
+
case expr.type === AST_NODE_TYPES.MemberExpression && expr.object.type === AST_NODE_TYPES.Identifier && expr.property.type === AST_NODE_TYPES.Identifier: {
|
|
4367
|
+
const objectName = expr.object.name;
|
|
4368
|
+
const propertyName = expr.property.name;
|
|
4369
|
+
if (!IMPURE_FUNCS.get(objectName)?.has(propertyName)) return;
|
|
4370
|
+
const func = ast.findParentNode(node, ast.isFunction);
|
|
4371
|
+
if (func == null) return;
|
|
4372
|
+
cExprs.push({
|
|
4373
|
+
func,
|
|
4374
|
+
node
|
|
4375
|
+
});
|
|
4376
|
+
break;
|
|
4377
|
+
}
|
|
4378
|
+
}
|
|
4256
4379
|
},
|
|
4257
4380
|
NewExpression(node) {
|
|
4258
4381
|
const expr = ast.getUnderlyingExpression(node.callee);
|
|
@@ -7235,8 +7358,6 @@ const plugin = {
|
|
|
7235
7358
|
"jsx-no-duplicate-props": jsx_no_duplicate_props_default,
|
|
7236
7359
|
"jsx-shorthand-boolean": jsx_shorthand_boolean_default,
|
|
7237
7360
|
"jsx-shorthand-fragment": jsx_shorthand_fragment_default,
|
|
7238
|
-
"jsx-uses-react": jsx_uses_react_default,
|
|
7239
|
-
"jsx-uses-vars": jsx_uses_vars_default,
|
|
7240
7361
|
"no-access-state-in-setstate": no_access_state_in_setstate_default,
|
|
7241
7362
|
"no-array-index-key": no_array_index_key_default,
|
|
7242
7363
|
"no-children-count": no_children_count_default,
|
|
@@ -7310,8 +7431,6 @@ const rules$6 = {
|
|
|
7310
7431
|
"react-x/jsx-key-before-spread": "warn",
|
|
7311
7432
|
"react-x/jsx-no-comment-textnodes": "warn",
|
|
7312
7433
|
"react-x/jsx-no-duplicate-props": "warn",
|
|
7313
|
-
"react-x/jsx-uses-react": "warn",
|
|
7314
|
-
"react-x/jsx-uses-vars": "warn",
|
|
7315
7434
|
"react-x/no-access-state-in-setstate": "error",
|
|
7316
7435
|
"react-x/no-array-index-key": "warn",
|
|
7317
7436
|
"react-x/no-children-count": "warn",
|
|
@@ -7356,11 +7475,7 @@ const settings$5 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
|
7356
7475
|
/**
|
|
7357
7476
|
* Disables rules that are already handled by TypeScript
|
|
7358
7477
|
*/
|
|
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
|
-
};
|
|
7478
|
+
const rules$5 = { "react-x/jsx-no-duplicate-props": "off" };
|
|
7364
7479
|
|
|
7365
7480
|
//#endregion
|
|
7366
7481
|
//#region src/configs/recommended-typescript.ts
|
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.74",
|
|
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/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/shared": "3.0.0-next.74",
|
|
49
|
+
"@eslint-react/var": "3.0.0-next.74",
|
|
50
|
+
"@local/eff": "3.0.0-beta.72",
|
|
51
|
+
"@eslint-react/ast": "3.0.0-next.74",
|
|
52
|
+
"@eslint-react/core": "3.0.0-next.74"
|
|
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"
|