eslint-plugin-react-x 5.24.3 → 5.24.5
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 +132 -462
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -14,23 +14,17 @@ import { unionConstituents } from "ts-api-utils";
|
|
|
14
14
|
import "typescript";
|
|
15
15
|
import { simpleTraverse } from "@typescript-eslint/typescript-estree";
|
|
16
16
|
import { delimiterCase, snakeCase, toLowerCase } from "string-ts";
|
|
17
|
-
|
|
18
17
|
//#region \0rolldown/runtime.js
|
|
19
18
|
var __defProp = Object.defineProperty;
|
|
20
19
|
var __exportAll = (all, no_symbols) => {
|
|
21
20
|
let target = {};
|
|
22
|
-
for (var name in all) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (!no_symbols) {
|
|
29
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
30
|
-
}
|
|
21
|
+
for (var name in all) __defProp(target, name, {
|
|
22
|
+
get: all[name],
|
|
23
|
+
enumerable: true
|
|
24
|
+
});
|
|
25
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
31
26
|
return target;
|
|
32
27
|
};
|
|
33
|
-
|
|
34
28
|
//#endregion
|
|
35
29
|
//#region src/configs/disable-conflict-eslint-plugin-react.ts
|
|
36
30
|
var disable_conflict_eslint_plugin_react_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -81,7 +75,6 @@ const conflictingRules$1 = [
|
|
|
81
75
|
];
|
|
82
76
|
const name$10 = "react-x/disable-conflict-eslint-plugin-react";
|
|
83
77
|
const rules$9 = Object.fromEntries(conflictingRules$1.map((key) => [key, "off"]));
|
|
84
|
-
|
|
85
78
|
//#endregion
|
|
86
79
|
//#region src/configs/disable-conflict-eslint-plugin-react-hooks.ts
|
|
87
80
|
var disable_conflict_eslint_plugin_react_hooks_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -104,7 +97,6 @@ const conflictingRules = [
|
|
|
104
97
|
];
|
|
105
98
|
const name$9 = "react-x/disable-conflict-eslint-plugin-react-hooks";
|
|
106
99
|
const rules$8 = Object.fromEntries(conflictingRules.map((key) => [key, "off"]));
|
|
107
|
-
|
|
108
100
|
//#endregion
|
|
109
101
|
//#region src/configs/disable-experimental.ts
|
|
110
102
|
var disable_experimental_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -126,7 +118,6 @@ const rules$7 = {
|
|
|
126
118
|
"react-x/set-state-in-render": "off",
|
|
127
119
|
"react-x/static-components": "off"
|
|
128
120
|
};
|
|
129
|
-
|
|
130
121
|
//#endregion
|
|
131
122
|
//#region src/configs/disable-type-checked.ts
|
|
132
123
|
var disable_type_checked_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -141,22 +132,16 @@ const rules$6 = {
|
|
|
141
132
|
"react-x/no-leaked-conditional-rendering": "off",
|
|
142
133
|
"react-x/no-unused-props": "off"
|
|
143
134
|
};
|
|
144
|
-
|
|
145
135
|
//#endregion
|
|
146
136
|
//#region package.json
|
|
147
137
|
var name$6 = "eslint-plugin-react-x";
|
|
148
|
-
var version = "5.24.
|
|
149
|
-
|
|
138
|
+
var version = "5.24.5";
|
|
150
139
|
//#endregion
|
|
151
140
|
//#region src/utils/create-rule.ts
|
|
152
141
|
function getDocsUrl(ruleName) {
|
|
153
142
|
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
154
143
|
}
|
|
155
144
|
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
156
|
-
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/rules/error-boundaries/error-boundaries.ts
|
|
159
|
-
const RULE_NAME$50 = "error-boundaries";
|
|
160
145
|
var error_boundaries_default = createRule({
|
|
161
146
|
meta: {
|
|
162
147
|
type: "problem",
|
|
@@ -167,9 +152,8 @@ var error_boundaries_default = createRule({
|
|
|
167
152
|
},
|
|
168
153
|
schema: []
|
|
169
154
|
},
|
|
170
|
-
name:
|
|
171
|
-
create: create$50
|
|
172
|
-
defaultOptions: []
|
|
155
|
+
name: "error-boundaries",
|
|
156
|
+
create: create$50
|
|
173
157
|
});
|
|
174
158
|
function create$50(context) {
|
|
175
159
|
if (!context.sourceCode.text.includes("try")) return {};
|
|
@@ -213,7 +197,6 @@ function create$50(context) {
|
|
|
213
197
|
}
|
|
214
198
|
});
|
|
215
199
|
}
|
|
216
|
-
|
|
217
200
|
//#endregion
|
|
218
201
|
//#region src/rules/exhaustive-deps/exhaustive-deps.ts
|
|
219
202
|
const rule$1 = {
|
|
@@ -1085,7 +1068,6 @@ function isUseEffectEventIdentifier$1(node) {
|
|
|
1085
1068
|
function getUnknownDependenciesMessage(reactiveHookName) {
|
|
1086
1069
|
return `React Hook ${reactiveHookName} received a function whose dependencies are unknown. Pass an inline function instead.`;
|
|
1087
1070
|
}
|
|
1088
|
-
|
|
1089
1071
|
//#endregion
|
|
1090
1072
|
//#region src/rules/globals/helpers.ts
|
|
1091
1073
|
const MUTATING_ARRAY_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -1108,7 +1090,6 @@ function resolveToFunction(context, node, seen = /* @__PURE__ */ new Set()) {
|
|
|
1108
1090
|
if (resolved == null) return null;
|
|
1109
1091
|
return resolveToFunction(context, resolved, seen);
|
|
1110
1092
|
}
|
|
1111
|
-
|
|
1112
1093
|
//#endregion
|
|
1113
1094
|
//#region src/rules/globals/collect.ts
|
|
1114
1095
|
function createFactCollector$6() {
|
|
@@ -1175,7 +1156,6 @@ function createFactCollector$6() {
|
|
|
1175
1156
|
}
|
|
1176
1157
|
};
|
|
1177
1158
|
}
|
|
1178
|
-
|
|
1179
1159
|
//#endregion
|
|
1180
1160
|
//#region src/rules/globals/origins.ts
|
|
1181
1161
|
function isGlobalVariable(context, node) {
|
|
@@ -1199,7 +1179,6 @@ function resolveGlobalOrigin(context, node, seen = /* @__PURE__ */ new Set()) {
|
|
|
1199
1179
|
if (initializer.type !== AST_NODE_TYPES.Identifier && initializer.type !== AST_NODE_TYPES.MemberExpression) return null;
|
|
1200
1180
|
return resolveGlobalOrigin(context, initializer, seen);
|
|
1201
1181
|
}
|
|
1202
|
-
|
|
1203
1182
|
//#endregion
|
|
1204
1183
|
//#region src/rules/globals/effects.ts
|
|
1205
1184
|
function inferGlobalMutations(context, facts) {
|
|
@@ -1268,10 +1247,6 @@ function collectReachableEffects(renderFunctions, directEffects, callGraph) {
|
|
|
1268
1247
|
for (const func of renderFunctions) applyFunctionEffects(func);
|
|
1269
1248
|
return reachable;
|
|
1270
1249
|
}
|
|
1271
|
-
|
|
1272
|
-
//#endregion
|
|
1273
|
-
//#region src/rules/globals/globals.ts
|
|
1274
|
-
const RULE_NAME$49 = "globals";
|
|
1275
1250
|
var globals_default = createRule({
|
|
1276
1251
|
meta: {
|
|
1277
1252
|
type: "problem",
|
|
@@ -1283,9 +1258,8 @@ var globals_default = createRule({
|
|
|
1283
1258
|
},
|
|
1284
1259
|
schema: []
|
|
1285
1260
|
},
|
|
1286
|
-
name:
|
|
1287
|
-
create: create$49
|
|
1288
|
-
defaultOptions: []
|
|
1261
|
+
name: "globals",
|
|
1262
|
+
create: create$49
|
|
1289
1263
|
});
|
|
1290
1264
|
function create$49(context) {
|
|
1291
1265
|
const hooks = core.getHookCollector(context);
|
|
@@ -1308,7 +1282,6 @@ function create$49(context) {
|
|
|
1308
1282
|
}
|
|
1309
1283
|
} });
|
|
1310
1284
|
}
|
|
1311
|
-
|
|
1312
1285
|
//#endregion
|
|
1313
1286
|
//#region src/rules/immutability/helpers.ts
|
|
1314
1287
|
const KNOWN_MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -1404,7 +1377,6 @@ function isKnownNonMutatingMethodCall(context, node) {
|
|
|
1404
1377
|
function isRefLikeChain(context, node) {
|
|
1405
1378
|
return hasRefLikeNameInChain(node) || isInitializedFromUseRef(context, node);
|
|
1406
1379
|
}
|
|
1407
|
-
|
|
1408
1380
|
//#endregion
|
|
1409
1381
|
//#region src/rules/immutability/collect.ts
|
|
1410
1382
|
function createFactCollector$5() {
|
|
@@ -1493,7 +1465,6 @@ function createFactCollector$5() {
|
|
|
1493
1465
|
}
|
|
1494
1466
|
};
|
|
1495
1467
|
}
|
|
1496
|
-
|
|
1497
1468
|
//#endregion
|
|
1498
1469
|
//#region src/rules/immutability/origins.ts
|
|
1499
1470
|
function classifyFrozenOrigin(context, variable, components, seen = /* @__PURE__ */ new Set()) {
|
|
@@ -1556,7 +1527,6 @@ function classifyFrozenOrigin(context, variable, components, seen = /* @__PURE__
|
|
|
1556
1527
|
default: return null;
|
|
1557
1528
|
}
|
|
1558
1529
|
}
|
|
1559
|
-
|
|
1560
1530
|
//#endregion
|
|
1561
1531
|
//#region src/rules/immutability/effects.ts
|
|
1562
1532
|
function isGlobalOrModuleVariable(variable) {
|
|
@@ -1651,10 +1621,6 @@ function inferDirectMutations(context, mutations, components) {
|
|
|
1651
1621
|
}
|
|
1652
1622
|
return directMutations;
|
|
1653
1623
|
}
|
|
1654
|
-
|
|
1655
|
-
//#endregion
|
|
1656
|
-
//#region src/rules/immutability/immutability.ts
|
|
1657
|
-
const RULE_NAME$48 = "immutability";
|
|
1658
1624
|
var immutability_default = createRule({
|
|
1659
1625
|
meta: {
|
|
1660
1626
|
type: "problem",
|
|
@@ -1666,9 +1632,8 @@ var immutability_default = createRule({
|
|
|
1666
1632
|
},
|
|
1667
1633
|
schema: []
|
|
1668
1634
|
},
|
|
1669
|
-
name:
|
|
1670
|
-
create: create$48
|
|
1671
|
-
defaultOptions: []
|
|
1635
|
+
name: "immutability",
|
|
1636
|
+
create: create$48
|
|
1672
1637
|
});
|
|
1673
1638
|
function create$48(context) {
|
|
1674
1639
|
const hooks = core.getHookCollector(context);
|
|
@@ -1719,10 +1684,6 @@ function create$48(context) {
|
|
|
1719
1684
|
}
|
|
1720
1685
|
} });
|
|
1721
1686
|
}
|
|
1722
|
-
|
|
1723
|
-
//#endregion
|
|
1724
|
-
//#region src/rules/no-access-state-in-setstate/no-access-state-in-setstate.ts
|
|
1725
|
-
const RULE_NAME$47 = "no-access-state-in-setstate";
|
|
1726
1687
|
var no_access_state_in_setstate_default = createRule({
|
|
1727
1688
|
meta: {
|
|
1728
1689
|
type: "problem",
|
|
@@ -1730,9 +1691,8 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
1730
1691
|
messages: { default: "Do not access 'this.state' within 'setState'. Use the update function instead." },
|
|
1731
1692
|
schema: []
|
|
1732
1693
|
},
|
|
1733
|
-
name:
|
|
1734
|
-
create: create$47
|
|
1735
|
-
defaultOptions: []
|
|
1694
|
+
name: "no-access-state-in-setstate",
|
|
1695
|
+
create: create$47
|
|
1736
1696
|
});
|
|
1737
1697
|
function create$47(context) {
|
|
1738
1698
|
if (!context.sourceCode.text.includes("setState")) return {};
|
|
@@ -1746,7 +1706,6 @@ function create$47(context) {
|
|
|
1746
1706
|
});
|
|
1747
1707
|
} };
|
|
1748
1708
|
}
|
|
1749
|
-
|
|
1750
1709
|
//#endregion
|
|
1751
1710
|
//#region src/rules/no-array-index-key/lib.ts
|
|
1752
1711
|
const INDEX_PARAM_POSITIONS$1 = /* @__PURE__ */ new Map([
|
|
@@ -1788,7 +1747,6 @@ function getIdentifiersFromBinaryExpression(side) {
|
|
|
1788
1747
|
if (side.type === AST_NODE_TYPES.BinaryExpression) return [...getIdentifiersFromBinaryExpression(side.left), ...getIdentifiersFromBinaryExpression(side.right)];
|
|
1789
1748
|
return [];
|
|
1790
1749
|
}
|
|
1791
|
-
|
|
1792
1750
|
//#endregion
|
|
1793
1751
|
//#region src/rules/no-array-index-key/no-array-index-key.ts
|
|
1794
1752
|
const RULE_NAME$46 = "no-array-index-key";
|
|
@@ -1801,8 +1759,7 @@ var no_array_index_key_default = createRule({
|
|
|
1801
1759
|
schema: []
|
|
1802
1760
|
},
|
|
1803
1761
|
name: RULE_NAME$46,
|
|
1804
|
-
create: create$46
|
|
1805
|
-
defaultOptions: []
|
|
1762
|
+
create: create$46
|
|
1806
1763
|
});
|
|
1807
1764
|
function create$46(context) {
|
|
1808
1765
|
function isArrayIndex(node) {
|
|
@@ -1864,10 +1821,6 @@ function create$46(context) {
|
|
|
1864
1821
|
}
|
|
1865
1822
|
};
|
|
1866
1823
|
}
|
|
1867
|
-
|
|
1868
|
-
//#endregion
|
|
1869
|
-
//#region src/rules/no-children-count/no-children-count.ts
|
|
1870
|
-
const RULE_NAME$45 = "no-children-count";
|
|
1871
1824
|
var no_children_count_default = createRule({
|
|
1872
1825
|
meta: {
|
|
1873
1826
|
type: "suggestion",
|
|
@@ -1875,9 +1828,8 @@ var no_children_count_default = createRule({
|
|
|
1875
1828
|
messages: { default: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1876
1829
|
schema: []
|
|
1877
1830
|
},
|
|
1878
|
-
name:
|
|
1879
|
-
create: create$45
|
|
1880
|
-
defaultOptions: []
|
|
1831
|
+
name: "no-children-count",
|
|
1832
|
+
create: create$45
|
|
1881
1833
|
});
|
|
1882
1834
|
function create$45(context) {
|
|
1883
1835
|
return { MemberExpression(node) {
|
|
@@ -1887,10 +1839,6 @@ function create$45(context) {
|
|
|
1887
1839
|
});
|
|
1888
1840
|
} };
|
|
1889
1841
|
}
|
|
1890
|
-
|
|
1891
|
-
//#endregion
|
|
1892
|
-
//#region src/rules/no-children-for-each/no-children-for-each.ts
|
|
1893
|
-
const RULE_NAME$44 = "no-children-for-each";
|
|
1894
1842
|
var no_children_for_each_default = createRule({
|
|
1895
1843
|
meta: {
|
|
1896
1844
|
type: "suggestion",
|
|
@@ -1898,9 +1846,8 @@ var no_children_for_each_default = createRule({
|
|
|
1898
1846
|
messages: { default: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1899
1847
|
schema: []
|
|
1900
1848
|
},
|
|
1901
|
-
name:
|
|
1902
|
-
create: create$44
|
|
1903
|
-
defaultOptions: []
|
|
1849
|
+
name: "no-children-for-each",
|
|
1850
|
+
create: create$44
|
|
1904
1851
|
});
|
|
1905
1852
|
function create$44(context) {
|
|
1906
1853
|
return { MemberExpression(node) {
|
|
@@ -1910,10 +1857,6 @@ function create$44(context) {
|
|
|
1910
1857
|
});
|
|
1911
1858
|
} };
|
|
1912
1859
|
}
|
|
1913
|
-
|
|
1914
|
-
//#endregion
|
|
1915
|
-
//#region src/rules/no-children-map/no-children-map.ts
|
|
1916
|
-
const RULE_NAME$43 = "no-children-map";
|
|
1917
1860
|
var no_children_map_default = createRule({
|
|
1918
1861
|
meta: {
|
|
1919
1862
|
type: "suggestion",
|
|
@@ -1921,9 +1864,8 @@ var no_children_map_default = createRule({
|
|
|
1921
1864
|
messages: { default: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1922
1865
|
schema: []
|
|
1923
1866
|
},
|
|
1924
|
-
name:
|
|
1925
|
-
create: create$43
|
|
1926
|
-
defaultOptions: []
|
|
1867
|
+
name: "no-children-map",
|
|
1868
|
+
create: create$43
|
|
1927
1869
|
});
|
|
1928
1870
|
function create$43(context) {
|
|
1929
1871
|
return { MemberExpression(node) {
|
|
@@ -1933,10 +1875,6 @@ function create$43(context) {
|
|
|
1933
1875
|
});
|
|
1934
1876
|
} };
|
|
1935
1877
|
}
|
|
1936
|
-
|
|
1937
|
-
//#endregion
|
|
1938
|
-
//#region src/rules/no-children-only/no-children-only.ts
|
|
1939
|
-
const RULE_NAME$42 = "no-children-only";
|
|
1940
1878
|
var no_children_only_default = createRule({
|
|
1941
1879
|
meta: {
|
|
1942
1880
|
type: "suggestion",
|
|
@@ -1944,9 +1882,8 @@ var no_children_only_default = createRule({
|
|
|
1944
1882
|
messages: { default: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1945
1883
|
schema: []
|
|
1946
1884
|
},
|
|
1947
|
-
name:
|
|
1948
|
-
create: create$42
|
|
1949
|
-
defaultOptions: []
|
|
1885
|
+
name: "no-children-only",
|
|
1886
|
+
create: create$42
|
|
1950
1887
|
});
|
|
1951
1888
|
function create$42(context) {
|
|
1952
1889
|
return { MemberExpression(node) {
|
|
@@ -1956,10 +1893,6 @@ function create$42(context) {
|
|
|
1956
1893
|
});
|
|
1957
1894
|
} };
|
|
1958
1895
|
}
|
|
1959
|
-
|
|
1960
|
-
//#endregion
|
|
1961
|
-
//#region src/rules/no-children-to-array/no-children-to-array.ts
|
|
1962
|
-
const RULE_NAME$41 = "no-children-to-array";
|
|
1963
1896
|
var no_children_to_array_default = createRule({
|
|
1964
1897
|
meta: {
|
|
1965
1898
|
type: "suggestion",
|
|
@@ -1967,9 +1900,8 @@ var no_children_to_array_default = createRule({
|
|
|
1967
1900
|
messages: { default: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1968
1901
|
schema: []
|
|
1969
1902
|
},
|
|
1970
|
-
name:
|
|
1971
|
-
create: create$41
|
|
1972
|
-
defaultOptions: []
|
|
1903
|
+
name: "no-children-to-array",
|
|
1904
|
+
create: create$41
|
|
1973
1905
|
});
|
|
1974
1906
|
function create$41(context) {
|
|
1975
1907
|
return { MemberExpression(node) {
|
|
@@ -1979,7 +1911,6 @@ function create$41(context) {
|
|
|
1979
1911
|
});
|
|
1980
1912
|
} };
|
|
1981
1913
|
}
|
|
1982
|
-
|
|
1983
1914
|
//#endregion
|
|
1984
1915
|
//#region ../../.pkgs/eff/dist/index.js
|
|
1985
1916
|
const pipeArguments = (self, args) => {
|
|
@@ -2004,7 +1935,7 @@ const pipeArguments = (self, args) => {
|
|
|
2004
1935
|
const Prototype = { pipe() {
|
|
2005
1936
|
return pipeArguments(this, arguments);
|
|
2006
1937
|
} };
|
|
2007
|
-
|
|
1938
|
+
(function() {
|
|
2008
1939
|
function PipeableBase() {}
|
|
2009
1940
|
PipeableBase.prototype = Prototype;
|
|
2010
1941
|
return PipeableBase;
|
|
@@ -2039,12 +1970,7 @@ const dual = function(arity, body) {
|
|
|
2039
1970
|
};
|
|
2040
1971
|
const identity = (a) => a;
|
|
2041
1972
|
const cast = identity;
|
|
2042
|
-
|
|
2043
|
-
const constTrue = constant(true);
|
|
2044
|
-
const constFalse = constant(false);
|
|
2045
|
-
const constNull = constant(null);
|
|
2046
|
-
const constUndefined = constant(void 0);
|
|
2047
|
-
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
1973
|
+
dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
2048
1974
|
const absurd = (_) => {
|
|
2049
1975
|
throw new Error("Called `absurd` function which should be uncallable");
|
|
2050
1976
|
};
|
|
@@ -2077,17 +2003,17 @@ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
|
|
|
2077
2003
|
};
|
|
2078
2004
|
}
|
|
2079
2005
|
}
|
|
2080
|
-
|
|
2006
|
+
cast(absurd);
|
|
2081
2007
|
function not(predicate) {
|
|
2082
2008
|
return (data) => !predicate(data);
|
|
2083
2009
|
}
|
|
2084
|
-
|
|
2010
|
+
dual(2, (a, b) => (data) => a(data) && b(data));
|
|
2085
2011
|
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2012
|
+
dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
2013
|
+
dual(2, (a, b) => (data) => a(data) === b(data));
|
|
2014
|
+
dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
2015
|
+
dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
2016
|
+
dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
2091
2017
|
function isString(input) {
|
|
2092
2018
|
return typeof input === "string";
|
|
2093
2019
|
}
|
|
@@ -2104,24 +2030,20 @@ function getOrInsertComputed(map, key, callback) {
|
|
|
2104
2030
|
map.set(key, value);
|
|
2105
2031
|
return value;
|
|
2106
2032
|
}
|
|
2107
|
-
|
|
2033
|
+
dual(2, (self, predicate) => {
|
|
2108
2034
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
2109
2035
|
const len = input.length;
|
|
2110
2036
|
let idx = 0;
|
|
2111
2037
|
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
2112
2038
|
return input.slice(idx);
|
|
2113
2039
|
});
|
|
2114
|
-
|
|
2040
|
+
dual(2, (self, predicate) => {
|
|
2115
2041
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
2116
2042
|
const len = input.length;
|
|
2117
2043
|
let idx = 0;
|
|
2118
2044
|
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
2119
2045
|
return input.slice(0, idx);
|
|
2120
2046
|
});
|
|
2121
|
-
|
|
2122
|
-
//#endregion
|
|
2123
|
-
//#region src/rules/no-class-component/no-class-component.ts
|
|
2124
|
-
const RULE_NAME$40 = "no-class-component";
|
|
2125
2047
|
var no_class_component_default = createRule({
|
|
2126
2048
|
meta: {
|
|
2127
2049
|
type: "suggestion",
|
|
@@ -2129,19 +2051,17 @@ var no_class_component_default = createRule({
|
|
|
2129
2051
|
messages: { default: "Avoid using class components. Use function components instead." },
|
|
2130
2052
|
schema: []
|
|
2131
2053
|
},
|
|
2132
|
-
name:
|
|
2133
|
-
create: create$40
|
|
2134
|
-
defaultOptions: []
|
|
2054
|
+
name: "no-class-component",
|
|
2055
|
+
create: create$40
|
|
2135
2056
|
});
|
|
2136
2057
|
function create$40(context) {
|
|
2137
2058
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
2138
2059
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
2139
2060
|
return merge(visitor, { "Program:exit"(program) {
|
|
2140
|
-
for (const { id,
|
|
2061
|
+
for (const { id, node: component } of api.getAllComponents(program)) {
|
|
2141
2062
|
if (component.body.body.some(or(core.isComponentDidCatch, core.isGetDerivedStateFromError))) continue;
|
|
2142
2063
|
const classToken = context.sourceCode.getFirstToken(component, { filter: (token) => token.value === "class" });
|
|
2143
2064
|
context.report({
|
|
2144
|
-
data: { name },
|
|
2145
2065
|
loc: (id ?? classToken ?? component).loc,
|
|
2146
2066
|
messageId: "default",
|
|
2147
2067
|
node: component
|
|
@@ -2149,10 +2069,6 @@ function create$40(context) {
|
|
|
2149
2069
|
}
|
|
2150
2070
|
} });
|
|
2151
2071
|
}
|
|
2152
|
-
|
|
2153
|
-
//#endregion
|
|
2154
|
-
//#region src/rules/no-clone-element/no-clone-element.ts
|
|
2155
|
-
const RULE_NAME$39 = "no-clone-element";
|
|
2156
2072
|
var no_clone_element_default = createRule({
|
|
2157
2073
|
meta: {
|
|
2158
2074
|
type: "suggestion",
|
|
@@ -2160,9 +2076,8 @@ var no_clone_element_default = createRule({
|
|
|
2160
2076
|
messages: { default: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
2161
2077
|
schema: []
|
|
2162
2078
|
},
|
|
2163
|
-
name:
|
|
2164
|
-
create: create$39
|
|
2165
|
-
defaultOptions: []
|
|
2079
|
+
name: "no-clone-element",
|
|
2080
|
+
create: create$39
|
|
2166
2081
|
});
|
|
2167
2082
|
function create$39(context) {
|
|
2168
2083
|
return { CallExpression(node) {
|
|
@@ -2172,10 +2087,6 @@ function create$39(context) {
|
|
|
2172
2087
|
});
|
|
2173
2088
|
} };
|
|
2174
2089
|
}
|
|
2175
|
-
|
|
2176
|
-
//#endregion
|
|
2177
|
-
//#region src/rules/no-component-will-mount/no-component-will-mount.ts
|
|
2178
|
-
const RULE_NAME$38 = "no-component-will-mount";
|
|
2179
2090
|
var no_component_will_mount_default = createRule({
|
|
2180
2091
|
meta: {
|
|
2181
2092
|
type: "problem",
|
|
@@ -2184,9 +2095,8 @@ var no_component_will_mount_default = createRule({
|
|
|
2184
2095
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
|
|
2185
2096
|
schema: []
|
|
2186
2097
|
},
|
|
2187
|
-
name:
|
|
2188
|
-
create: create$38
|
|
2189
|
-
defaultOptions: []
|
|
2098
|
+
name: "no-component-will-mount",
|
|
2099
|
+
create: create$38
|
|
2190
2100
|
});
|
|
2191
2101
|
function create$38(context) {
|
|
2192
2102
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
@@ -2205,10 +2115,6 @@ function create$38(context) {
|
|
|
2205
2115
|
}
|
|
2206
2116
|
} });
|
|
2207
2117
|
}
|
|
2208
|
-
|
|
2209
|
-
//#endregion
|
|
2210
|
-
//#region src/rules/no-component-will-receive-props/no-component-will-receive-props.ts
|
|
2211
|
-
const RULE_NAME$37 = "no-component-will-receive-props";
|
|
2212
2118
|
var no_component_will_receive_props_default = createRule({
|
|
2213
2119
|
meta: {
|
|
2214
2120
|
type: "problem",
|
|
@@ -2217,9 +2123,8 @@ var no_component_will_receive_props_default = createRule({
|
|
|
2217
2123
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
|
|
2218
2124
|
schema: []
|
|
2219
2125
|
},
|
|
2220
|
-
name:
|
|
2221
|
-
create: create$37
|
|
2222
|
-
defaultOptions: []
|
|
2126
|
+
name: "no-component-will-receive-props",
|
|
2127
|
+
create: create$37
|
|
2223
2128
|
});
|
|
2224
2129
|
function create$37(context) {
|
|
2225
2130
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
@@ -2238,10 +2143,6 @@ function create$37(context) {
|
|
|
2238
2143
|
}
|
|
2239
2144
|
} });
|
|
2240
2145
|
}
|
|
2241
|
-
|
|
2242
|
-
//#endregion
|
|
2243
|
-
//#region src/rules/no-component-will-update/no-component-will-update.ts
|
|
2244
|
-
const RULE_NAME$36 = "no-component-will-update";
|
|
2245
2146
|
var no_component_will_update_default = createRule({
|
|
2246
2147
|
meta: {
|
|
2247
2148
|
type: "problem",
|
|
@@ -2250,9 +2151,8 @@ var no_component_will_update_default = createRule({
|
|
|
2250
2151
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
|
|
2251
2152
|
schema: []
|
|
2252
2153
|
},
|
|
2253
|
-
name:
|
|
2254
|
-
create: create$36
|
|
2255
|
-
defaultOptions: []
|
|
2154
|
+
name: "no-component-will-update",
|
|
2155
|
+
create: create$36
|
|
2256
2156
|
});
|
|
2257
2157
|
function create$36(context) {
|
|
2258
2158
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
@@ -2271,10 +2171,6 @@ function create$36(context) {
|
|
|
2271
2171
|
}
|
|
2272
2172
|
} });
|
|
2273
2173
|
}
|
|
2274
|
-
|
|
2275
|
-
//#endregion
|
|
2276
|
-
//#region src/rules/no-context-provider/no-context-provider.ts
|
|
2277
|
-
const RULE_NAME$35 = "no-context-provider";
|
|
2278
2174
|
var no_context_provider_default = createRule({
|
|
2279
2175
|
meta: {
|
|
2280
2176
|
type: "suggestion",
|
|
@@ -2287,9 +2183,8 @@ var no_context_provider_default = createRule({
|
|
|
2287
2183
|
},
|
|
2288
2184
|
schema: []
|
|
2289
2185
|
},
|
|
2290
|
-
name:
|
|
2291
|
-
create: create$35
|
|
2292
|
-
defaultOptions: []
|
|
2186
|
+
name: "no-context-provider",
|
|
2187
|
+
create: create$35
|
|
2293
2188
|
});
|
|
2294
2189
|
function create$35(context) {
|
|
2295
2190
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
@@ -2318,10 +2213,6 @@ function create$35(context) {
|
|
|
2318
2213
|
});
|
|
2319
2214
|
} };
|
|
2320
2215
|
}
|
|
2321
|
-
|
|
2322
|
-
//#endregion
|
|
2323
|
-
//#region src/rules/no-create-ref/no-create-ref.ts
|
|
2324
|
-
const RULE_NAME$34 = "no-create-ref";
|
|
2325
2216
|
var no_create_ref_default = createRule({
|
|
2326
2217
|
meta: {
|
|
2327
2218
|
type: "suggestion",
|
|
@@ -2329,25 +2220,24 @@ var no_create_ref_default = createRule({
|
|
|
2329
2220
|
messages: { default: "[Deprecated] Use 'useRef' instead." },
|
|
2330
2221
|
schema: []
|
|
2331
2222
|
},
|
|
2332
|
-
name:
|
|
2333
|
-
create: create$34
|
|
2334
|
-
defaultOptions: []
|
|
2223
|
+
name: "no-create-ref",
|
|
2224
|
+
create: create$34
|
|
2335
2225
|
});
|
|
2336
2226
|
function create$34(context) {
|
|
2337
2227
|
if (!context.sourceCode.text.includes("createRef")) return {};
|
|
2338
2228
|
const fc = core.getFunctionComponentCollector(context);
|
|
2339
2229
|
const hc = core.getHookCollector(context);
|
|
2340
|
-
const
|
|
2230
|
+
const facts = /* @__PURE__ */ new Set();
|
|
2341
2231
|
return merge(fc.visitor, hc.visitor, {
|
|
2342
2232
|
CallExpression(node) {
|
|
2343
2233
|
if (!core.isCreateRefCall(context, node)) return;
|
|
2344
|
-
|
|
2234
|
+
facts.add(node);
|
|
2345
2235
|
},
|
|
2346
2236
|
"Program:exit"(node) {
|
|
2347
2237
|
const comps = fc.api.getAllComponents(node);
|
|
2348
2238
|
const hooks = hc.api.getAllHooks(node);
|
|
2349
2239
|
const funcs = [...comps, ...hooks];
|
|
2350
|
-
for (const call of
|
|
2240
|
+
for (const call of facts) {
|
|
2351
2241
|
if (Traverse.findParent(call, (n) => funcs.some((f) => f.node === n)) == null) continue;
|
|
2352
2242
|
context.report({
|
|
2353
2243
|
messageId: "default",
|
|
@@ -2357,10 +2247,6 @@ function create$34(context) {
|
|
|
2357
2247
|
}
|
|
2358
2248
|
});
|
|
2359
2249
|
}
|
|
2360
|
-
|
|
2361
|
-
//#endregion
|
|
2362
|
-
//#region src/rules/no-direct-mutation-state/no-direct-mutation-state.ts
|
|
2363
|
-
const RULE_NAME$33 = "no-direct-mutation-state";
|
|
2364
2250
|
var no_direct_mutation_state_default = createRule({
|
|
2365
2251
|
meta: {
|
|
2366
2252
|
type: "problem",
|
|
@@ -2368,9 +2254,8 @@ var no_direct_mutation_state_default = createRule({
|
|
|
2368
2254
|
messages: { default: "Do not mutate state directly. Use 'setState()' instead." },
|
|
2369
2255
|
schema: []
|
|
2370
2256
|
},
|
|
2371
|
-
name:
|
|
2372
|
-
create: create$33
|
|
2373
|
-
defaultOptions: []
|
|
2257
|
+
name: "no-direct-mutation-state",
|
|
2258
|
+
create: create$33
|
|
2374
2259
|
});
|
|
2375
2260
|
function isConstructorFunction(node) {
|
|
2376
2261
|
return Check.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && Check.isPropertyOrMethod(node.parent) && Check.isIdentifier(node.parent.key, "constructor");
|
|
@@ -2397,10 +2282,6 @@ function create$33(context) {
|
|
|
2397
2282
|
});
|
|
2398
2283
|
} };
|
|
2399
2284
|
}
|
|
2400
|
-
|
|
2401
|
-
//#endregion
|
|
2402
|
-
//#region src/rules/no-duplicate-key/no-duplicate-key.ts
|
|
2403
|
-
const RULE_NAME$32 = "no-duplicate-key";
|
|
2404
2285
|
var no_duplicate_key_default = createRule({
|
|
2405
2286
|
meta: {
|
|
2406
2287
|
type: "problem",
|
|
@@ -2408,9 +2289,8 @@ var no_duplicate_key_default = createRule({
|
|
|
2408
2289
|
messages: { default: "The 'key' prop must be unique to its sibling elements." },
|
|
2409
2290
|
schema: []
|
|
2410
2291
|
},
|
|
2411
|
-
name:
|
|
2412
|
-
create: create$32
|
|
2413
|
-
defaultOptions: []
|
|
2292
|
+
name: "no-duplicate-key",
|
|
2293
|
+
create: create$32
|
|
2414
2294
|
});
|
|
2415
2295
|
function create$32(context) {
|
|
2416
2296
|
if (!context.sourceCode.text.includes("key=")) return {};
|
|
@@ -2461,7 +2341,6 @@ function create$32(context) {
|
|
|
2461
2341
|
for (const { hasDuplicate, keys } of keyedEntries.values()) {
|
|
2462
2342
|
if (!hasDuplicate) continue;
|
|
2463
2343
|
for (const key of keys) context.report({
|
|
2464
|
-
data: { value: context.sourceCode.getText(key) },
|
|
2465
2344
|
messageId: "default",
|
|
2466
2345
|
node: key
|
|
2467
2346
|
});
|
|
@@ -2469,10 +2348,6 @@ function create$32(context) {
|
|
|
2469
2348
|
}
|
|
2470
2349
|
};
|
|
2471
2350
|
}
|
|
2472
|
-
|
|
2473
|
-
//#endregion
|
|
2474
|
-
//#region src/rules/no-forward-ref/no-forward-ref.ts
|
|
2475
|
-
const RULE_NAME$31 = "no-forward-ref";
|
|
2476
2351
|
var no_forward_ref_default = createRule({
|
|
2477
2352
|
meta: {
|
|
2478
2353
|
type: "suggestion",
|
|
@@ -2485,9 +2360,8 @@ var no_forward_ref_default = createRule({
|
|
|
2485
2360
|
},
|
|
2486
2361
|
schema: []
|
|
2487
2362
|
},
|
|
2488
|
-
name:
|
|
2489
|
-
create: create$31
|
|
2490
|
-
defaultOptions: []
|
|
2363
|
+
name: "no-forward-ref",
|
|
2364
|
+
create: create$31
|
|
2491
2365
|
});
|
|
2492
2366
|
function create$31(context) {
|
|
2493
2367
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
@@ -2570,7 +2444,6 @@ function buildFixForComponentProps(context, fixer, node, typeArguments) {
|
|
|
2570
2444
|
"}"
|
|
2571
2445
|
].join(" ")), ...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]];
|
|
2572
2446
|
}
|
|
2573
|
-
|
|
2574
2447
|
//#endregion
|
|
2575
2448
|
//#region src/utils/create-implicit-prop-listener.ts
|
|
2576
2449
|
function createImplicitPropListener(context, options) {
|
|
@@ -2590,7 +2463,6 @@ function createImplicitPropListener(context, options) {
|
|
|
2590
2463
|
}
|
|
2591
2464
|
} };
|
|
2592
2465
|
}
|
|
2593
|
-
|
|
2594
2466
|
//#endregion
|
|
2595
2467
|
//#region src/rules/no-implicit-children/no-implicit-children.ts
|
|
2596
2468
|
const RULE_NAME$30 = "no-implicit-children";
|
|
@@ -2603,8 +2475,7 @@ var no_implicit_children_default = createRule({
|
|
|
2603
2475
|
schema: []
|
|
2604
2476
|
},
|
|
2605
2477
|
name: RULE_NAME$30,
|
|
2606
|
-
create: create$30
|
|
2607
|
-
defaultOptions: []
|
|
2478
|
+
create: create$30
|
|
2608
2479
|
});
|
|
2609
2480
|
function create$30(context) {
|
|
2610
2481
|
return createImplicitPropListener(context, {
|
|
@@ -2619,10 +2490,6 @@ function create$30(context) {
|
|
|
2619
2490
|
}
|
|
2620
2491
|
});
|
|
2621
2492
|
}
|
|
2622
|
-
|
|
2623
|
-
//#endregion
|
|
2624
|
-
//#region src/rules/no-implicit-key/no-implicit-key.ts
|
|
2625
|
-
const RULE_NAME$29 = "no-implicit-key";
|
|
2626
2493
|
var no_implicit_key_default = createRule({
|
|
2627
2494
|
meta: {
|
|
2628
2495
|
type: "problem",
|
|
@@ -2630,9 +2497,8 @@ var no_implicit_key_default = createRule({
|
|
|
2630
2497
|
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}'." },
|
|
2631
2498
|
schema: []
|
|
2632
2499
|
},
|
|
2633
|
-
name:
|
|
2634
|
-
create: create$29
|
|
2635
|
-
defaultOptions: []
|
|
2500
|
+
name: "no-implicit-key",
|
|
2501
|
+
create: create$29
|
|
2636
2502
|
});
|
|
2637
2503
|
function create$29(context) {
|
|
2638
2504
|
return createImplicitPropListener(context, {
|
|
@@ -2647,7 +2513,6 @@ function create$29(context) {
|
|
|
2647
2513
|
}
|
|
2648
2514
|
});
|
|
2649
2515
|
}
|
|
2650
|
-
|
|
2651
2516
|
//#endregion
|
|
2652
2517
|
//#region src/rules/no-implicit-ref/no-implicit-ref.ts
|
|
2653
2518
|
const RULE_NAME$28 = "no-implicit-ref";
|
|
@@ -2660,8 +2525,7 @@ var no_implicit_ref_default = createRule({
|
|
|
2660
2525
|
schema: []
|
|
2661
2526
|
},
|
|
2662
2527
|
name: RULE_NAME$28,
|
|
2663
|
-
create: create$28
|
|
2664
|
-
defaultOptions: []
|
|
2528
|
+
create: create$28
|
|
2665
2529
|
});
|
|
2666
2530
|
function create$28(context) {
|
|
2667
2531
|
return createImplicitPropListener(context, {
|
|
@@ -2676,10 +2540,6 @@ function create$28(context) {
|
|
|
2676
2540
|
}
|
|
2677
2541
|
});
|
|
2678
2542
|
}
|
|
2679
|
-
|
|
2680
|
-
//#endregion
|
|
2681
|
-
//#region src/rules/no-leaked-conditional-rendering/no-leaked-conditional-rendering.ts
|
|
2682
|
-
const RULE_NAME$27 = "no-leaked-conditional-rendering";
|
|
2683
2543
|
var no_leaked_conditional_rendering_default = createRule({
|
|
2684
2544
|
meta: {
|
|
2685
2545
|
type: "problem",
|
|
@@ -2687,9 +2547,8 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
2687
2547
|
messages: { default: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
|
|
2688
2548
|
schema: []
|
|
2689
2549
|
},
|
|
2690
|
-
name:
|
|
2691
|
-
create: create$27
|
|
2692
|
-
defaultOptions: []
|
|
2550
|
+
name: "no-leaked-conditional-rendering",
|
|
2551
|
+
create: create$27
|
|
2693
2552
|
});
|
|
2694
2553
|
function create$27(context) {
|
|
2695
2554
|
if (!context.sourceCode.text.includes("&&")) return {};
|
|
@@ -2743,10 +2602,6 @@ function create$27(context) {
|
|
|
2743
2602
|
}
|
|
2744
2603
|
return { JSXExpressionContainer: flow(visit, report(context)) };
|
|
2745
2604
|
}
|
|
2746
|
-
|
|
2747
|
-
//#endregion
|
|
2748
|
-
//#region src/rules/no-missing-component-display-name/no-missing-component-display-name.ts
|
|
2749
|
-
const RULE_NAME$26 = "no-missing-component-display-name";
|
|
2750
2605
|
var no_missing_component_display_name_default = createRule({
|
|
2751
2606
|
meta: {
|
|
2752
2607
|
type: "suggestion",
|
|
@@ -2754,9 +2609,8 @@ var no_missing_component_display_name_default = createRule({
|
|
|
2754
2609
|
messages: { default: "Add missing 'displayName' for component." },
|
|
2755
2610
|
schema: []
|
|
2756
2611
|
},
|
|
2757
|
-
name:
|
|
2758
|
-
create: create$26
|
|
2759
|
-
defaultOptions: []
|
|
2612
|
+
name: "no-missing-component-display-name",
|
|
2613
|
+
create: create$26
|
|
2760
2614
|
});
|
|
2761
2615
|
function create$26(context) {
|
|
2762
2616
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
@@ -2777,10 +2631,6 @@ function create$26(context) {
|
|
|
2777
2631
|
}
|
|
2778
2632
|
} });
|
|
2779
2633
|
}
|
|
2780
|
-
|
|
2781
|
-
//#endregion
|
|
2782
|
-
//#region src/rules/no-missing-context-display-name/no-missing-context-display-name.ts
|
|
2783
|
-
const RULE_NAME$25 = "no-missing-context-display-name";
|
|
2784
2634
|
var no_missing_context_display_name_default = createRule({
|
|
2785
2635
|
meta: {
|
|
2786
2636
|
type: "suggestion",
|
|
@@ -2789,9 +2639,8 @@ var no_missing_context_display_name_default = createRule({
|
|
|
2789
2639
|
messages: { default: "Add missing 'displayName' for context." },
|
|
2790
2640
|
schema: []
|
|
2791
2641
|
},
|
|
2792
|
-
name:
|
|
2793
|
-
create: create$25
|
|
2794
|
-
defaultOptions: []
|
|
2642
|
+
name: "no-missing-context-display-name",
|
|
2643
|
+
create: create$25
|
|
2795
2644
|
});
|
|
2796
2645
|
function create$25(context) {
|
|
2797
2646
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
@@ -2842,7 +2691,6 @@ function create$25(context) {
|
|
|
2842
2691
|
}
|
|
2843
2692
|
};
|
|
2844
2693
|
}
|
|
2845
|
-
|
|
2846
2694
|
//#endregion
|
|
2847
2695
|
//#region src/rules/no-missing-key/lib.ts
|
|
2848
2696
|
const INDEX_PARAM_POSITIONS = /* @__PURE__ */ new Map([
|
|
@@ -2860,10 +2708,6 @@ function getNestedReturnStatements$1(node) {
|
|
|
2860
2708
|
} });
|
|
2861
2709
|
return statements;
|
|
2862
2710
|
}
|
|
2863
|
-
|
|
2864
|
-
//#endregion
|
|
2865
|
-
//#region src/rules/no-missing-key/no-missing-key.ts
|
|
2866
|
-
const RULE_NAME$24 = "no-missing-key";
|
|
2867
2711
|
var no_missing_key_default = createRule({
|
|
2868
2712
|
meta: {
|
|
2869
2713
|
type: "problem",
|
|
@@ -2874,9 +2718,8 @@ var no_missing_key_default = createRule({
|
|
|
2874
2718
|
},
|
|
2875
2719
|
schema: []
|
|
2876
2720
|
},
|
|
2877
|
-
name:
|
|
2878
|
-
create: create$24
|
|
2879
|
-
defaultOptions: []
|
|
2721
|
+
name: "no-missing-key",
|
|
2722
|
+
create: create$24
|
|
2880
2723
|
});
|
|
2881
2724
|
function getIteratorCallback(node) {
|
|
2882
2725
|
const callee = Extract.unwrap(node.callee);
|
|
@@ -2938,7 +2781,6 @@ function create$24(context) {
|
|
|
2938
2781
|
}
|
|
2939
2782
|
};
|
|
2940
2783
|
}
|
|
2941
|
-
|
|
2942
2784
|
//#endregion
|
|
2943
2785
|
//#region src/rules/no-misused-capture-owner-stack/lib.ts
|
|
2944
2786
|
function isProcessEnvNodeEnv(context, node) {
|
|
@@ -2960,10 +2802,6 @@ function isDevelopmentOnlyCheck(context, node) {
|
|
|
2960
2802
|
if (node.type !== AST_NODE_TYPES.IfStatement) return false;
|
|
2961
2803
|
return isProcessEnvNodeEnvCompare(context, node.test, "!==", "production");
|
|
2962
2804
|
}
|
|
2963
|
-
|
|
2964
|
-
//#endregion
|
|
2965
|
-
//#region src/rules/no-misused-capture-owner-stack/no-misused-capture-owner-stack.ts
|
|
2966
|
-
const RULE_NAME$23 = "no-misused-capture-owner-stack";
|
|
2967
2805
|
var no_misused_capture_owner_stack_default = createRule({
|
|
2968
2806
|
meta: {
|
|
2969
2807
|
type: "problem",
|
|
@@ -2974,9 +2812,8 @@ var no_misused_capture_owner_stack_default = createRule({
|
|
|
2974
2812
|
},
|
|
2975
2813
|
schema: []
|
|
2976
2814
|
},
|
|
2977
|
-
name:
|
|
2978
|
-
create: create$23
|
|
2979
|
-
defaultOptions: []
|
|
2815
|
+
name: "no-misused-capture-owner-stack",
|
|
2816
|
+
create: create$23
|
|
2980
2817
|
});
|
|
2981
2818
|
function create$23(context) {
|
|
2982
2819
|
if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
|
|
@@ -3002,7 +2839,6 @@ function create$23(context) {
|
|
|
3002
2839
|
}
|
|
3003
2840
|
};
|
|
3004
2841
|
}
|
|
3005
|
-
|
|
3006
2842
|
//#endregion
|
|
3007
2843
|
//#region src/rules/no-nested-component-definitions/lib.ts
|
|
3008
2844
|
const isConnectCall = core.isAPICall("connect");
|
|
@@ -3073,10 +2909,6 @@ function isInsideJSXAttributeValue(node) {
|
|
|
3073
2909
|
function isInsideRenderMethod(node) {
|
|
3074
2910
|
return Traverse.findParent(node, (n) => core.isRenderMethodLike(n) && core.isClassComponent(n.parent.parent)) != null;
|
|
3075
2911
|
}
|
|
3076
|
-
|
|
3077
|
-
//#endregion
|
|
3078
|
-
//#region src/rules/no-nested-component-definitions/no-nested-component-definitions.ts
|
|
3079
|
-
const RULE_NAME$22 = "no-nested-component-definitions";
|
|
3080
2912
|
var no_nested_component_definitions_default = createRule({
|
|
3081
2913
|
meta: {
|
|
3082
2914
|
type: "problem",
|
|
@@ -3084,9 +2916,8 @@ var no_nested_component_definitions_default = createRule({
|
|
|
3084
2916
|
messages: { default: "Do not nest component definitions inside other components or props. {{suggestion}}" },
|
|
3085
2917
|
schema: []
|
|
3086
2918
|
},
|
|
3087
|
-
name:
|
|
3088
|
-
create: create$22
|
|
3089
|
-
defaultOptions: []
|
|
2919
|
+
name: "no-nested-component-definitions",
|
|
2920
|
+
create: create$22
|
|
3090
2921
|
});
|
|
3091
2922
|
function create$22(context) {
|
|
3092
2923
|
const hint = core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.FunctionComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.FunctionComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayPatternElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayExpressionElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback;
|
|
@@ -3109,10 +2940,7 @@ function create$22(context) {
|
|
|
3109
2940
|
if (name == null || !core.isFunctionComponentNameLoose(name)) continue;
|
|
3110
2941
|
if (isInsideJSXAttributeValue(component)) {
|
|
3111
2942
|
context.report({
|
|
3112
|
-
data: {
|
|
3113
|
-
name,
|
|
3114
|
-
suggestion: "Move it to the top level or pass it as a prop."
|
|
3115
|
-
},
|
|
2943
|
+
data: { suggestion: "Move it to the top level or pass it as a prop." },
|
|
3116
2944
|
messageId: "default",
|
|
3117
2945
|
node: component
|
|
3118
2946
|
});
|
|
@@ -3120,10 +2948,7 @@ function create$22(context) {
|
|
|
3120
2948
|
}
|
|
3121
2949
|
if (core.isInsideCreateElementProps(context, component)) {
|
|
3122
2950
|
context.report({
|
|
3123
|
-
data: {
|
|
3124
|
-
name,
|
|
3125
|
-
suggestion: "Move it to the top level or pass it as a prop."
|
|
3126
|
-
},
|
|
2951
|
+
data: { suggestion: "Move it to the top level or pass it as a prop." },
|
|
3127
2952
|
messageId: "default",
|
|
3128
2953
|
node: component
|
|
3129
2954
|
});
|
|
@@ -3131,41 +2956,28 @@ function create$22(context) {
|
|
|
3131
2956
|
}
|
|
3132
2957
|
if (findEnclosingComponent(component) != null) {
|
|
3133
2958
|
context.report({
|
|
3134
|
-
data: {
|
|
3135
|
-
name,
|
|
3136
|
-
suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
3137
|
-
},
|
|
2959
|
+
data: { suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level." },
|
|
3138
2960
|
messageId: "default",
|
|
3139
2961
|
node: component
|
|
3140
2962
|
});
|
|
3141
2963
|
continue;
|
|
3142
2964
|
}
|
|
3143
2965
|
if (isInsideRenderMethod(component)) context.report({
|
|
3144
|
-
data: {
|
|
3145
|
-
name,
|
|
3146
|
-
suggestion: "Move it to the top level."
|
|
3147
|
-
},
|
|
2966
|
+
data: { suggestion: "Move it to the top level." },
|
|
3148
2967
|
messageId: "default",
|
|
3149
2968
|
node: component
|
|
3150
2969
|
});
|
|
3151
2970
|
}
|
|
3152
|
-
for (const {
|
|
2971
|
+
for (const { node: component } of cComponents) {
|
|
3153
2972
|
if (findEnclosingComponent(component) == null) continue;
|
|
3154
2973
|
context.report({
|
|
3155
|
-
data: {
|
|
3156
|
-
name,
|
|
3157
|
-
suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
|
|
3158
|
-
},
|
|
2974
|
+
data: { suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level." },
|
|
3159
2975
|
messageId: "default",
|
|
3160
2976
|
node: component
|
|
3161
2977
|
});
|
|
3162
2978
|
}
|
|
3163
2979
|
} });
|
|
3164
2980
|
}
|
|
3165
|
-
|
|
3166
|
-
//#endregion
|
|
3167
|
-
//#region src/rules/no-nested-lazy-component-declarations/no-nested-lazy-component-declarations.ts
|
|
3168
|
-
const RULE_NAME$21 = "no-nested-lazy-component-declarations";
|
|
3169
2981
|
var no_nested_lazy_component_declarations_default = createRule({
|
|
3170
2982
|
meta: {
|
|
3171
2983
|
type: "problem",
|
|
@@ -3173,9 +2985,8 @@ var no_nested_lazy_component_declarations_default = createRule({
|
|
|
3173
2985
|
messages: { default: "Do not declare lazy components inside other components or hooks. Instead, always declare them at the top level of your module." },
|
|
3174
2986
|
schema: []
|
|
3175
2987
|
},
|
|
3176
|
-
name:
|
|
3177
|
-
create: create$21
|
|
3178
|
-
defaultOptions: []
|
|
2988
|
+
name: "no-nested-lazy-component-declarations",
|
|
2989
|
+
create: create$21
|
|
3179
2990
|
});
|
|
3180
2991
|
function create$21(context) {
|
|
3181
2992
|
const fc = core.getFunctionComponentCollector(context);
|
|
@@ -3184,7 +2995,7 @@ function create$21(context) {
|
|
|
3184
2995
|
const lazyCalls = /* @__PURE__ */ new Set();
|
|
3185
2996
|
return merge(fc.visitor, cc.visitor, hc.visitor, {
|
|
3186
2997
|
ImportExpression(node) {
|
|
3187
|
-
const lazyCall = Traverse.findParent(node,
|
|
2998
|
+
const lazyCall = Traverse.findParent(node, core.isLazyCall(context));
|
|
3188
2999
|
if (lazyCall != null) lazyCalls.add(lazyCall);
|
|
3189
3000
|
},
|
|
3190
3001
|
"Program:exit"(program) {
|
|
@@ -3200,10 +3011,6 @@ function create$21(context) {
|
|
|
3200
3011
|
}
|
|
3201
3012
|
});
|
|
3202
3013
|
}
|
|
3203
|
-
|
|
3204
|
-
//#endregion
|
|
3205
|
-
//#region src/rules/no-set-state-in-component-did-mount/no-set-state-in-component-did-mount.ts
|
|
3206
|
-
const RULE_NAME$20 = "no-set-state-in-component-did-mount";
|
|
3207
3014
|
var no_set_state_in_component_did_mount_default = createRule({
|
|
3208
3015
|
meta: {
|
|
3209
3016
|
type: "problem",
|
|
@@ -3211,9 +3018,8 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
3211
3018
|
messages: { default: "Do not call `this.setState` in `componentDidMount` outside functions such as callbacks." },
|
|
3212
3019
|
schema: []
|
|
3213
3020
|
},
|
|
3214
|
-
name:
|
|
3215
|
-
create: create$20
|
|
3216
|
-
defaultOptions: []
|
|
3021
|
+
name: "no-set-state-in-component-did-mount",
|
|
3022
|
+
create: create$20
|
|
3217
3023
|
});
|
|
3218
3024
|
function create$20(context) {
|
|
3219
3025
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
@@ -3230,10 +3036,6 @@ function create$20(context) {
|
|
|
3230
3036
|
});
|
|
3231
3037
|
} };
|
|
3232
3038
|
}
|
|
3233
|
-
|
|
3234
|
-
//#endregion
|
|
3235
|
-
//#region src/rules/no-set-state-in-component-did-update/no-set-state-in-component-did-update.ts
|
|
3236
|
-
const RULE_NAME$19 = "no-set-state-in-component-did-update";
|
|
3237
3039
|
var no_set_state_in_component_did_update_default = createRule({
|
|
3238
3040
|
meta: {
|
|
3239
3041
|
type: "problem",
|
|
@@ -3241,9 +3043,8 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
3241
3043
|
messages: { default: "Do not call `this.setState` in `componentDidUpdate` outside functions such as callbacks." },
|
|
3242
3044
|
schema: []
|
|
3243
3045
|
},
|
|
3244
|
-
name:
|
|
3245
|
-
create: create$19
|
|
3246
|
-
defaultOptions: []
|
|
3046
|
+
name: "no-set-state-in-component-did-update",
|
|
3047
|
+
create: create$19
|
|
3247
3048
|
});
|
|
3248
3049
|
function create$19(context) {
|
|
3249
3050
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
@@ -3260,10 +3061,6 @@ function create$19(context) {
|
|
|
3260
3061
|
});
|
|
3261
3062
|
} };
|
|
3262
3063
|
}
|
|
3263
|
-
|
|
3264
|
-
//#endregion
|
|
3265
|
-
//#region src/rules/no-set-state-in-component-will-update/no-set-state-in-component-will-update.ts
|
|
3266
|
-
const RULE_NAME$18 = "no-set-state-in-component-will-update";
|
|
3267
3064
|
var no_set_state_in_component_will_update_default = createRule({
|
|
3268
3065
|
meta: {
|
|
3269
3066
|
type: "problem",
|
|
@@ -3271,9 +3068,8 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
3271
3068
|
messages: { default: "Do not call `this.setState` in `componentWillUpdate` outside functions such as callbacks." },
|
|
3272
3069
|
schema: []
|
|
3273
3070
|
},
|
|
3274
|
-
name:
|
|
3275
|
-
create: create$18
|
|
3276
|
-
defaultOptions: []
|
|
3071
|
+
name: "no-set-state-in-component-will-update",
|
|
3072
|
+
create: create$18
|
|
3277
3073
|
});
|
|
3278
3074
|
function create$18(context) {
|
|
3279
3075
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
@@ -3290,7 +3086,6 @@ function create$18(context) {
|
|
|
3290
3086
|
});
|
|
3291
3087
|
} };
|
|
3292
3088
|
}
|
|
3293
|
-
|
|
3294
3089
|
//#endregion
|
|
3295
3090
|
//#region src/rules/no-unnecessary-use-prefix/lib.ts
|
|
3296
3091
|
const WELL_KNOWN_HOOKS = ["use", "useMDXComponents"];
|
|
@@ -3310,10 +3105,6 @@ function isInTestMock(node) {
|
|
|
3310
3105
|
return n.arguments.slice(1).some((arg) => arg.range[0] <= node.range[0] && node.range[1] <= arg.range[1]);
|
|
3311
3106
|
}) != null;
|
|
3312
3107
|
}
|
|
3313
|
-
|
|
3314
|
-
//#endregion
|
|
3315
|
-
//#region src/rules/no-unnecessary-use-prefix/no-unnecessary-use-prefix.ts
|
|
3316
|
-
const RULE_NAME$17 = "no-unnecessary-use-prefix";
|
|
3317
3108
|
var no_unnecessary_use_prefix_default = createRule({
|
|
3318
3109
|
meta: {
|
|
3319
3110
|
type: "problem",
|
|
@@ -3321,9 +3112,8 @@ var no_unnecessary_use_prefix_default = createRule({
|
|
|
3321
3112
|
messages: { default: "If your function doesn't call any Hooks, avoid the 'use' prefix. Instead, write it as a regular function without the 'use' prefix." },
|
|
3322
3113
|
schema: []
|
|
3323
3114
|
},
|
|
3324
|
-
name:
|
|
3325
|
-
create: create$17
|
|
3326
|
-
defaultOptions: []
|
|
3115
|
+
name: "no-unnecessary-use-prefix",
|
|
3116
|
+
create: create$17
|
|
3327
3117
|
});
|
|
3328
3118
|
function create$17(context) {
|
|
3329
3119
|
const { api, visitor } = core.getHookCollector(context);
|
|
@@ -3336,17 +3126,12 @@ function create$17(context) {
|
|
|
3336
3126
|
if (containsUseComments(context, node)) continue;
|
|
3337
3127
|
if (isInTestMock(node)) continue;
|
|
3338
3128
|
context.report({
|
|
3339
|
-
data: { name },
|
|
3340
3129
|
messageId: "default",
|
|
3341
3130
|
node: id ?? node
|
|
3342
3131
|
});
|
|
3343
3132
|
}
|
|
3344
3133
|
} });
|
|
3345
3134
|
}
|
|
3346
|
-
|
|
3347
|
-
//#endregion
|
|
3348
|
-
//#region src/rules/no-unsafe-component-will-mount/no-unsafe-component-will-mount.ts
|
|
3349
|
-
const RULE_NAME$16 = "no-unsafe-component-will-mount";
|
|
3350
3135
|
var no_unsafe_component_will_mount_default = createRule({
|
|
3351
3136
|
meta: {
|
|
3352
3137
|
type: "problem",
|
|
@@ -3354,9 +3139,8 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
3354
3139
|
messages: { default: "Do not use 'UNSAFE_componentWillMount'." },
|
|
3355
3140
|
schema: []
|
|
3356
3141
|
},
|
|
3357
|
-
name:
|
|
3358
|
-
create: create$16
|
|
3359
|
-
defaultOptions: []
|
|
3142
|
+
name: "no-unsafe-component-will-mount",
|
|
3143
|
+
create: create$16
|
|
3360
3144
|
});
|
|
3361
3145
|
function create$16(context) {
|
|
3362
3146
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
@@ -3371,10 +3155,6 @@ function create$16(context) {
|
|
|
3371
3155
|
}
|
|
3372
3156
|
} });
|
|
3373
3157
|
}
|
|
3374
|
-
|
|
3375
|
-
//#endregion
|
|
3376
|
-
//#region src/rules/no-unsafe-component-will-receive-props/no-unsafe-component-will-receive-props.ts
|
|
3377
|
-
const RULE_NAME$15 = "no-unsafe-component-will-receive-props";
|
|
3378
3158
|
var no_unsafe_component_will_receive_props_default = createRule({
|
|
3379
3159
|
meta: {
|
|
3380
3160
|
type: "problem",
|
|
@@ -3382,9 +3162,8 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
3382
3162
|
messages: { default: "Do not use 'UNSAFE_componentWillReceiveProps'." },
|
|
3383
3163
|
schema: []
|
|
3384
3164
|
},
|
|
3385
|
-
name:
|
|
3386
|
-
create: create$15
|
|
3387
|
-
defaultOptions: []
|
|
3165
|
+
name: "no-unsafe-component-will-receive-props",
|
|
3166
|
+
create: create$15
|
|
3388
3167
|
});
|
|
3389
3168
|
function create$15(context) {
|
|
3390
3169
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
|
|
@@ -3399,10 +3178,6 @@ function create$15(context) {
|
|
|
3399
3178
|
}
|
|
3400
3179
|
} });
|
|
3401
3180
|
}
|
|
3402
|
-
|
|
3403
|
-
//#endregion
|
|
3404
|
-
//#region src/rules/no-unsafe-component-will-update/no-unsafe-component-will-update.ts
|
|
3405
|
-
const RULE_NAME$14 = "no-unsafe-component-will-update";
|
|
3406
3181
|
var no_unsafe_component_will_update_default = createRule({
|
|
3407
3182
|
meta: {
|
|
3408
3183
|
type: "problem",
|
|
@@ -3410,9 +3185,8 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
3410
3185
|
messages: { default: "Do not use 'UNSAFE_componentWillUpdate'." },
|
|
3411
3186
|
schema: []
|
|
3412
3187
|
},
|
|
3413
|
-
name:
|
|
3414
|
-
create: create$14
|
|
3415
|
-
defaultOptions: []
|
|
3188
|
+
name: "no-unsafe-component-will-update",
|
|
3189
|
+
create: create$14
|
|
3416
3190
|
});
|
|
3417
3191
|
function create$14(context) {
|
|
3418
3192
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
@@ -3427,7 +3201,6 @@ function create$14(context) {
|
|
|
3427
3201
|
}
|
|
3428
3202
|
} });
|
|
3429
3203
|
}
|
|
3430
|
-
|
|
3431
3204
|
//#endregion
|
|
3432
3205
|
//#region src/rules/no-unstable-context-value/lib.ts
|
|
3433
3206
|
function isContextName(name, isReact18OrBelow) {
|
|
@@ -3443,10 +3216,6 @@ function getHumanReadableKind$1(node) {
|
|
|
3443
3216
|
}
|
|
3444
3217
|
return toLowerCase(delimiterCase(node.type, " "));
|
|
3445
3218
|
}
|
|
3446
|
-
|
|
3447
|
-
//#endregion
|
|
3448
|
-
//#region src/rules/no-unstable-context-value/no-unstable-context-value.ts
|
|
3449
|
-
const RULE_NAME$13 = "no-unstable-context-value";
|
|
3450
3219
|
var no_unstable_context_value_default = createRule({
|
|
3451
3220
|
meta: {
|
|
3452
3221
|
type: "problem",
|
|
@@ -3454,9 +3223,8 @@ var no_unstable_context_value_default = createRule({
|
|
|
3454
3223
|
messages: { "unstable-context-value": "A/an '{{kind}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}" },
|
|
3455
3224
|
schema: []
|
|
3456
3225
|
},
|
|
3457
|
-
name:
|
|
3458
|
-
create: create$13
|
|
3459
|
-
defaultOptions: []
|
|
3226
|
+
name: "no-unstable-context-value",
|
|
3227
|
+
create: create$13
|
|
3460
3228
|
});
|
|
3461
3229
|
function create$13(context) {
|
|
3462
3230
|
const { compilationMode, version } = getSettingsFromContext(context);
|
|
@@ -3502,7 +3270,6 @@ function create$13(context) {
|
|
|
3502
3270
|
}
|
|
3503
3271
|
});
|
|
3504
3272
|
}
|
|
3505
|
-
|
|
3506
3273
|
//#endregion
|
|
3507
3274
|
//#region src/rules/no-unstable-default-props/lib.ts
|
|
3508
3275
|
const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
|
|
@@ -3518,7 +3285,6 @@ function getHumanReadableKind(node) {
|
|
|
3518
3285
|
}
|
|
3519
3286
|
return toLowerCase(delimiterCase(node.type, " "));
|
|
3520
3287
|
}
|
|
3521
|
-
|
|
3522
3288
|
//#endregion
|
|
3523
3289
|
//#region src/rules/no-unstable-default-props/no-unstable-default-props.ts
|
|
3524
3290
|
const RULE_NAME$12 = "no-unstable-default-props";
|
|
@@ -3534,13 +3300,13 @@ const schema$1 = [{
|
|
|
3534
3300
|
var no_unstable_default_props_default = createRule({
|
|
3535
3301
|
meta: {
|
|
3536
3302
|
type: "problem",
|
|
3303
|
+
defaultOptions: [...defaultOptions$1],
|
|
3537
3304
|
docs: { description: "Prevents using referential-type values as default props in object destructuring." },
|
|
3538
3305
|
messages: { default: "A/an '{{kind}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{kind}}'." },
|
|
3539
3306
|
schema: schema$1
|
|
3540
3307
|
},
|
|
3541
3308
|
name: RULE_NAME$12,
|
|
3542
|
-
create: create$12
|
|
3543
|
-
defaultOptions: defaultOptions$1
|
|
3309
|
+
create: create$12
|
|
3544
3310
|
});
|
|
3545
3311
|
function create$12(context, [options]) {
|
|
3546
3312
|
const { compilationMode } = getSettingsFromContext(context);
|
|
@@ -3588,7 +3354,6 @@ function create$12(context, [options]) {
|
|
|
3588
3354
|
}
|
|
3589
3355
|
});
|
|
3590
3356
|
}
|
|
3591
|
-
|
|
3592
3357
|
//#endregion
|
|
3593
3358
|
//#region src/rules/no-unused-class-component-members/lib.ts
|
|
3594
3359
|
const LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -3616,10 +3381,6 @@ const HOST_CONVENTION_METHODS = /* @__PURE__ */ new Set([
|
|
|
3616
3381
|
"measureLayout",
|
|
3617
3382
|
"setNativeProps"
|
|
3618
3383
|
]);
|
|
3619
|
-
|
|
3620
|
-
//#endregion
|
|
3621
|
-
//#region src/rules/no-unused-class-component-members/no-unused-class-component-members.ts
|
|
3622
|
-
const RULE_NAME$11 = "no-unused-class-component-members";
|
|
3623
3384
|
var no_unused_class_component_members_default = createRule({
|
|
3624
3385
|
meta: {
|
|
3625
3386
|
type: "suggestion",
|
|
@@ -3627,9 +3388,8 @@ var no_unused_class_component_members_default = createRule({
|
|
|
3627
3388
|
messages: { default: "Unused method or property '{{methodName}}'' of class '{{className}}'." },
|
|
3628
3389
|
schema: []
|
|
3629
3390
|
},
|
|
3630
|
-
name:
|
|
3631
|
-
create: create$11
|
|
3632
|
-
defaultOptions: []
|
|
3391
|
+
name: "no-unused-class-component-members",
|
|
3392
|
+
create: create$11
|
|
3633
3393
|
});
|
|
3634
3394
|
function create$11(context) {
|
|
3635
3395
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -3691,7 +3451,6 @@ function create$11(context) {
|
|
|
3691
3451
|
}
|
|
3692
3452
|
};
|
|
3693
3453
|
}
|
|
3694
|
-
|
|
3695
3454
|
//#endregion
|
|
3696
3455
|
//#region src/rules/no-unused-props/lib.ts
|
|
3697
3456
|
function collectUsedPropKeysOfParameter(context, usedPropKeys, parameter) {
|
|
@@ -3752,10 +3511,6 @@ function getKeyOfExpression(expr) {
|
|
|
3752
3511
|
}
|
|
3753
3512
|
return null;
|
|
3754
3513
|
}
|
|
3755
|
-
|
|
3756
|
-
//#endregion
|
|
3757
|
-
//#region src/rules/no-unused-props/no-unused-props.ts
|
|
3758
|
-
const RULE_NAME$10 = "no-unused-props";
|
|
3759
3514
|
var no_unused_props_default = createRule({
|
|
3760
3515
|
meta: {
|
|
3761
3516
|
type: "suggestion",
|
|
@@ -3763,9 +3518,8 @@ var no_unused_props_default = createRule({
|
|
|
3763
3518
|
messages: { default: "Prop `{{name}}` is declared but never used" },
|
|
3764
3519
|
schema: []
|
|
3765
3520
|
},
|
|
3766
|
-
name:
|
|
3767
|
-
create: create$10
|
|
3768
|
-
defaultOptions: []
|
|
3521
|
+
name: "no-unused-props",
|
|
3522
|
+
create: create$10
|
|
3769
3523
|
});
|
|
3770
3524
|
function create$10(context) {
|
|
3771
3525
|
const services = ESLintUtils.getParserServices(context, false);
|
|
@@ -3803,10 +3557,6 @@ function reportUnusedProp(context, services, prop) {
|
|
|
3803
3557
|
node: nodeToReport
|
|
3804
3558
|
});
|
|
3805
3559
|
}
|
|
3806
|
-
|
|
3807
|
-
//#endregion
|
|
3808
|
-
//#region src/rules/no-unused-state/no-unused-state.ts
|
|
3809
|
-
const RULE_NAME$9 = "no-unused-state";
|
|
3810
3560
|
var no_unused_state_default = createRule({
|
|
3811
3561
|
meta: {
|
|
3812
3562
|
type: "problem",
|
|
@@ -3814,9 +3564,8 @@ var no_unused_state_default = createRule({
|
|
|
3814
3564
|
messages: { default: "State variable '{{name}}' is defined but never used." },
|
|
3815
3565
|
schema: []
|
|
3816
3566
|
},
|
|
3817
|
-
name:
|
|
3818
|
-
create: create$9
|
|
3819
|
-
defaultOptions: []
|
|
3567
|
+
name: "no-unused-state",
|
|
3568
|
+
create: create$9
|
|
3820
3569
|
});
|
|
3821
3570
|
function create$9(context) {
|
|
3822
3571
|
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
@@ -3854,10 +3603,6 @@ function create$9(context) {
|
|
|
3854
3603
|
}
|
|
3855
3604
|
};
|
|
3856
3605
|
}
|
|
3857
|
-
|
|
3858
|
-
//#endregion
|
|
3859
|
-
//#region src/rules/no-use-context/no-use-context.ts
|
|
3860
|
-
const RULE_NAME$8 = "no-use-context";
|
|
3861
3606
|
var no_use_context_default = createRule({
|
|
3862
3607
|
meta: {
|
|
3863
3608
|
type: "suggestion",
|
|
@@ -3870,9 +3615,8 @@ var no_use_context_default = createRule({
|
|
|
3870
3615
|
},
|
|
3871
3616
|
schema: []
|
|
3872
3617
|
},
|
|
3873
|
-
name:
|
|
3874
|
-
create: create$8
|
|
3875
|
-
defaultOptions: []
|
|
3618
|
+
name: "no-use-context",
|
|
3619
|
+
create: create$8
|
|
3876
3620
|
});
|
|
3877
3621
|
function create$8(context) {
|
|
3878
3622
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
@@ -3896,7 +3640,6 @@ function create$8(context) {
|
|
|
3896
3640
|
});
|
|
3897
3641
|
} };
|
|
3898
3642
|
}
|
|
3899
|
-
|
|
3900
3643
|
//#endregion
|
|
3901
3644
|
//#region src/rules/purity/lib.ts
|
|
3902
3645
|
const IMPURE_FUNCS = /* @__PURE__ */ new Map([
|
|
@@ -4346,10 +4089,6 @@ function resolveBuiltinObjectName(context, node, seen = /* @__PURE__ */ new Set(
|
|
|
4346
4089
|
}
|
|
4347
4090
|
return null;
|
|
4348
4091
|
}
|
|
4349
|
-
|
|
4350
|
-
//#endregion
|
|
4351
|
-
//#region src/rules/purity/purity.ts
|
|
4352
|
-
const RULE_NAME$7 = "purity";
|
|
4353
4092
|
var purity_default = createRule({
|
|
4354
4093
|
meta: {
|
|
4355
4094
|
type: "problem",
|
|
@@ -4357,9 +4096,8 @@ var purity_default = createRule({
|
|
|
4357
4096
|
messages: { default: "Do not call '{{name}}' during render. Components and hooks must be pure. Move this call into an event handler, effect, or state initializer." },
|
|
4358
4097
|
schema: []
|
|
4359
4098
|
},
|
|
4360
|
-
name:
|
|
4361
|
-
create: create$7
|
|
4362
|
-
defaultOptions: []
|
|
4099
|
+
name: "purity",
|
|
4100
|
+
create: create$7
|
|
4363
4101
|
});
|
|
4364
4102
|
function create$7(context) {
|
|
4365
4103
|
const hc = core.getHookCollector(context);
|
|
@@ -4428,7 +4166,6 @@ function create$7(context) {
|
|
|
4428
4166
|
}
|
|
4429
4167
|
});
|
|
4430
4168
|
}
|
|
4431
|
-
|
|
4432
4169
|
//#endregion
|
|
4433
4170
|
//#region src/rules/refs/helpers.ts
|
|
4434
4171
|
const SYNC_ARRAY_CALLBACKS = /* @__PURE__ */ new Set([
|
|
@@ -4594,7 +4331,6 @@ function isAfterTerminatingNonNullGuard(node, getNullBranch) {
|
|
|
4594
4331
|
}
|
|
4595
4332
|
return false;
|
|
4596
4333
|
}
|
|
4597
|
-
|
|
4598
4334
|
//#endregion
|
|
4599
4335
|
//#region src/rules/refs/collect.ts
|
|
4600
4336
|
function createFactCollector$4() {
|
|
@@ -4693,7 +4429,6 @@ function createFactCollector$4() {
|
|
|
4693
4429
|
}
|
|
4694
4430
|
};
|
|
4695
4431
|
}
|
|
4696
|
-
|
|
4697
4432
|
//#endregion
|
|
4698
4433
|
//#region src/rules/refs/effects.ts
|
|
4699
4434
|
function findBoundary(node, boundaries) {
|
|
@@ -4818,7 +4553,6 @@ function inferRefPassViolations(passSites, boundaries, reachability, resolver) {
|
|
|
4818
4553
|
}
|
|
4819
4554
|
return violations;
|
|
4820
4555
|
}
|
|
4821
|
-
|
|
4822
4556
|
//#endregion
|
|
4823
4557
|
//#region src/rules/refs/origins.ts
|
|
4824
4558
|
function createBindingResolver(context, facts) {
|
|
@@ -4982,10 +4716,6 @@ function getLatestValue(events, position) {
|
|
|
4982
4716
|
}
|
|
4983
4717
|
return latest;
|
|
4984
4718
|
}
|
|
4985
|
-
|
|
4986
|
-
//#endregion
|
|
4987
|
-
//#region src/rules/refs/refs.ts
|
|
4988
|
-
const RULE_NAME$6 = "refs";
|
|
4989
4719
|
var refs_default = createRule({
|
|
4990
4720
|
meta: {
|
|
4991
4721
|
type: "problem",
|
|
@@ -4998,9 +4728,8 @@ var refs_default = createRule({
|
|
|
4998
4728
|
},
|
|
4999
4729
|
schema: []
|
|
5000
4730
|
},
|
|
5001
|
-
name:
|
|
5002
|
-
create: create$6
|
|
5003
|
-
defaultOptions: []
|
|
4731
|
+
name: "refs",
|
|
4732
|
+
create: create$6
|
|
5004
4733
|
});
|
|
5005
4734
|
function create$6(context) {
|
|
5006
4735
|
const hooks = core.getHookCollector(context);
|
|
@@ -5009,8 +4738,7 @@ function create$6(context) {
|
|
|
5009
4738
|
return merge(hooks.visitor, comps.visitor, facts.visitor, { "Program:exit"(program) {
|
|
5010
4739
|
const boundaries = /* @__PURE__ */ new Set([...comps.api.getAllComponents(program).map((component) => component.node), ...hooks.api.getAllHooks(program).map((hook) => hook.node)]);
|
|
5011
4740
|
const resolver = createBindingResolver(context, facts.facts);
|
|
5012
|
-
const
|
|
5013
|
-
const reachability = collectReachableFunctions(boundaries, callGraph);
|
|
4741
|
+
const reachability = collectReachableFunctions(boundaries, inferCallGraph(boundaries, facts.facts.callEdges, resolver.resolveCallable));
|
|
5014
4742
|
const violations = [...inferRefViolations(facts.facts.refAccesses, boundaries, reachability, resolver), ...inferRefPassViolations(facts.facts.passSites, boundaries, reachability, resolver)];
|
|
5015
4743
|
for (const violation of violations) context.report({
|
|
5016
4744
|
messageId: match(violation).with({ kind: "duplicate-init" }, () => "duplicate-ref-init").with({ kind: "pass" }, () => "ref-passed-to-function").with({ kind: "read" }, () => "read-during-render").with({ kind: "write" }, () => "write-during-render").exhaustive(),
|
|
@@ -5018,7 +4746,6 @@ function create$6(context) {
|
|
|
5018
4746
|
});
|
|
5019
4747
|
} });
|
|
5020
4748
|
}
|
|
5021
|
-
|
|
5022
4749
|
//#endregion
|
|
5023
4750
|
//#region src/rules/rules-of-hooks/lib.ts
|
|
5024
4751
|
function assert(cond, message) {
|
|
@@ -6293,7 +6020,6 @@ var CodePathAnalyzer = class {
|
|
|
6293
6020
|
if (fromSegment.reachable && toSegment.reachable) this.emitter.emit("onCodePathSegmentLoop", fromSegment, toSegment, this.currentNode);
|
|
6294
6021
|
}
|
|
6295
6022
|
};
|
|
6296
|
-
|
|
6297
6023
|
//#endregion
|
|
6298
6024
|
//#region src/rules/rules-of-hooks/rules-of-hooks.ts
|
|
6299
6025
|
function isHookName(s) {
|
|
@@ -6617,7 +6343,6 @@ function getFunctionName(node) {
|
|
|
6617
6343
|
function last(array) {
|
|
6618
6344
|
return array[array.length - 1];
|
|
6619
6345
|
}
|
|
6620
|
-
|
|
6621
6346
|
//#endregion
|
|
6622
6347
|
//#region src/rules/set-state-in-effect/helpers.ts
|
|
6623
6348
|
const IDENTIFIER_VISITOR_KEYS = {
|
|
@@ -6691,7 +6416,6 @@ function getCallName(node, getText) {
|
|
|
6691
6416
|
function getSetStateCallExpression(node) {
|
|
6692
6417
|
return Check.isIdentifier(node) && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node ? node.parent : node;
|
|
6693
6418
|
}
|
|
6694
|
-
|
|
6695
6419
|
//#endregion
|
|
6696
6420
|
//#region src/rules/set-state-in-effect/collect.ts
|
|
6697
6421
|
function createFactCollector$3(additionalStateHooks, additionalEffectHooks) {
|
|
@@ -6772,7 +6496,6 @@ function createFactCollector$3(additionalStateHooks, additionalEffectHooks) {
|
|
|
6772
6496
|
}
|
|
6773
6497
|
};
|
|
6774
6498
|
}
|
|
6775
|
-
|
|
6776
6499
|
//#endregion
|
|
6777
6500
|
//#region src/rules/set-state-in-effect/origins.ts
|
|
6778
6501
|
function createSetStateResolver$1(context) {
|
|
@@ -6914,7 +6637,6 @@ function getRefSourceName(node) {
|
|
|
6914
6637
|
default: return null;
|
|
6915
6638
|
}
|
|
6916
6639
|
}
|
|
6917
|
-
|
|
6918
6640
|
//#endregion
|
|
6919
6641
|
//#region src/rules/set-state-in-effect/effects.ts
|
|
6920
6642
|
function inferViolations$2(context, facts) {
|
|
@@ -7016,10 +6738,6 @@ function inferViolations$2(context, facts) {
|
|
|
7016
6738
|
}
|
|
7017
6739
|
return violations;
|
|
7018
6740
|
}
|
|
7019
|
-
|
|
7020
|
-
//#endregion
|
|
7021
|
-
//#region src/rules/set-state-in-effect/set-state-in-effect.ts
|
|
7022
|
-
const RULE_NAME$5 = "set-state-in-effect";
|
|
7023
6741
|
var set_state_in_effect_default = createRule({
|
|
7024
6742
|
meta: {
|
|
7025
6743
|
type: "problem",
|
|
@@ -7027,9 +6745,8 @@ var set_state_in_effect_default = createRule({
|
|
|
7027
6745
|
messages: { default: "Do not call the 'set' function '{{name}}' of 'useState' synchronously in an effect. This can lead to unnecessary re-renders and performance issues." },
|
|
7028
6746
|
schema: []
|
|
7029
6747
|
},
|
|
7030
|
-
name:
|
|
7031
|
-
create: create$5
|
|
7032
|
-
defaultOptions: []
|
|
6748
|
+
name: "set-state-in-effect",
|
|
6749
|
+
create: create$5
|
|
7033
6750
|
});
|
|
7034
6751
|
function create$5(context) {
|
|
7035
6752
|
if (!/use\w*Effect/u.test(context.sourceCode.text)) return {};
|
|
@@ -7043,7 +6760,6 @@ function create$5(context) {
|
|
|
7043
6760
|
});
|
|
7044
6761
|
} });
|
|
7045
6762
|
}
|
|
7046
|
-
|
|
7047
6763
|
//#endregion
|
|
7048
6764
|
//#region src/rules/set-state-in-render/helpers.ts
|
|
7049
6765
|
const isComponentOrHookName = or(core.isFunctionComponentName, core.isHookName);
|
|
@@ -7068,7 +6784,6 @@ function isInsideConditional(node, stopAt) {
|
|
|
7068
6784
|
}
|
|
7069
6785
|
return false;
|
|
7070
6786
|
}
|
|
7071
|
-
|
|
7072
6787
|
//#endregion
|
|
7073
6788
|
//#region src/rules/set-state-in-render/collect.ts
|
|
7074
6789
|
function createFactCollector$2(additionalStateHooks) {
|
|
@@ -7134,7 +6849,6 @@ function createFactCollector$2(additionalStateHooks) {
|
|
|
7134
6849
|
}
|
|
7135
6850
|
};
|
|
7136
6851
|
}
|
|
7137
|
-
|
|
7138
6852
|
//#endregion
|
|
7139
6853
|
//#region src/rules/set-state-in-render/origins.ts
|
|
7140
6854
|
function createSetStateResolver(context) {
|
|
@@ -7180,7 +6894,6 @@ function createSetStateResolver(context) {
|
|
|
7180
6894
|
isUseStateCall
|
|
7181
6895
|
};
|
|
7182
6896
|
}
|
|
7183
|
-
|
|
7184
6897
|
//#endregion
|
|
7185
6898
|
//#region src/rules/set-state-in-render/effects.ts
|
|
7186
6899
|
function inferViolations$1(context, facts) {
|
|
@@ -7202,10 +6915,6 @@ function inferViolations$1(context, facts) {
|
|
|
7202
6915
|
}
|
|
7203
6916
|
return violations;
|
|
7204
6917
|
}
|
|
7205
|
-
|
|
7206
|
-
//#endregion
|
|
7207
|
-
//#region src/rules/set-state-in-render/set-state-in-render.ts
|
|
7208
|
-
const RULE_NAME$4 = "set-state-in-render";
|
|
7209
6918
|
var set_state_in_render_default = createRule({
|
|
7210
6919
|
meta: {
|
|
7211
6920
|
type: "problem",
|
|
@@ -7213,9 +6922,8 @@ var set_state_in_render_default = createRule({
|
|
|
7213
6922
|
messages: { default: "Do not call the 'set' function '{{name}}' unconditionally during render. This will trigger an infinite render loop." },
|
|
7214
6923
|
schema: []
|
|
7215
6924
|
},
|
|
7216
|
-
name:
|
|
7217
|
-
create: create$4
|
|
7218
|
-
defaultOptions: []
|
|
6925
|
+
name: "set-state-in-render",
|
|
6926
|
+
create: create$4
|
|
7219
6927
|
});
|
|
7220
6928
|
function create$4(context) {
|
|
7221
6929
|
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
@@ -7228,7 +6936,6 @@ function create$4(context) {
|
|
|
7228
6936
|
});
|
|
7229
6937
|
} });
|
|
7230
6938
|
}
|
|
7231
|
-
|
|
7232
6939
|
//#endregion
|
|
7233
6940
|
//#region src/rules/static-components/collect.ts
|
|
7234
6941
|
function createFactCollector$1() {
|
|
@@ -7246,7 +6953,6 @@ function createFactCollector$1() {
|
|
|
7246
6953
|
} }
|
|
7247
6954
|
};
|
|
7248
6955
|
}
|
|
7249
|
-
|
|
7250
6956
|
//#endregion
|
|
7251
6957
|
//#region src/rules/static-components/helpers.ts
|
|
7252
6958
|
const KNOWN_DYNAMIC_EXPRESSION_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -7260,7 +6966,6 @@ function createRenderBoundaryChecker(componentNodes) {
|
|
|
7260
6966
|
const components = new Set(componentNodes);
|
|
7261
6967
|
return (node) => Traverse.findParent(node, (n) => (Check.isFunction(n) || Check.isClass(n)) && components.has(n)) != null;
|
|
7262
6968
|
}
|
|
7263
|
-
|
|
7264
6969
|
//#endregion
|
|
7265
6970
|
//#region src/rules/static-components/origins.ts
|
|
7266
6971
|
function findDynamicCreationSite(context, node, isInsideRender, seen) {
|
|
@@ -7322,7 +7027,6 @@ function resolveDynamicComponentOrigin(context, variable, isInsideRender, seen =
|
|
|
7322
7027
|
isDynamic: false
|
|
7323
7028
|
};
|
|
7324
7029
|
}
|
|
7325
|
-
|
|
7326
7030
|
//#endregion
|
|
7327
7031
|
//#region src/rules/static-components/effects.ts
|
|
7328
7032
|
function inferCreatedComponents(context, componentUsages, isInsideRender) {
|
|
@@ -7343,10 +7047,6 @@ function inferCreatedComponents(context, componentUsages, isInsideRender) {
|
|
|
7343
7047
|
}
|
|
7344
7048
|
return effects;
|
|
7345
7049
|
}
|
|
7346
|
-
|
|
7347
|
-
//#endregion
|
|
7348
|
-
//#region src/rules/static-components/static-components.ts
|
|
7349
|
-
const RULE_NAME$3 = "static-components";
|
|
7350
7050
|
var static_components_default = createRule({
|
|
7351
7051
|
meta: {
|
|
7352
7052
|
type: "problem",
|
|
@@ -7357,9 +7057,8 @@ var static_components_default = createRule({
|
|
|
7357
7057
|
},
|
|
7358
7058
|
schema: []
|
|
7359
7059
|
},
|
|
7360
|
-
name:
|
|
7361
|
-
create: create$3
|
|
7362
|
-
defaultOptions: []
|
|
7060
|
+
name: "static-components",
|
|
7061
|
+
create: create$3
|
|
7363
7062
|
});
|
|
7364
7063
|
function create$3(context) {
|
|
7365
7064
|
const hint = core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.FunctionComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.FunctionComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayPatternElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayExpressionElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
|
|
@@ -7367,19 +7066,16 @@ function create$3(context) {
|
|
|
7367
7066
|
const cc = core.getClassComponentCollector(context);
|
|
7368
7067
|
const facts = createFactCollector$1();
|
|
7369
7068
|
return merge(fc.visitor, cc.visitor, facts.visitor, { "Program:exit"(program) {
|
|
7370
|
-
const
|
|
7371
|
-
const isInsideRender = createRenderBoundaryChecker(componentNodes);
|
|
7069
|
+
const isInsideRender = createRenderBoundaryChecker([...fc.api.getAllComponents(program), ...cc.api.getAllComponents(program)].map((component) => component.node));
|
|
7372
7070
|
const reportedCreations = /* @__PURE__ */ new Set();
|
|
7373
7071
|
for (const effect of inferCreatedComponents(context, facts.facts.componentUsages, isInsideRender)) {
|
|
7374
7072
|
context.report({
|
|
7375
|
-
data: { name: effect.name },
|
|
7376
7073
|
messageId: "default",
|
|
7377
7074
|
node: effect.node
|
|
7378
7075
|
});
|
|
7379
7076
|
if (effect.creationNode != null && !reportedCreations.has(effect.creationNode)) {
|
|
7380
7077
|
reportedCreations.add(effect.creationNode);
|
|
7381
7078
|
context.report({
|
|
7382
|
-
data: { name: effect.name },
|
|
7383
7079
|
messageId: "created-here",
|
|
7384
7080
|
node: effect.creationNode
|
|
7385
7081
|
});
|
|
@@ -7387,7 +7083,6 @@ function create$3(context) {
|
|
|
7387
7083
|
}
|
|
7388
7084
|
} });
|
|
7389
7085
|
}
|
|
7390
|
-
|
|
7391
7086
|
//#endregion
|
|
7392
7087
|
//#region src/rules/unsupported-syntax/lib.ts
|
|
7393
7088
|
function isEvalCall(node) {
|
|
@@ -7400,10 +7095,6 @@ function isEvalCall(node) {
|
|
|
7400
7095
|
default: return false;
|
|
7401
7096
|
}
|
|
7402
7097
|
}
|
|
7403
|
-
|
|
7404
|
-
//#endregion
|
|
7405
|
-
//#region src/rules/unsupported-syntax/unsupported-syntax.ts
|
|
7406
|
-
const RULE_NAME$2 = "unsupported-syntax";
|
|
7407
7098
|
var unsupported_syntax_default = createRule({
|
|
7408
7099
|
meta: {
|
|
7409
7100
|
type: "problem",
|
|
@@ -7414,9 +7105,8 @@ var unsupported_syntax_default = createRule({
|
|
|
7414
7105
|
},
|
|
7415
7106
|
schema: []
|
|
7416
7107
|
},
|
|
7417
|
-
name:
|
|
7418
|
-
create: create$2
|
|
7419
|
-
defaultOptions: []
|
|
7108
|
+
name: "unsupported-syntax",
|
|
7109
|
+
create: create$2
|
|
7420
7110
|
});
|
|
7421
7111
|
function create$2(context) {
|
|
7422
7112
|
const hc = core.getHookCollector(context);
|
|
@@ -7462,7 +7152,6 @@ function create$2(context) {
|
|
|
7462
7152
|
}
|
|
7463
7153
|
});
|
|
7464
7154
|
}
|
|
7465
|
-
|
|
7466
7155
|
//#endregion
|
|
7467
7156
|
//#region src/rules/use-memo/helpers.ts
|
|
7468
7157
|
function isResultUsed(node) {
|
|
@@ -7480,7 +7169,6 @@ function getNestedReturnStatements(node) {
|
|
|
7480
7169
|
} });
|
|
7481
7170
|
return statements;
|
|
7482
7171
|
}
|
|
7483
|
-
|
|
7484
7172
|
//#endregion
|
|
7485
7173
|
//#region src/rules/use-memo/collect.ts
|
|
7486
7174
|
function createFactCollector(isUseMemoCall) {
|
|
@@ -7527,7 +7215,6 @@ function createFactCollector(isUseMemoCall) {
|
|
|
7527
7215
|
} }
|
|
7528
7216
|
};
|
|
7529
7217
|
}
|
|
7530
|
-
|
|
7531
7218
|
//#endregion
|
|
7532
7219
|
//#region src/rules/use-memo/origins.ts
|
|
7533
7220
|
function isDeclaredInsideCallback(variable, callback) {
|
|
@@ -7544,7 +7231,6 @@ function isOuterVariable(context, target, callback) {
|
|
|
7544
7231
|
if (variable == null || variable.defs.length === 0) return true;
|
|
7545
7232
|
return !isDeclaredInsideCallback(variable, callback);
|
|
7546
7233
|
}
|
|
7547
|
-
|
|
7548
7234
|
//#endregion
|
|
7549
7235
|
//#region src/rules/use-memo/effects.ts
|
|
7550
7236
|
function inferViolations(context, facts) {
|
|
@@ -7587,10 +7273,6 @@ function inferViolations(context, facts) {
|
|
|
7587
7273
|
}
|
|
7588
7274
|
return violations;
|
|
7589
7275
|
}
|
|
7590
|
-
|
|
7591
|
-
//#endregion
|
|
7592
|
-
//#region src/rules/use-memo/use-memo.ts
|
|
7593
|
-
const RULE_NAME$1 = "use-memo";
|
|
7594
7276
|
var use_memo_default = createRule({
|
|
7595
7277
|
meta: {
|
|
7596
7278
|
type: "problem",
|
|
@@ -7604,9 +7286,8 @@ var use_memo_default = createRule({
|
|
|
7604
7286
|
},
|
|
7605
7287
|
schema: []
|
|
7606
7288
|
},
|
|
7607
|
-
name:
|
|
7608
|
-
create: create$1
|
|
7609
|
-
defaultOptions: []
|
|
7289
|
+
name: "use-memo",
|
|
7290
|
+
create: create$1
|
|
7610
7291
|
});
|
|
7611
7292
|
function create$1(context) {
|
|
7612
7293
|
if (!context.sourceCode.text.includes("useMemo")) return {};
|
|
@@ -7618,7 +7299,6 @@ function create$1(context) {
|
|
|
7618
7299
|
});
|
|
7619
7300
|
} });
|
|
7620
7301
|
}
|
|
7621
|
-
|
|
7622
7302
|
//#endregion
|
|
7623
7303
|
//#region src/rules/use-state/lib.ts
|
|
7624
7304
|
const LAZY_INIT_ALLOW_LIST = [
|
|
@@ -7696,7 +7376,6 @@ function getNestedExpressionsOfType(type) {
|
|
|
7696
7376
|
}
|
|
7697
7377
|
const getNestedNewExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.NewExpression);
|
|
7698
7378
|
const getNestedCallExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.CallExpression);
|
|
7699
|
-
|
|
7700
7379
|
//#endregion
|
|
7701
7380
|
//#region src/rules/use-state/use-state.ts
|
|
7702
7381
|
const RULE_NAME = "use-state";
|
|
@@ -7726,6 +7405,7 @@ const schema = [{
|
|
|
7726
7405
|
var use_state_default = createRule({
|
|
7727
7406
|
meta: {
|
|
7728
7407
|
type: "suggestion",
|
|
7408
|
+
defaultOptions: [...defaultOptions],
|
|
7729
7409
|
docs: { description: "Enforces correct usage of 'useState', including destructuring, symmetric naming of the value and setter, and wrapping expensive initializers in a lazy initializer function." },
|
|
7730
7410
|
messages: {
|
|
7731
7411
|
"invalid-assignment": "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...).",
|
|
@@ -7735,8 +7415,7 @@ var use_state_default = createRule({
|
|
|
7735
7415
|
schema
|
|
7736
7416
|
},
|
|
7737
7417
|
name: RULE_NAME,
|
|
7738
|
-
create
|
|
7739
|
-
defaultOptions
|
|
7418
|
+
create
|
|
7740
7419
|
});
|
|
7741
7420
|
function create(context) {
|
|
7742
7421
|
const { enforceAssignment = true, enforceLazyInitialization = true, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
|
|
@@ -7749,7 +7428,7 @@ function create(context) {
|
|
|
7749
7428
|
for (const expr of getNestedNewExpressions(useStateInput)) {
|
|
7750
7429
|
if (!hasProperty(expr.callee, "name")) continue;
|
|
7751
7430
|
if (LAZY_INIT_ALLOW_LIST.includes(expr.callee.name)) continue;
|
|
7752
|
-
if (Traverse.findParent(expr,
|
|
7431
|
+
if (Traverse.findParent(expr, core.isUseCall(context)) != null) continue;
|
|
7753
7432
|
context.report({
|
|
7754
7433
|
messageId: "invalid-initialization",
|
|
7755
7434
|
node: expr
|
|
@@ -7759,7 +7438,7 @@ function create(context) {
|
|
|
7759
7438
|
if (!hasProperty(expr.callee, "name")) continue;
|
|
7760
7439
|
if (core.isHookName(expr.callee.name)) continue;
|
|
7761
7440
|
if (LAZY_INIT_ALLOW_LIST.includes(expr.callee.name)) continue;
|
|
7762
|
-
if (Traverse.findParent(expr,
|
|
7441
|
+
if (Traverse.findParent(expr, core.isUseCall(context)) != null) continue;
|
|
7763
7442
|
context.report({
|
|
7764
7443
|
messageId: "invalid-initialization",
|
|
7765
7444
|
node: expr
|
|
@@ -7818,7 +7497,6 @@ function create(context) {
|
|
|
7818
7497
|
});
|
|
7819
7498
|
} };
|
|
7820
7499
|
}
|
|
7821
|
-
|
|
7822
7500
|
//#endregion
|
|
7823
7501
|
//#region src/plugin.ts
|
|
7824
7502
|
const plugin = {
|
|
@@ -7882,7 +7560,6 @@ const plugin = {
|
|
|
7882
7560
|
"use-state": use_state_default
|
|
7883
7561
|
}
|
|
7884
7562
|
};
|
|
7885
|
-
|
|
7886
7563
|
//#endregion
|
|
7887
7564
|
//#region src/configs/recommended.ts
|
|
7888
7565
|
var recommended_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -7933,7 +7610,6 @@ const rules$5 = {
|
|
|
7933
7610
|
};
|
|
7934
7611
|
const plugins$5 = { "react-x": plugin };
|
|
7935
7612
|
const settings$5 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
7936
|
-
|
|
7937
7613
|
//#endregion
|
|
7938
7614
|
//#region src/configs/recommended-typescript.ts
|
|
7939
7615
|
var recommended_typescript_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -7946,7 +7622,6 @@ const name$4 = "react-x/recommended-typescript";
|
|
|
7946
7622
|
const rules$4 = { ...rules$5 };
|
|
7947
7623
|
const plugins$4 = { ...plugins$5 };
|
|
7948
7624
|
const settings$4 = { ...settings$5 };
|
|
7949
|
-
|
|
7950
7625
|
//#endregion
|
|
7951
7626
|
//#region src/configs/recommended-type-checked.ts
|
|
7952
7627
|
var recommended_type_checked_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -7962,7 +7637,6 @@ const rules$3 = {
|
|
|
7962
7637
|
};
|
|
7963
7638
|
const plugins$3 = { ...plugins$4 };
|
|
7964
7639
|
const settings$3 = { ...settings$4 };
|
|
7965
|
-
|
|
7966
7640
|
//#endregion
|
|
7967
7641
|
//#region src/configs/strict.ts
|
|
7968
7642
|
var strict_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -7981,7 +7655,6 @@ const rules$2 = {
|
|
|
7981
7655
|
};
|
|
7982
7656
|
const plugins$2 = { ...plugins$5 };
|
|
7983
7657
|
const settings$2 = { ...settings$5 };
|
|
7984
|
-
|
|
7985
7658
|
//#endregion
|
|
7986
7659
|
//#region src/configs/strict-typescript.ts
|
|
7987
7660
|
var strict_typescript_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -7994,7 +7667,6 @@ const name$1 = "react-x/strict-typescript";
|
|
|
7994
7667
|
const rules$1 = { ...rules$2 };
|
|
7995
7668
|
const plugins$1 = { ...plugins$2 };
|
|
7996
7669
|
const settings$1 = { ...settings$2 };
|
|
7997
|
-
|
|
7998
7670
|
//#endregion
|
|
7999
7671
|
//#region src/configs/strict-type-checked.ts
|
|
8000
7672
|
var strict_type_checked_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -8011,7 +7683,6 @@ const rules = {
|
|
|
8011
7683
|
};
|
|
8012
7684
|
const plugins = { ...plugins$1 };
|
|
8013
7685
|
const settings = { ...settings$1 };
|
|
8014
|
-
|
|
8015
7686
|
//#endregion
|
|
8016
7687
|
//#region src/index.ts
|
|
8017
7688
|
function createConfig(base) {
|
|
@@ -8040,6 +7711,5 @@ const finalPlugin = {
|
|
|
8040
7711
|
["strict-typescript"]: createConfig(strict_typescript_exports)
|
|
8041
7712
|
}
|
|
8042
7713
|
};
|
|
8043
|
-
|
|
8044
7714
|
//#endregion
|
|
8045
|
-
export { finalPlugin as default };
|
|
7715
|
+
export { finalPlugin as default };
|