eslint-plugin-react-x 5.0.0-next.0 → 5.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +481 -560
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_ESLINT_REACT_SETTINGS,
|
|
1
|
+
import { DEFAULT_ESLINT_REACT_SETTINGS, defineRuleListener, getSettingsFromContext, report, toRegExp } from "@eslint-react/shared";
|
|
2
2
|
import * as ast from "@eslint-react/ast";
|
|
3
3
|
import * as core from "@eslint-react/core";
|
|
4
4
|
import { isUseRefCall } from "@eslint-react/core";
|
|
@@ -7,7 +7,7 @@ import { ESLintUtils } from "@typescript-eslint/utils";
|
|
|
7
7
|
import { JsxDetectionHint, findParentAttribute, getElementFullType, hasAttribute, isJsxLike } from "@eslint-react/jsx";
|
|
8
8
|
import { computeObjectType, findEnclosingAssignmentTarget, isAssignmentTargetEqual, resolve } from "@eslint-react/var";
|
|
9
9
|
import { DefinitionType } from "@typescript-eslint/scope-manager";
|
|
10
|
-
import { findVariable, getStaticValue
|
|
10
|
+
import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
11
11
|
import { P, isMatching, match } from "ts-pattern";
|
|
12
12
|
import { compare } from "compare-versions";
|
|
13
13
|
import { getConstrainedTypeAtLocation } from "@typescript-eslint/type-utils";
|
|
@@ -118,8 +118,6 @@ const rules$8 = {
|
|
|
118
118
|
"react-x/no-implicit-key": "off",
|
|
119
119
|
"react-x/no-implicit-ref": "off",
|
|
120
120
|
"react-x/no-misused-capture-owner-stack": "off",
|
|
121
|
-
"react-x/no-unnecessary-use-callback": "off",
|
|
122
|
-
"react-x/no-unnecessary-use-memo": "off",
|
|
123
121
|
"react-x/no-unused-props": "off",
|
|
124
122
|
"react-x/refs": "off",
|
|
125
123
|
"react-x/set-state-in-render": "off"
|
|
@@ -143,18 +141,18 @@ const rules$7 = {
|
|
|
143
141
|
//#endregion
|
|
144
142
|
//#region package.json
|
|
145
143
|
var name$6 = "eslint-plugin-react-x";
|
|
146
|
-
var version = "5.0.
|
|
144
|
+
var version = "5.0.1-beta.0";
|
|
147
145
|
|
|
148
146
|
//#endregion
|
|
149
147
|
//#region src/utils/create-rule.ts
|
|
150
148
|
function getDocsUrl(ruleName) {
|
|
151
|
-
return
|
|
149
|
+
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
152
150
|
}
|
|
153
151
|
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
154
152
|
|
|
155
153
|
//#endregion
|
|
156
154
|
//#region src/rules/component-hook-factories/component-hook-factories.ts
|
|
157
|
-
const RULE_NAME$
|
|
155
|
+
const RULE_NAME$48 = "component-hook-factories";
|
|
158
156
|
var component_hook_factories_default = createRule({
|
|
159
157
|
meta: {
|
|
160
158
|
type: "problem",
|
|
@@ -165,8 +163,8 @@ var component_hook_factories_default = createRule({
|
|
|
165
163
|
},
|
|
166
164
|
schema: []
|
|
167
165
|
},
|
|
168
|
-
name: RULE_NAME$
|
|
169
|
-
create: create$
|
|
166
|
+
name: RULE_NAME$48,
|
|
167
|
+
create: create$48,
|
|
170
168
|
defaultOptions: []
|
|
171
169
|
});
|
|
172
170
|
/**
|
|
@@ -212,7 +210,7 @@ function isHigherOrderComponent(fn) {
|
|
|
212
210
|
function isInsideTestMockCallback(node) {
|
|
213
211
|
return ast.findParent(node, ast.isTestMockCallback) != null;
|
|
214
212
|
}
|
|
215
|
-
function create$
|
|
213
|
+
function create$48(context) {
|
|
216
214
|
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;
|
|
217
215
|
const fCollector = core.getFunctionComponentCollector(context, { hint });
|
|
218
216
|
const cCollector = core.getClassComponentCollector(context);
|
|
@@ -263,7 +261,7 @@ function create$53(context) {
|
|
|
263
261
|
|
|
264
262
|
//#endregion
|
|
265
263
|
//#region src/rules/error-boundaries/error-boundaries.ts
|
|
266
|
-
const RULE_NAME$
|
|
264
|
+
const RULE_NAME$47 = "error-boundaries";
|
|
267
265
|
var error_boundaries_default = createRule({
|
|
268
266
|
meta: {
|
|
269
267
|
type: "problem",
|
|
@@ -274,11 +272,11 @@ var error_boundaries_default = createRule({
|
|
|
274
272
|
},
|
|
275
273
|
schema: []
|
|
276
274
|
},
|
|
277
|
-
name: RULE_NAME$
|
|
278
|
-
create: create$
|
|
275
|
+
name: RULE_NAME$47,
|
|
276
|
+
create: create$47,
|
|
279
277
|
defaultOptions: []
|
|
280
278
|
});
|
|
281
|
-
function create$
|
|
279
|
+
function create$47(context) {
|
|
282
280
|
if (!context.sourceCode.text.includes("try")) return {};
|
|
283
281
|
const hint = JsxDetectionHint.DoNotIncludeJsxWithNullValue | JsxDetectionHint.DoNotIncludeJsxWithNumberValue | JsxDetectionHint.DoNotIncludeJsxWithBigIntValue | JsxDetectionHint.DoNotIncludeJsxWithStringValue | JsxDetectionHint.DoNotIncludeJsxWithBooleanValue | JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue | JsxDetectionHint.DoNotIncludeJsxWithEmptyArrayValue;
|
|
284
282
|
const fCollector = core.getFunctionComponentCollector(context);
|
|
@@ -1229,7 +1227,7 @@ function getUnknownDependenciesMessage(reactiveHookName) {
|
|
|
1229
1227
|
|
|
1230
1228
|
//#endregion
|
|
1231
1229
|
//#region src/rules/immutability/immutability.ts
|
|
1232
|
-
const RULE_NAME$
|
|
1230
|
+
const RULE_NAME$46 = "immutability";
|
|
1233
1231
|
/**
|
|
1234
1232
|
* Array methods that mutate the array in place.
|
|
1235
1233
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
@@ -1255,11 +1253,11 @@ var immutability_default = createRule({
|
|
|
1255
1253
|
},
|
|
1256
1254
|
schema: []
|
|
1257
1255
|
},
|
|
1258
|
-
name: RULE_NAME$
|
|
1259
|
-
create: create$
|
|
1256
|
+
name: RULE_NAME$46,
|
|
1257
|
+
create: create$46,
|
|
1260
1258
|
defaultOptions: []
|
|
1261
1259
|
});
|
|
1262
|
-
function create$
|
|
1260
|
+
function create$46(context) {
|
|
1263
1261
|
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
1264
1262
|
const hCollector = core.getHookCollector(context);
|
|
1265
1263
|
const cCollector = core.getFunctionComponentCollector(context);
|
|
@@ -1394,15 +1392,6 @@ function not(predicate) {
|
|
|
1394
1392
|
return (data) => !predicate(data);
|
|
1395
1393
|
}
|
|
1396
1394
|
/**
|
|
1397
|
-
* Returns its argument.
|
|
1398
|
-
*
|
|
1399
|
-
* @param x - The value to return.
|
|
1400
|
-
* @returns The input value unchanged.
|
|
1401
|
-
*/
|
|
1402
|
-
function identity(x) {
|
|
1403
|
-
return x;
|
|
1404
|
-
}
|
|
1405
|
-
/**
|
|
1406
1395
|
* Creates a function that can be used in a data-last (aka `pipe`able) or
|
|
1407
1396
|
* data-first style.
|
|
1408
1397
|
*
|
|
@@ -1575,8 +1564,8 @@ function getOrInsertComputed(map, key, callback) {
|
|
|
1575
1564
|
|
|
1576
1565
|
//#endregion
|
|
1577
1566
|
//#region src/rules/no-access-state-in-setstate/no-access-state-in-setstate.ts
|
|
1578
|
-
const RULE_NAME$
|
|
1579
|
-
function isKeyLiteral$
|
|
1567
|
+
const RULE_NAME$45 = "no-access-state-in-setstate";
|
|
1568
|
+
function isKeyLiteral$1(node, key) {
|
|
1580
1569
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
|
|
1581
1570
|
type: AST_NODE_TYPES.TemplateLiteral,
|
|
1582
1571
|
expressions: []
|
|
@@ -1589,11 +1578,11 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
1589
1578
|
messages: { default: "Do not access 'this.state' within 'setState'. Use the update function instead." },
|
|
1590
1579
|
schema: []
|
|
1591
1580
|
},
|
|
1592
|
-
name: RULE_NAME$
|
|
1593
|
-
create: create$
|
|
1581
|
+
name: RULE_NAME$45,
|
|
1582
|
+
create: create$45,
|
|
1594
1583
|
defaultOptions: []
|
|
1595
1584
|
});
|
|
1596
|
-
function create$
|
|
1585
|
+
function create$45(context) {
|
|
1597
1586
|
if (!context.sourceCode.text.includes("setState")) return {};
|
|
1598
1587
|
const classStack = [];
|
|
1599
1588
|
const methodStack = [];
|
|
@@ -1653,7 +1642,7 @@ function create$50(context) {
|
|
|
1653
1642
|
const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
|
|
1654
1643
|
if (setState == null || hasThisState) return;
|
|
1655
1644
|
if (node.init == null || !ast.isThisExpressionLoose(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
|
|
1656
|
-
if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$
|
|
1645
|
+
if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$1(prop, prop.key) && ast.getPropertyName(prop.key) === "state")) return;
|
|
1657
1646
|
context.report({
|
|
1658
1647
|
messageId: "default",
|
|
1659
1648
|
node
|
|
@@ -1664,7 +1653,7 @@ function create$50(context) {
|
|
|
1664
1653
|
|
|
1665
1654
|
//#endregion
|
|
1666
1655
|
//#region src/rules/no-array-index-key/no-array-index-key.ts
|
|
1667
|
-
const RULE_NAME$
|
|
1656
|
+
const RULE_NAME$44 = "no-array-index-key";
|
|
1668
1657
|
function getIndexParamPosition(methodName) {
|
|
1669
1658
|
switch (methodName) {
|
|
1670
1659
|
case "every":
|
|
@@ -1709,11 +1698,11 @@ var no_array_index_key_default = createRule({
|
|
|
1709
1698
|
messages: { default: "Do not use item index in the array as its key." },
|
|
1710
1699
|
schema: []
|
|
1711
1700
|
},
|
|
1712
|
-
name: RULE_NAME$
|
|
1713
|
-
create: create$
|
|
1701
|
+
name: RULE_NAME$44,
|
|
1702
|
+
create: create$44,
|
|
1714
1703
|
defaultOptions: []
|
|
1715
1704
|
});
|
|
1716
|
-
function create$
|
|
1705
|
+
function create$44(context) {
|
|
1717
1706
|
const indexParamNames = [];
|
|
1718
1707
|
function isArrayIndex(node) {
|
|
1719
1708
|
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name) => name != null && name === node.name);
|
|
@@ -1779,7 +1768,7 @@ function create$49(context) {
|
|
|
1779
1768
|
|
|
1780
1769
|
//#endregion
|
|
1781
1770
|
//#region src/rules/no-children-count/no-children-count.ts
|
|
1782
|
-
const RULE_NAME$
|
|
1771
|
+
const RULE_NAME$43 = "no-children-count";
|
|
1783
1772
|
var no_children_count_default = createRule({
|
|
1784
1773
|
meta: {
|
|
1785
1774
|
type: "suggestion",
|
|
@@ -1787,11 +1776,11 @@ var no_children_count_default = createRule({
|
|
|
1787
1776
|
messages: { default: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1788
1777
|
schema: []
|
|
1789
1778
|
},
|
|
1790
|
-
name: RULE_NAME$
|
|
1791
|
-
create: create$
|
|
1779
|
+
name: RULE_NAME$43,
|
|
1780
|
+
create: create$43,
|
|
1792
1781
|
defaultOptions: []
|
|
1793
1782
|
});
|
|
1794
|
-
function create$
|
|
1783
|
+
function create$43(context) {
|
|
1795
1784
|
return defineRuleListener({ MemberExpression(node) {
|
|
1796
1785
|
if (core.isChildrenCount(context, node)) context.report({
|
|
1797
1786
|
messageId: "default",
|
|
@@ -1802,7 +1791,7 @@ function create$48(context) {
|
|
|
1802
1791
|
|
|
1803
1792
|
//#endregion
|
|
1804
1793
|
//#region src/rules/no-children-for-each/no-children-for-each.ts
|
|
1805
|
-
const RULE_NAME$
|
|
1794
|
+
const RULE_NAME$42 = "no-children-for-each";
|
|
1806
1795
|
var no_children_for_each_default = createRule({
|
|
1807
1796
|
meta: {
|
|
1808
1797
|
type: "suggestion",
|
|
@@ -1810,11 +1799,11 @@ var no_children_for_each_default = createRule({
|
|
|
1810
1799
|
messages: { default: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1811
1800
|
schema: []
|
|
1812
1801
|
},
|
|
1813
|
-
name: RULE_NAME$
|
|
1814
|
-
create: create$
|
|
1802
|
+
name: RULE_NAME$42,
|
|
1803
|
+
create: create$42,
|
|
1815
1804
|
defaultOptions: []
|
|
1816
1805
|
});
|
|
1817
|
-
function create$
|
|
1806
|
+
function create$42(context) {
|
|
1818
1807
|
return defineRuleListener({ MemberExpression(node) {
|
|
1819
1808
|
if (core.isChildrenForEach(context, node)) context.report({
|
|
1820
1809
|
messageId: "default",
|
|
@@ -1825,7 +1814,7 @@ function create$47(context) {
|
|
|
1825
1814
|
|
|
1826
1815
|
//#endregion
|
|
1827
1816
|
//#region src/rules/no-children-map/no-children-map.ts
|
|
1828
|
-
const RULE_NAME$
|
|
1817
|
+
const RULE_NAME$41 = "no-children-map";
|
|
1829
1818
|
var no_children_map_default = createRule({
|
|
1830
1819
|
meta: {
|
|
1831
1820
|
type: "suggestion",
|
|
@@ -1833,11 +1822,11 @@ var no_children_map_default = createRule({
|
|
|
1833
1822
|
messages: { default: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1834
1823
|
schema: []
|
|
1835
1824
|
},
|
|
1836
|
-
name: RULE_NAME$
|
|
1837
|
-
create: create$
|
|
1825
|
+
name: RULE_NAME$41,
|
|
1826
|
+
create: create$41,
|
|
1838
1827
|
defaultOptions: []
|
|
1839
1828
|
});
|
|
1840
|
-
function create$
|
|
1829
|
+
function create$41(context) {
|
|
1841
1830
|
return defineRuleListener({ MemberExpression(node) {
|
|
1842
1831
|
if (core.isChildrenMap(context, node)) context.report({
|
|
1843
1832
|
messageId: "default",
|
|
@@ -1848,7 +1837,7 @@ function create$46(context) {
|
|
|
1848
1837
|
|
|
1849
1838
|
//#endregion
|
|
1850
1839
|
//#region src/rules/no-children-only/no-children-only.ts
|
|
1851
|
-
const RULE_NAME$
|
|
1840
|
+
const RULE_NAME$40 = "no-children-only";
|
|
1852
1841
|
var no_children_only_default = createRule({
|
|
1853
1842
|
meta: {
|
|
1854
1843
|
type: "suggestion",
|
|
@@ -1856,11 +1845,11 @@ var no_children_only_default = createRule({
|
|
|
1856
1845
|
messages: { default: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1857
1846
|
schema: []
|
|
1858
1847
|
},
|
|
1859
|
-
name: RULE_NAME$
|
|
1860
|
-
create: create$
|
|
1848
|
+
name: RULE_NAME$40,
|
|
1849
|
+
create: create$40,
|
|
1861
1850
|
defaultOptions: []
|
|
1862
1851
|
});
|
|
1863
|
-
function create$
|
|
1852
|
+
function create$40(context) {
|
|
1864
1853
|
return defineRuleListener({ MemberExpression(node) {
|
|
1865
1854
|
if (core.isChildrenOnly(context, node)) context.report({
|
|
1866
1855
|
messageId: "default",
|
|
@@ -1871,7 +1860,7 @@ function create$45(context) {
|
|
|
1871
1860
|
|
|
1872
1861
|
//#endregion
|
|
1873
1862
|
//#region src/rules/no-children-to-array/no-children-to-array.ts
|
|
1874
|
-
const RULE_NAME$
|
|
1863
|
+
const RULE_NAME$39 = "no-children-to-array";
|
|
1875
1864
|
var no_children_to_array_default = createRule({
|
|
1876
1865
|
meta: {
|
|
1877
1866
|
type: "suggestion",
|
|
@@ -1879,11 +1868,11 @@ var no_children_to_array_default = createRule({
|
|
|
1879
1868
|
messages: { default: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1880
1869
|
schema: []
|
|
1881
1870
|
},
|
|
1882
|
-
name: RULE_NAME$
|
|
1883
|
-
create: create$
|
|
1871
|
+
name: RULE_NAME$39,
|
|
1872
|
+
create: create$39,
|
|
1884
1873
|
defaultOptions: []
|
|
1885
1874
|
});
|
|
1886
|
-
function create$
|
|
1875
|
+
function create$39(context) {
|
|
1887
1876
|
return defineRuleListener({ MemberExpression(node) {
|
|
1888
1877
|
if (core.isChildrenToArray(context, node)) context.report({
|
|
1889
1878
|
messageId: "default",
|
|
@@ -1894,7 +1883,7 @@ function create$44(context) {
|
|
|
1894
1883
|
|
|
1895
1884
|
//#endregion
|
|
1896
1885
|
//#region src/rules/no-class-component/no-class-component.ts
|
|
1897
|
-
const RULE_NAME$
|
|
1886
|
+
const RULE_NAME$38 = "no-class-component";
|
|
1898
1887
|
var no_class_component_default = createRule({
|
|
1899
1888
|
meta: {
|
|
1900
1889
|
type: "suggestion",
|
|
@@ -1902,11 +1891,11 @@ var no_class_component_default = createRule({
|
|
|
1902
1891
|
messages: { default: "Avoid using class components. Use function components instead." },
|
|
1903
1892
|
schema: []
|
|
1904
1893
|
},
|
|
1905
|
-
name: RULE_NAME$
|
|
1906
|
-
create: create$
|
|
1894
|
+
name: RULE_NAME$38,
|
|
1895
|
+
create: create$38,
|
|
1907
1896
|
defaultOptions: []
|
|
1908
1897
|
});
|
|
1909
|
-
function create$
|
|
1898
|
+
function create$38(context) {
|
|
1910
1899
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
1911
1900
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
1912
1901
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -1923,7 +1912,7 @@ function create$43(context) {
|
|
|
1923
1912
|
|
|
1924
1913
|
//#endregion
|
|
1925
1914
|
//#region src/rules/no-clone-element/no-clone-element.ts
|
|
1926
|
-
const RULE_NAME$
|
|
1915
|
+
const RULE_NAME$37 = "no-clone-element";
|
|
1927
1916
|
var no_clone_element_default = createRule({
|
|
1928
1917
|
meta: {
|
|
1929
1918
|
type: "suggestion",
|
|
@@ -1931,11 +1920,11 @@ var no_clone_element_default = createRule({
|
|
|
1931
1920
|
messages: { default: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
|
|
1932
1921
|
schema: []
|
|
1933
1922
|
},
|
|
1934
|
-
name: RULE_NAME$
|
|
1935
|
-
create: create$
|
|
1923
|
+
name: RULE_NAME$37,
|
|
1924
|
+
create: create$37,
|
|
1936
1925
|
defaultOptions: []
|
|
1937
1926
|
});
|
|
1938
|
-
function create$
|
|
1927
|
+
function create$37(context) {
|
|
1939
1928
|
return defineRuleListener({ CallExpression(node) {
|
|
1940
1929
|
if (core.isCloneElementCall(context, node)) context.report({
|
|
1941
1930
|
messageId: "default",
|
|
@@ -1946,7 +1935,7 @@ function create$42(context) {
|
|
|
1946
1935
|
|
|
1947
1936
|
//#endregion
|
|
1948
1937
|
//#region src/rules/no-component-will-mount/no-component-will-mount.ts
|
|
1949
|
-
const RULE_NAME$
|
|
1938
|
+
const RULE_NAME$36 = "no-component-will-mount";
|
|
1950
1939
|
var no_component_will_mount_default = createRule({
|
|
1951
1940
|
meta: {
|
|
1952
1941
|
type: "problem",
|
|
@@ -1955,11 +1944,11 @@ var no_component_will_mount_default = createRule({
|
|
|
1955
1944
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
|
|
1956
1945
|
schema: []
|
|
1957
1946
|
},
|
|
1958
|
-
name: RULE_NAME$
|
|
1959
|
-
create: create$
|
|
1947
|
+
name: RULE_NAME$36,
|
|
1948
|
+
create: create$36,
|
|
1960
1949
|
defaultOptions: []
|
|
1961
1950
|
});
|
|
1962
|
-
function create$
|
|
1951
|
+
function create$36(context) {
|
|
1963
1952
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
1964
1953
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
1965
1954
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -1979,7 +1968,7 @@ function create$41(context) {
|
|
|
1979
1968
|
|
|
1980
1969
|
//#endregion
|
|
1981
1970
|
//#region src/rules/no-component-will-receive-props/no-component-will-receive-props.ts
|
|
1982
|
-
const RULE_NAME$
|
|
1971
|
+
const RULE_NAME$35 = "no-component-will-receive-props";
|
|
1983
1972
|
var no_component_will_receive_props_default = createRule({
|
|
1984
1973
|
meta: {
|
|
1985
1974
|
type: "problem",
|
|
@@ -1988,11 +1977,11 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1988
1977
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
|
|
1989
1978
|
schema: []
|
|
1990
1979
|
},
|
|
1991
|
-
name: RULE_NAME$
|
|
1992
|
-
create: create$
|
|
1980
|
+
name: RULE_NAME$35,
|
|
1981
|
+
create: create$35,
|
|
1993
1982
|
defaultOptions: []
|
|
1994
1983
|
});
|
|
1995
|
-
function create$
|
|
1984
|
+
function create$35(context) {
|
|
1996
1985
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1997
1986
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
1998
1987
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -2012,7 +2001,7 @@ function create$40(context) {
|
|
|
2012
2001
|
|
|
2013
2002
|
//#endregion
|
|
2014
2003
|
//#region src/rules/no-component-will-update/no-component-will-update.ts
|
|
2015
|
-
const RULE_NAME$
|
|
2004
|
+
const RULE_NAME$34 = "no-component-will-update";
|
|
2016
2005
|
var no_component_will_update_default = createRule({
|
|
2017
2006
|
meta: {
|
|
2018
2007
|
type: "problem",
|
|
@@ -2021,11 +2010,11 @@ var no_component_will_update_default = createRule({
|
|
|
2021
2010
|
messages: { default: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
|
|
2022
2011
|
schema: []
|
|
2023
2012
|
},
|
|
2024
|
-
name: RULE_NAME$
|
|
2025
|
-
create: create$
|
|
2013
|
+
name: RULE_NAME$34,
|
|
2014
|
+
create: create$34,
|
|
2026
2015
|
defaultOptions: []
|
|
2027
2016
|
});
|
|
2028
|
-
function create$
|
|
2017
|
+
function create$34(context) {
|
|
2029
2018
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2030
2019
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
2031
2020
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -2045,7 +2034,7 @@ function create$39(context) {
|
|
|
2045
2034
|
|
|
2046
2035
|
//#endregion
|
|
2047
2036
|
//#region src/rules/no-context-provider/no-context-provider.ts
|
|
2048
|
-
const RULE_NAME$
|
|
2037
|
+
const RULE_NAME$33 = "no-context-provider";
|
|
2049
2038
|
var no_context_provider_default = createRule({
|
|
2050
2039
|
meta: {
|
|
2051
2040
|
type: "suggestion",
|
|
@@ -2058,11 +2047,11 @@ var no_context_provider_default = createRule({
|
|
|
2058
2047
|
},
|
|
2059
2048
|
schema: []
|
|
2060
2049
|
},
|
|
2061
|
-
name: RULE_NAME$
|
|
2062
|
-
create: create$
|
|
2050
|
+
name: RULE_NAME$33,
|
|
2051
|
+
create: create$33,
|
|
2063
2052
|
defaultOptions: []
|
|
2064
2053
|
});
|
|
2065
|
-
function create$
|
|
2054
|
+
function create$33(context) {
|
|
2066
2055
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
2067
2056
|
const { version } = getSettingsFromContext(context);
|
|
2068
2057
|
if (compare(version, "19.0.0", "<")) return {};
|
|
@@ -2092,7 +2081,7 @@ function create$38(context) {
|
|
|
2092
2081
|
|
|
2093
2082
|
//#endregion
|
|
2094
2083
|
//#region src/rules/no-create-ref/no-create-ref.ts
|
|
2095
|
-
const RULE_NAME$
|
|
2084
|
+
const RULE_NAME$32 = "no-create-ref";
|
|
2096
2085
|
var no_create_ref_default = createRule({
|
|
2097
2086
|
meta: {
|
|
2098
2087
|
type: "suggestion",
|
|
@@ -2100,11 +2089,11 @@ var no_create_ref_default = createRule({
|
|
|
2100
2089
|
messages: { default: "[Deprecated] Use 'useRef' instead." },
|
|
2101
2090
|
schema: []
|
|
2102
2091
|
},
|
|
2103
|
-
name: RULE_NAME$
|
|
2104
|
-
create: create$
|
|
2092
|
+
name: RULE_NAME$32,
|
|
2093
|
+
create: create$32,
|
|
2105
2094
|
defaultOptions: []
|
|
2106
2095
|
});
|
|
2107
|
-
function create$
|
|
2096
|
+
function create$32(context) {
|
|
2108
2097
|
return defineRuleListener({ CallExpression(node) {
|
|
2109
2098
|
if (core.isCreateRefCall(context, node) && ast.findParent(node, core.isClassComponent) == null) context.report({
|
|
2110
2099
|
messageId: "default",
|
|
@@ -2115,7 +2104,7 @@ function create$37(context) {
|
|
|
2115
2104
|
|
|
2116
2105
|
//#endregion
|
|
2117
2106
|
//#region src/rules/no-direct-mutation-state/no-direct-mutation-state.ts
|
|
2118
|
-
const RULE_NAME$
|
|
2107
|
+
const RULE_NAME$31 = "no-direct-mutation-state";
|
|
2119
2108
|
function isConstructorFunction(node) {
|
|
2120
2109
|
return ast.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && ast.isMethodOrProperty(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
|
|
2121
2110
|
}
|
|
@@ -2126,11 +2115,11 @@ var no_direct_mutation_state_default = createRule({
|
|
|
2126
2115
|
messages: { default: "Do not mutate state directly. Use 'setState()' instead." },
|
|
2127
2116
|
schema: []
|
|
2128
2117
|
},
|
|
2129
|
-
name: RULE_NAME$
|
|
2130
|
-
create: create$
|
|
2118
|
+
name: RULE_NAME$31,
|
|
2119
|
+
create: create$31,
|
|
2131
2120
|
defaultOptions: []
|
|
2132
2121
|
});
|
|
2133
|
-
function create$
|
|
2122
|
+
function create$31(context) {
|
|
2134
2123
|
return defineRuleListener({ AssignmentExpression(node) {
|
|
2135
2124
|
if (!core.isAssignmentToThisState(node)) return;
|
|
2136
2125
|
const parentClass = ast.findParent(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
|
|
@@ -2144,7 +2133,7 @@ function create$36(context) {
|
|
|
2144
2133
|
|
|
2145
2134
|
//#endregion
|
|
2146
2135
|
//#region src/rules/no-duplicate-key/no-duplicate-key.ts
|
|
2147
|
-
const RULE_NAME$
|
|
2136
|
+
const RULE_NAME$30 = "no-duplicate-key";
|
|
2148
2137
|
var no_duplicate_key_default = createRule({
|
|
2149
2138
|
meta: {
|
|
2150
2139
|
type: "problem",
|
|
@@ -2152,11 +2141,11 @@ var no_duplicate_key_default = createRule({
|
|
|
2152
2141
|
messages: { default: "The 'key' prop must be unique to its sibling elements." },
|
|
2153
2142
|
schema: []
|
|
2154
2143
|
},
|
|
2155
|
-
name: RULE_NAME$
|
|
2156
|
-
create: create$
|
|
2144
|
+
name: RULE_NAME$30,
|
|
2145
|
+
create: create$30,
|
|
2157
2146
|
defaultOptions: []
|
|
2158
2147
|
});
|
|
2159
|
-
function create$
|
|
2148
|
+
function create$30(context) {
|
|
2160
2149
|
if (!context.sourceCode.text.includes("key=")) return {};
|
|
2161
2150
|
const keyedEntries = /* @__PURE__ */ new Map();
|
|
2162
2151
|
function isKeyValueEqual(a, b) {
|
|
@@ -2211,7 +2200,7 @@ function create$35(context) {
|
|
|
2211
2200
|
|
|
2212
2201
|
//#endregion
|
|
2213
2202
|
//#region src/rules/no-forward-ref/no-forward-ref.ts
|
|
2214
|
-
const RULE_NAME$
|
|
2203
|
+
const RULE_NAME$29 = "no-forward-ref";
|
|
2215
2204
|
var no_forward_ref_default = createRule({
|
|
2216
2205
|
meta: {
|
|
2217
2206
|
type: "suggestion",
|
|
@@ -2224,11 +2213,11 @@ var no_forward_ref_default = createRule({
|
|
|
2224
2213
|
},
|
|
2225
2214
|
schema: []
|
|
2226
2215
|
},
|
|
2227
|
-
name: RULE_NAME$
|
|
2228
|
-
create: create$
|
|
2216
|
+
name: RULE_NAME$29,
|
|
2217
|
+
create: create$29,
|
|
2229
2218
|
defaultOptions: []
|
|
2230
2219
|
});
|
|
2231
|
-
function create$
|
|
2220
|
+
function create$29(context) {
|
|
2232
2221
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
2233
2222
|
const { version } = getSettingsFromContext(context);
|
|
2234
2223
|
if (compare(version, "19.0.0", "<")) return {};
|
|
@@ -2333,7 +2322,7 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
2333
2322
|
|
|
2334
2323
|
//#endregion
|
|
2335
2324
|
//#region src/rules/no-implicit-children/no-implicit-children.ts
|
|
2336
|
-
const RULE_NAME$
|
|
2325
|
+
const RULE_NAME$28 = "no-implicit-children";
|
|
2337
2326
|
const RE_REACT_CHILDREN_TYPE = /react\.(reactnode|reactelement|reactportal)$/i;
|
|
2338
2327
|
var no_implicit_children_default = createRule({
|
|
2339
2328
|
meta: {
|
|
@@ -2342,11 +2331,11 @@ var no_implicit_children_default = createRule({
|
|
|
2342
2331
|
messages: { default: "This spread attribute implicitly passes the 'children' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'children' prop, use 'children={value}'." },
|
|
2343
2332
|
schema: []
|
|
2344
2333
|
},
|
|
2345
|
-
name: RULE_NAME$
|
|
2346
|
-
create: create$
|
|
2334
|
+
name: RULE_NAME$28,
|
|
2335
|
+
create: create$28,
|
|
2347
2336
|
defaultOptions: []
|
|
2348
2337
|
});
|
|
2349
|
-
function create$
|
|
2338
|
+
function create$28(context) {
|
|
2350
2339
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2351
2340
|
const checker = services.program.getTypeChecker();
|
|
2352
2341
|
return defineRuleListener({ JSXSpreadAttribute(node) {
|
|
@@ -2371,7 +2360,7 @@ function create$33(context) {
|
|
|
2371
2360
|
|
|
2372
2361
|
//#endregion
|
|
2373
2362
|
//#region src/rules/no-implicit-key/no-implicit-key.ts
|
|
2374
|
-
const RULE_NAME$
|
|
2363
|
+
const RULE_NAME$27 = "no-implicit-key";
|
|
2375
2364
|
var no_implicit_key_default = createRule({
|
|
2376
2365
|
meta: {
|
|
2377
2366
|
type: "problem",
|
|
@@ -2379,11 +2368,11 @@ var no_implicit_key_default = createRule({
|
|
|
2379
2368
|
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}'." },
|
|
2380
2369
|
schema: []
|
|
2381
2370
|
},
|
|
2382
|
-
name: RULE_NAME$
|
|
2383
|
-
create: create$
|
|
2371
|
+
name: RULE_NAME$27,
|
|
2372
|
+
create: create$27,
|
|
2384
2373
|
defaultOptions: []
|
|
2385
2374
|
});
|
|
2386
|
-
function create$
|
|
2375
|
+
function create$27(context) {
|
|
2387
2376
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2388
2377
|
const checker = services.program.getTypeChecker();
|
|
2389
2378
|
return defineRuleListener({ JSXSpreadAttribute(node) {
|
|
@@ -2405,7 +2394,7 @@ function create$32(context) {
|
|
|
2405
2394
|
|
|
2406
2395
|
//#endregion
|
|
2407
2396
|
//#region src/rules/no-implicit-ref/no-implicit-ref.ts
|
|
2408
|
-
const RULE_NAME$
|
|
2397
|
+
const RULE_NAME$26 = "no-implicit-ref";
|
|
2409
2398
|
const RE_REACT_REF_TYPE = /react\.(ref|legacyref|refcallback|refobject)$/i;
|
|
2410
2399
|
var no_implicit_ref_default = createRule({
|
|
2411
2400
|
meta: {
|
|
@@ -2414,11 +2403,11 @@ var no_implicit_ref_default = createRule({
|
|
|
2414
2403
|
messages: { default: "This spread attribute implicitly passes the 'ref' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'ref' prop, use 'ref={value}'." },
|
|
2415
2404
|
schema: []
|
|
2416
2405
|
},
|
|
2417
|
-
name: RULE_NAME$
|
|
2418
|
-
create: create$
|
|
2406
|
+
name: RULE_NAME$26,
|
|
2407
|
+
create: create$26,
|
|
2419
2408
|
defaultOptions: []
|
|
2420
2409
|
});
|
|
2421
|
-
function create$
|
|
2410
|
+
function create$26(context) {
|
|
2422
2411
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2423
2412
|
const checker = services.program.getTypeChecker();
|
|
2424
2413
|
return defineRuleListener({ JSXSpreadAttribute(node) {
|
|
@@ -2442,7 +2431,7 @@ function create$31(context) {
|
|
|
2442
2431
|
|
|
2443
2432
|
//#endregion
|
|
2444
2433
|
//#region src/rules/no-leaked-conditional-rendering/no-leaked-conditional-rendering.ts
|
|
2445
|
-
const RULE_NAME$
|
|
2434
|
+
const RULE_NAME$25 = "no-leaked-conditional-rendering";
|
|
2446
2435
|
var no_leaked_conditional_rendering_default = createRule({
|
|
2447
2436
|
meta: {
|
|
2448
2437
|
type: "problem",
|
|
@@ -2450,11 +2439,11 @@ var no_leaked_conditional_rendering_default = createRule({
|
|
|
2450
2439
|
messages: { default: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
|
|
2451
2440
|
schema: []
|
|
2452
2441
|
},
|
|
2453
|
-
name: RULE_NAME$
|
|
2454
|
-
create: create$
|
|
2442
|
+
name: RULE_NAME$25,
|
|
2443
|
+
create: create$25,
|
|
2455
2444
|
defaultOptions: []
|
|
2456
2445
|
});
|
|
2457
|
-
function create$
|
|
2446
|
+
function create$25(context) {
|
|
2458
2447
|
if (!context.sourceCode.text.includes("&&")) return {};
|
|
2459
2448
|
const { version } = getSettingsFromContext(context);
|
|
2460
2449
|
const allowedVariants = [
|
|
@@ -2512,7 +2501,7 @@ function create$30(context) {
|
|
|
2512
2501
|
|
|
2513
2502
|
//#endregion
|
|
2514
2503
|
//#region src/rules/no-missing-component-display-name/no-missing-component-display-name.ts
|
|
2515
|
-
const RULE_NAME$
|
|
2504
|
+
const RULE_NAME$24 = "no-missing-component-display-name";
|
|
2516
2505
|
var no_missing_component_display_name_default = createRule({
|
|
2517
2506
|
meta: {
|
|
2518
2507
|
type: "suggestion",
|
|
@@ -2520,11 +2509,11 @@ var no_missing_component_display_name_default = createRule({
|
|
|
2520
2509
|
messages: { default: "Add missing 'displayName' for component." },
|
|
2521
2510
|
schema: []
|
|
2522
2511
|
},
|
|
2523
|
-
name: RULE_NAME$
|
|
2524
|
-
create: create$
|
|
2512
|
+
name: RULE_NAME$24,
|
|
2513
|
+
create: create$24,
|
|
2525
2514
|
defaultOptions: []
|
|
2526
2515
|
});
|
|
2527
|
-
function create$
|
|
2516
|
+
function create$24(context) {
|
|
2528
2517
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
2529
2518
|
const { api, visitor } = core.getFunctionComponentCollector(context, {
|
|
2530
2519
|
collectDisplayName: true,
|
|
@@ -2546,7 +2535,7 @@ function create$29(context) {
|
|
|
2546
2535
|
|
|
2547
2536
|
//#endregion
|
|
2548
2537
|
//#region src/rules/no-missing-context-display-name/no-missing-context-display-name.ts
|
|
2549
|
-
const RULE_NAME$
|
|
2538
|
+
const RULE_NAME$23 = "no-missing-context-display-name";
|
|
2550
2539
|
var no_missing_context_display_name_default = createRule({
|
|
2551
2540
|
meta: {
|
|
2552
2541
|
type: "suggestion",
|
|
@@ -2555,11 +2544,11 @@ var no_missing_context_display_name_default = createRule({
|
|
|
2555
2544
|
messages: { default: "Add missing 'displayName' for context." },
|
|
2556
2545
|
schema: []
|
|
2557
2546
|
},
|
|
2558
|
-
name: RULE_NAME$
|
|
2559
|
-
create: create$
|
|
2547
|
+
name: RULE_NAME$23,
|
|
2548
|
+
create: create$23,
|
|
2560
2549
|
defaultOptions: []
|
|
2561
2550
|
});
|
|
2562
|
-
function create$
|
|
2551
|
+
function create$23(context) {
|
|
2563
2552
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
2564
2553
|
const createCalls = [];
|
|
2565
2554
|
const displayNameAssignments = [];
|
|
@@ -2611,7 +2600,7 @@ function create$28(context) {
|
|
|
2611
2600
|
|
|
2612
2601
|
//#endregion
|
|
2613
2602
|
//#region src/rules/no-missing-key/no-missing-key.ts
|
|
2614
|
-
const RULE_NAME$
|
|
2603
|
+
const RULE_NAME$22 = "no-missing-key";
|
|
2615
2604
|
var no_missing_key_default = createRule({
|
|
2616
2605
|
meta: {
|
|
2617
2606
|
type: "problem",
|
|
@@ -2622,11 +2611,11 @@ var no_missing_key_default = createRule({
|
|
|
2622
2611
|
},
|
|
2623
2612
|
schema: []
|
|
2624
2613
|
},
|
|
2625
|
-
name: RULE_NAME$
|
|
2626
|
-
create: create$
|
|
2614
|
+
name: RULE_NAME$22,
|
|
2615
|
+
create: create$22,
|
|
2627
2616
|
defaultOptions: []
|
|
2628
2617
|
});
|
|
2629
|
-
function create$
|
|
2618
|
+
function create$22(ctx) {
|
|
2630
2619
|
let inChildrenToArray = false;
|
|
2631
2620
|
function check(node) {
|
|
2632
2621
|
if (node.type === AST_NODE_TYPES.JSXElement) return !hasAttribute(ctx, node, "key") ? {
|
|
@@ -2696,7 +2685,7 @@ function create$27(ctx) {
|
|
|
2696
2685
|
|
|
2697
2686
|
//#endregion
|
|
2698
2687
|
//#region src/rules/no-misused-capture-owner-stack/no-misused-capture-owner-stack.ts
|
|
2699
|
-
const RULE_NAME$
|
|
2688
|
+
const RULE_NAME$21 = "no-misused-capture-owner-stack";
|
|
2700
2689
|
var no_misused_capture_owner_stack_default = createRule({
|
|
2701
2690
|
meta: {
|
|
2702
2691
|
type: "problem",
|
|
@@ -2707,11 +2696,11 @@ var no_misused_capture_owner_stack_default = createRule({
|
|
|
2707
2696
|
},
|
|
2708
2697
|
schema: []
|
|
2709
2698
|
},
|
|
2710
|
-
name: RULE_NAME$
|
|
2711
|
-
create: create$
|
|
2699
|
+
name: RULE_NAME$21,
|
|
2700
|
+
create: create$21,
|
|
2712
2701
|
defaultOptions: []
|
|
2713
2702
|
});
|
|
2714
|
-
function create$
|
|
2703
|
+
function create$21(context) {
|
|
2715
2704
|
if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
|
|
2716
2705
|
const { importSource } = getSettingsFromContext(context);
|
|
2717
2706
|
return defineRuleListener({
|
|
@@ -2742,7 +2731,7 @@ function isDevelopmentOnlyCheck(node) {
|
|
|
2742
2731
|
|
|
2743
2732
|
//#endregion
|
|
2744
2733
|
//#region src/rules/no-nested-component-definitions/no-nested-component-definitions.ts
|
|
2745
|
-
const RULE_NAME$
|
|
2734
|
+
const RULE_NAME$20 = "no-nested-component-definitions";
|
|
2746
2735
|
var no_nested_component_definitions_default = createRule({
|
|
2747
2736
|
meta: {
|
|
2748
2737
|
type: "problem",
|
|
@@ -2750,11 +2739,11 @@ var no_nested_component_definitions_default = createRule({
|
|
|
2750
2739
|
messages: { default: "Do not nest component definitions inside other components or props. {{suggestion}}" },
|
|
2751
2740
|
schema: []
|
|
2752
2741
|
},
|
|
2753
|
-
name: RULE_NAME$
|
|
2754
|
-
create: create$
|
|
2742
|
+
name: RULE_NAME$20,
|
|
2743
|
+
create: create$20,
|
|
2755
2744
|
defaultOptions: []
|
|
2756
2745
|
});
|
|
2757
|
-
function create$
|
|
2746
|
+
function create$20(context) {
|
|
2758
2747
|
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;
|
|
2759
2748
|
const fCollector = core.getFunctionComponentCollector(context, { hint });
|
|
2760
2749
|
const cCollector = core.getClassComponentCollector(context);
|
|
@@ -2858,7 +2847,7 @@ function isInsideCreateElementProps(context, node) {
|
|
|
2858
2847
|
|
|
2859
2848
|
//#endregion
|
|
2860
2849
|
//#region src/rules/no-nested-lazy-component-declarations/no-nested-lazy-component-declarations.ts
|
|
2861
|
-
const RULE_NAME$
|
|
2850
|
+
const RULE_NAME$19 = "no-nested-lazy-component-declarations";
|
|
2862
2851
|
var no_nested_lazy_component_declarations_default = createRule({
|
|
2863
2852
|
meta: {
|
|
2864
2853
|
type: "problem",
|
|
@@ -2866,11 +2855,11 @@ var no_nested_lazy_component_declarations_default = createRule({
|
|
|
2866
2855
|
messages: { default: "Do not declare lazy components inside other components or hooks. Instead, always declare them at the top level of your module." },
|
|
2867
2856
|
schema: []
|
|
2868
2857
|
},
|
|
2869
|
-
name: RULE_NAME$
|
|
2870
|
-
create: create$
|
|
2858
|
+
name: RULE_NAME$19,
|
|
2859
|
+
create: create$19,
|
|
2871
2860
|
defaultOptions: []
|
|
2872
2861
|
});
|
|
2873
|
-
function create$
|
|
2862
|
+
function create$19(context) {
|
|
2874
2863
|
const fCollector = core.getFunctionComponentCollector(context);
|
|
2875
2864
|
const cCollector = core.getClassComponentCollector(context);
|
|
2876
2865
|
const hCollector = core.getHookCollector(context);
|
|
@@ -2896,7 +2885,7 @@ function create$24(context) {
|
|
|
2896
2885
|
|
|
2897
2886
|
//#endregion
|
|
2898
2887
|
//#region src/rules/no-set-state-in-component-did-mount/no-set-state-in-component-did-mount.ts
|
|
2899
|
-
const RULE_NAME$
|
|
2888
|
+
const RULE_NAME$18 = "no-set-state-in-component-did-mount";
|
|
2900
2889
|
var no_set_state_in_component_did_mount_default = createRule({
|
|
2901
2890
|
meta: {
|
|
2902
2891
|
type: "problem",
|
|
@@ -2904,11 +2893,11 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2904
2893
|
messages: { default: "Do not call `this.setState` in `componentDidMount` outside functions such as callbacks." },
|
|
2905
2894
|
schema: []
|
|
2906
2895
|
},
|
|
2907
|
-
name: RULE_NAME$
|
|
2908
|
-
create: create$
|
|
2896
|
+
name: RULE_NAME$18,
|
|
2897
|
+
create: create$18,
|
|
2909
2898
|
defaultOptions: []
|
|
2910
2899
|
});
|
|
2911
|
-
function create$
|
|
2900
|
+
function create$18(context) {
|
|
2912
2901
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2913
2902
|
return defineRuleListener({ CallExpression(node) {
|
|
2914
2903
|
if (!core.isThisSetStateCall(node)) return;
|
|
@@ -2926,7 +2915,7 @@ function create$23(context) {
|
|
|
2926
2915
|
|
|
2927
2916
|
//#endregion
|
|
2928
2917
|
//#region src/rules/no-set-state-in-component-did-update/no-set-state-in-component-did-update.ts
|
|
2929
|
-
const RULE_NAME$
|
|
2918
|
+
const RULE_NAME$17 = "no-set-state-in-component-did-update";
|
|
2930
2919
|
var no_set_state_in_component_did_update_default = createRule({
|
|
2931
2920
|
meta: {
|
|
2932
2921
|
type: "problem",
|
|
@@ -2934,11 +2923,11 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2934
2923
|
messages: { default: "Do not call `this.setState` in `componentDidUpdate` outside functions such as callbacks." },
|
|
2935
2924
|
schema: []
|
|
2936
2925
|
},
|
|
2937
|
-
name: RULE_NAME$
|
|
2938
|
-
create: create$
|
|
2926
|
+
name: RULE_NAME$17,
|
|
2927
|
+
create: create$17,
|
|
2939
2928
|
defaultOptions: []
|
|
2940
2929
|
});
|
|
2941
|
-
function create$
|
|
2930
|
+
function create$17(context) {
|
|
2942
2931
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2943
2932
|
return defineRuleListener({ CallExpression(node) {
|
|
2944
2933
|
if (!core.isThisSetStateCall(node)) return;
|
|
@@ -2956,7 +2945,7 @@ function create$22(context) {
|
|
|
2956
2945
|
|
|
2957
2946
|
//#endregion
|
|
2958
2947
|
//#region src/rules/no-set-state-in-component-will-update/no-set-state-in-component-will-update.ts
|
|
2959
|
-
const RULE_NAME$
|
|
2948
|
+
const RULE_NAME$16 = "no-set-state-in-component-will-update";
|
|
2960
2949
|
var no_set_state_in_component_will_update_default = createRule({
|
|
2961
2950
|
meta: {
|
|
2962
2951
|
type: "problem",
|
|
@@ -2964,11 +2953,11 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2964
2953
|
messages: { default: "Do not call `this.setState` in `componentWillUpdate` outside functions such as callbacks." },
|
|
2965
2954
|
schema: []
|
|
2966
2955
|
},
|
|
2967
|
-
name: RULE_NAME$
|
|
2968
|
-
create: create$
|
|
2956
|
+
name: RULE_NAME$16,
|
|
2957
|
+
create: create$16,
|
|
2969
2958
|
defaultOptions: []
|
|
2970
2959
|
});
|
|
2971
|
-
function create$
|
|
2960
|
+
function create$16(context) {
|
|
2972
2961
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2973
2962
|
return defineRuleListener({ CallExpression(node) {
|
|
2974
2963
|
if (!core.isThisSetStateCall(node)) return;
|
|
@@ -2984,172 +2973,9 @@ function create$21(context) {
|
|
|
2984
2973
|
} });
|
|
2985
2974
|
}
|
|
2986
2975
|
|
|
2987
|
-
//#endregion
|
|
2988
|
-
//#region src/rules/no-unnecessary-use-callback/no-unnecessary-use-callback.ts
|
|
2989
|
-
const RULE_NAME$20 = "no-unnecessary-use-callback";
|
|
2990
|
-
var no_unnecessary_use_callback_default = createRule({
|
|
2991
|
-
meta: {
|
|
2992
|
-
type: "suggestion",
|
|
2993
|
-
docs: { description: "Disallows unnecessary usage of 'useCallback'." },
|
|
2994
|
-
messages: {
|
|
2995
|
-
default: "An 'useCallback' with empty deps and no references to the component scope may be unnecessary.",
|
|
2996
|
-
noUnnecessaryUseCallbackInsideUseEffect: "{{name}} is only used inside 1 useEffect, which may be unnecessary. You can move the computation into useEffect directly and merge the dependency arrays."
|
|
2997
|
-
},
|
|
2998
|
-
schema: []
|
|
2999
|
-
},
|
|
3000
|
-
name: RULE_NAME$20,
|
|
3001
|
-
create: create$20,
|
|
3002
|
-
defaultOptions: []
|
|
3003
|
-
});
|
|
3004
|
-
function create$20(context) {
|
|
3005
|
-
if (!context.sourceCode.text.includes("useCallback")) return {};
|
|
3006
|
-
return defineRuleListener({ VariableDeclarator(node) {
|
|
3007
|
-
const { id, init } = node;
|
|
3008
|
-
if (id.type !== AST_NODE_TYPES.Identifier || init?.type !== AST_NODE_TYPES.CallExpression || !core.isUseCallbackCall(context, init)) return;
|
|
3009
|
-
const [cbk, ...rest] = context.sourceCode.getDeclaredVariables(node);
|
|
3010
|
-
if (cbk == null || rest.length > 0) return;
|
|
3011
|
-
const checkForUsageInsideUseEffectReport = checkForUsageInsideUseEffect$1(context.sourceCode, init);
|
|
3012
|
-
context.sourceCode.getScope(init);
|
|
3013
|
-
const component = context.sourceCode.getScope(init).block;
|
|
3014
|
-
if (!ast.isFunction(component)) return;
|
|
3015
|
-
const [arg0, arg1] = init.arguments;
|
|
3016
|
-
if (arg0 == null || arg1 == null) return;
|
|
3017
|
-
if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
3018
|
-
const initNode = resolve(context, n);
|
|
3019
|
-
if (initNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
|
|
3020
|
-
return initNode.elements.length === 0;
|
|
3021
|
-
}).otherwise(() => false)) {
|
|
3022
|
-
report(context)(checkForUsageInsideUseEffectReport);
|
|
3023
|
-
return;
|
|
3024
|
-
}
|
|
3025
|
-
const arg0Node = match(arg0).with({ type: AST_NODE_TYPES.ArrowFunctionExpression }, (n) => {
|
|
3026
|
-
if (n.body.type === AST_NODE_TYPES.ArrowFunctionExpression) return n.body;
|
|
3027
|
-
return n;
|
|
3028
|
-
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
3029
|
-
const initNode = resolve(context, n);
|
|
3030
|
-
if (initNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && initNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
|
|
3031
|
-
return initNode;
|
|
3032
|
-
}).otherwise(() => null);
|
|
3033
|
-
if (arg0Node == null) return;
|
|
3034
|
-
function getChildScopes(scope) {
|
|
3035
|
-
return scope.childScopes.reduce((acc, child) => [...acc, ...getChildScopes(child)], [scope]);
|
|
3036
|
-
}
|
|
3037
|
-
if (!getChildScopes(context.sourceCode.getScope(arg0Node)).flatMap((x) => x.references).some((x) => x.resolved?.scope.block === component)) {
|
|
3038
|
-
context.report({
|
|
3039
|
-
messageId: "default",
|
|
3040
|
-
node
|
|
3041
|
-
});
|
|
3042
|
-
return;
|
|
3043
|
-
}
|
|
3044
|
-
report(context)(checkForUsageInsideUseEffectReport);
|
|
3045
|
-
} });
|
|
3046
|
-
}
|
|
3047
|
-
function checkForUsageInsideUseEffect$1(sourceCode, node) {
|
|
3048
|
-
if (!/use\w*Effect/u.test(sourceCode.text)) return null;
|
|
3049
|
-
if (!isVariableDeclarator(node.parent)) return null;
|
|
3050
|
-
if (!isIdentifier(node.parent.id)) return null;
|
|
3051
|
-
const usages = (sourceCode.getDeclaredVariables(node.parent)[0]?.references ?? []).filter((ref) => ref.init !== true);
|
|
3052
|
-
if (usages.length === 0) return null;
|
|
3053
|
-
const effectSet = /* @__PURE__ */ new Set();
|
|
3054
|
-
for (const usage of usages) {
|
|
3055
|
-
const effect = ast.findParent(usage.identifier, core.isUseEffectLikeCall);
|
|
3056
|
-
if (effect == null) return null;
|
|
3057
|
-
effectSet.add(effect);
|
|
3058
|
-
if (effectSet.size > 1) return null;
|
|
3059
|
-
}
|
|
3060
|
-
return {
|
|
3061
|
-
data: { name: node.parent.id.name },
|
|
3062
|
-
messageId: "noUnnecessaryUseCallbackInsideUseEffect",
|
|
3063
|
-
node
|
|
3064
|
-
};
|
|
3065
|
-
}
|
|
3066
|
-
|
|
3067
|
-
//#endregion
|
|
3068
|
-
//#region src/rules/no-unnecessary-use-memo/no-unnecessary-use-memo.ts
|
|
3069
|
-
const RULE_NAME$19 = "no-unnecessary-use-memo";
|
|
3070
|
-
var no_unnecessary_use_memo_default = createRule({
|
|
3071
|
-
meta: {
|
|
3072
|
-
type: "suggestion",
|
|
3073
|
-
docs: { description: "Disallows unnecessary usage of 'useMemo'." },
|
|
3074
|
-
messages: {
|
|
3075
|
-
default: "An 'useMemo' with empty deps and no references to the component scope may be unnecessary.",
|
|
3076
|
-
noUnnecessaryUseMemoInsideUseEffect: "{{name}} is only used inside 1 useEffect, which may be unnecessary. You can move the computation into useEffect directly and merge the dependency arrays."
|
|
3077
|
-
},
|
|
3078
|
-
schema: []
|
|
3079
|
-
},
|
|
3080
|
-
name: RULE_NAME$19,
|
|
3081
|
-
create: create$19,
|
|
3082
|
-
defaultOptions: []
|
|
3083
|
-
});
|
|
3084
|
-
function create$19(context) {
|
|
3085
|
-
if (!context.sourceCode.text.includes("useMemo")) return {};
|
|
3086
|
-
return defineRuleListener({ VariableDeclarator(node) {
|
|
3087
|
-
const { id, init } = node;
|
|
3088
|
-
if (id.type !== AST_NODE_TYPES.Identifier || init?.type !== AST_NODE_TYPES.CallExpression || !core.isUseMemoCall(context, init)) return;
|
|
3089
|
-
const [mem, ...rest] = context.sourceCode.getDeclaredVariables(node);
|
|
3090
|
-
if (mem == null || rest.length > 0) return;
|
|
3091
|
-
const checkForUsageInsideUseEffectReport = checkForUsageInsideUseEffect(context.sourceCode, init);
|
|
3092
|
-
const component = context.sourceCode.getScope(init).block;
|
|
3093
|
-
if (!ast.isFunction(component)) return;
|
|
3094
|
-
const [arg0, arg1] = init.arguments;
|
|
3095
|
-
if (arg0 == null || arg1 == null) return;
|
|
3096
|
-
if (ast.isFunction(arg0) && [...ast.getNestedCallExpressions(arg0.body), ...ast.getNestedNewExpressions(arg0.body)].length > 0) {
|
|
3097
|
-
report(context)(checkForUsageInsideUseEffectReport);
|
|
3098
|
-
return;
|
|
3099
|
-
}
|
|
3100
|
-
if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
3101
|
-
const initNode = resolve(context, n);
|
|
3102
|
-
if (initNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
|
|
3103
|
-
return initNode.elements.length === 0;
|
|
3104
|
-
}).otherwise(() => false)) {
|
|
3105
|
-
report(context)(checkForUsageInsideUseEffectReport);
|
|
3106
|
-
return;
|
|
3107
|
-
}
|
|
3108
|
-
const arg0Node = match(arg0).with({ type: AST_NODE_TYPES.ArrowFunctionExpression }, (n) => {
|
|
3109
|
-
if (n.body.type === AST_NODE_TYPES.ArrowFunctionExpression) return n.body;
|
|
3110
|
-
return n;
|
|
3111
|
-
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
3112
|
-
const initNode = resolve(context, n);
|
|
3113
|
-
if (initNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && initNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
|
|
3114
|
-
return initNode;
|
|
3115
|
-
}).otherwise(() => null);
|
|
3116
|
-
if (arg0Node == null) return;
|
|
3117
|
-
function getChildScopes(scope) {
|
|
3118
|
-
return scope.childScopes.reduce((acc, child) => [...acc, ...getChildScopes(child)], [scope]);
|
|
3119
|
-
}
|
|
3120
|
-
if (!getChildScopes(context.sourceCode.getScope(arg0Node)).flatMap((x) => x.references).some((x) => x.resolved?.scope.block === component)) {
|
|
3121
|
-
context.report({
|
|
3122
|
-
messageId: "default",
|
|
3123
|
-
node
|
|
3124
|
-
});
|
|
3125
|
-
return;
|
|
3126
|
-
}
|
|
3127
|
-
report(context)(checkForUsageInsideUseEffectReport);
|
|
3128
|
-
} });
|
|
3129
|
-
}
|
|
3130
|
-
function checkForUsageInsideUseEffect(sourceCode, node) {
|
|
3131
|
-
if (!/use\w*Effect/u.test(sourceCode.text)) return null;
|
|
3132
|
-
if (!isVariableDeclarator(node.parent)) return null;
|
|
3133
|
-
if (!isIdentifier(node.parent.id)) return null;
|
|
3134
|
-
const usages = (sourceCode.getDeclaredVariables(node.parent)[0]?.references ?? []).filter((ref) => ref.init !== true);
|
|
3135
|
-
if (usages.length === 0) return null;
|
|
3136
|
-
const effectSet = /* @__PURE__ */ new Set();
|
|
3137
|
-
for (const usage of usages) {
|
|
3138
|
-
const effect = ast.findParent(usage.identifier, core.isUseEffectLikeCall);
|
|
3139
|
-
if (effect == null) return null;
|
|
3140
|
-
effectSet.add(effect);
|
|
3141
|
-
if (effectSet.size > 1) return null;
|
|
3142
|
-
}
|
|
3143
|
-
return {
|
|
3144
|
-
data: { name: node.parent.id.name },
|
|
3145
|
-
messageId: "noUnnecessaryUseMemoInsideUseEffect",
|
|
3146
|
-
node
|
|
3147
|
-
};
|
|
3148
|
-
}
|
|
3149
|
-
|
|
3150
2976
|
//#endregion
|
|
3151
2977
|
//#region src/rules/no-unnecessary-use-prefix/no-unnecessary-use-prefix.ts
|
|
3152
|
-
const RULE_NAME$
|
|
2978
|
+
const RULE_NAME$15 = "no-unnecessary-use-prefix";
|
|
3153
2979
|
const WELL_KNOWN_HOOKS = ["useMDXComponents"];
|
|
3154
2980
|
function containsUseComments(context, node) {
|
|
3155
2981
|
return context.sourceCode.getCommentsInside(node).some(({ value }) => /use\([\s\S]*?\)/u.test(value) || /use[A-Z0-9]\w*\([\s\S]*?\)/u.test(value));
|
|
@@ -3161,11 +2987,11 @@ var no_unnecessary_use_prefix_default = createRule({
|
|
|
3161
2987
|
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." },
|
|
3162
2988
|
schema: []
|
|
3163
2989
|
},
|
|
3164
|
-
name: RULE_NAME$
|
|
3165
|
-
create: create$
|
|
2990
|
+
name: RULE_NAME$15,
|
|
2991
|
+
create: create$15,
|
|
3166
2992
|
defaultOptions: []
|
|
3167
2993
|
});
|
|
3168
|
-
function create$
|
|
2994
|
+
function create$15(context) {
|
|
3169
2995
|
const { api, visitor } = core.getHookCollector(context);
|
|
3170
2996
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
3171
2997
|
for (const { id, name, hookCalls, node } of api.getAllHooks(program)) {
|
|
@@ -3186,7 +3012,7 @@ function create$18(context) {
|
|
|
3186
3012
|
|
|
3187
3013
|
//#endregion
|
|
3188
3014
|
//#region src/rules/no-unsafe-component-will-mount/no-unsafe-component-will-mount.ts
|
|
3189
|
-
const RULE_NAME$
|
|
3015
|
+
const RULE_NAME$14 = "no-unsafe-component-will-mount";
|
|
3190
3016
|
var no_unsafe_component_will_mount_default = createRule({
|
|
3191
3017
|
meta: {
|
|
3192
3018
|
type: "problem",
|
|
@@ -3194,11 +3020,11 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
3194
3020
|
messages: { default: "Do not use 'UNSAFE_componentWillMount'." },
|
|
3195
3021
|
schema: []
|
|
3196
3022
|
},
|
|
3197
|
-
name: RULE_NAME$
|
|
3198
|
-
create: create$
|
|
3023
|
+
name: RULE_NAME$14,
|
|
3024
|
+
create: create$14,
|
|
3199
3025
|
defaultOptions: []
|
|
3200
3026
|
});
|
|
3201
|
-
function create$
|
|
3027
|
+
function create$14(context) {
|
|
3202
3028
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
3203
3029
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
3204
3030
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -3214,7 +3040,7 @@ function create$17(context) {
|
|
|
3214
3040
|
|
|
3215
3041
|
//#endregion
|
|
3216
3042
|
//#region src/rules/no-unsafe-component-will-receive-props/no-unsafe-component-will-receive-props.ts
|
|
3217
|
-
const RULE_NAME$
|
|
3043
|
+
const RULE_NAME$13 = "no-unsafe-component-will-receive-props";
|
|
3218
3044
|
var no_unsafe_component_will_receive_props_default = createRule({
|
|
3219
3045
|
meta: {
|
|
3220
3046
|
type: "problem",
|
|
@@ -3222,11 +3048,11 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
3222
3048
|
messages: { default: "Do not use 'UNSAFE_componentWillReceiveProps'." },
|
|
3223
3049
|
schema: []
|
|
3224
3050
|
},
|
|
3225
|
-
name: RULE_NAME$
|
|
3226
|
-
create: create$
|
|
3051
|
+
name: RULE_NAME$13,
|
|
3052
|
+
create: create$13,
|
|
3227
3053
|
defaultOptions: []
|
|
3228
3054
|
});
|
|
3229
|
-
function create$
|
|
3055
|
+
function create$13(context) {
|
|
3230
3056
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
|
|
3231
3057
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
3232
3058
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -3242,7 +3068,7 @@ function create$16(context) {
|
|
|
3242
3068
|
|
|
3243
3069
|
//#endregion
|
|
3244
3070
|
//#region src/rules/no-unsafe-component-will-update/no-unsafe-component-will-update.ts
|
|
3245
|
-
const RULE_NAME$
|
|
3071
|
+
const RULE_NAME$12 = "no-unsafe-component-will-update";
|
|
3246
3072
|
var no_unsafe_component_will_update_default = createRule({
|
|
3247
3073
|
meta: {
|
|
3248
3074
|
type: "problem",
|
|
@@ -3250,11 +3076,11 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
3250
3076
|
messages: { default: "Do not use 'UNSAFE_componentWillUpdate'." },
|
|
3251
3077
|
schema: []
|
|
3252
3078
|
},
|
|
3253
|
-
name: RULE_NAME$
|
|
3254
|
-
create: create$
|
|
3079
|
+
name: RULE_NAME$12,
|
|
3080
|
+
create: create$12,
|
|
3255
3081
|
defaultOptions: []
|
|
3256
3082
|
});
|
|
3257
|
-
function create$
|
|
3083
|
+
function create$12(context) {
|
|
3258
3084
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
3259
3085
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
3260
3086
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
@@ -3270,7 +3096,7 @@ function create$15(context) {
|
|
|
3270
3096
|
|
|
3271
3097
|
//#endregion
|
|
3272
3098
|
//#region src/rules/no-unstable-context-value/no-unstable-context-value.ts
|
|
3273
|
-
const RULE_NAME$
|
|
3099
|
+
const RULE_NAME$11 = "no-unstable-context-value";
|
|
3274
3100
|
var no_unstable_context_value_default = createRule({
|
|
3275
3101
|
meta: {
|
|
3276
3102
|
type: "problem",
|
|
@@ -3278,11 +3104,11 @@ var no_unstable_context_value_default = createRule({
|
|
|
3278
3104
|
messages: { unstableContextValue: "A/an '{{kind}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}" },
|
|
3279
3105
|
schema: []
|
|
3280
3106
|
},
|
|
3281
|
-
name: RULE_NAME$
|
|
3282
|
-
create: create$
|
|
3107
|
+
name: RULE_NAME$11,
|
|
3108
|
+
create: create$11,
|
|
3283
3109
|
defaultOptions: []
|
|
3284
3110
|
});
|
|
3285
|
-
function create$
|
|
3111
|
+
function create$11(context) {
|
|
3286
3112
|
const { compilationMode, version } = getSettingsFromContext(context);
|
|
3287
3113
|
if (compilationMode === "infer" || compilationMode === "all") return {};
|
|
3288
3114
|
if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
|
|
@@ -3334,7 +3160,7 @@ function isContextName(name, isReact18OrBelow) {
|
|
|
3334
3160
|
|
|
3335
3161
|
//#endregion
|
|
3336
3162
|
//#region src/rules/no-unstable-default-props/no-unstable-default-props.ts
|
|
3337
|
-
const RULE_NAME$
|
|
3163
|
+
const RULE_NAME$10 = "no-unstable-default-props";
|
|
3338
3164
|
const defaultOptions$1 = [{ safeDefaultProps: [] }];
|
|
3339
3165
|
const schema$1 = [{
|
|
3340
3166
|
type: "object",
|
|
@@ -3351,8 +3177,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
3351
3177
|
messages: { default: "A/an '{{kind}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{kind}}'." },
|
|
3352
3178
|
schema: schema$1
|
|
3353
3179
|
},
|
|
3354
|
-
name: RULE_NAME$
|
|
3355
|
-
create: create$
|
|
3180
|
+
name: RULE_NAME$10,
|
|
3181
|
+
create: create$10,
|
|
3356
3182
|
defaultOptions: defaultOptions$1
|
|
3357
3183
|
});
|
|
3358
3184
|
function extractIdentifier(node) {
|
|
@@ -3363,7 +3189,7 @@ function extractIdentifier(node) {
|
|
|
3363
3189
|
}
|
|
3364
3190
|
return null;
|
|
3365
3191
|
}
|
|
3366
|
-
function create$
|
|
3192
|
+
function create$10(context, [options]) {
|
|
3367
3193
|
const { compilationMode } = getSettingsFromContext(context);
|
|
3368
3194
|
if (compilationMode === "infer" || compilationMode === "all") return {};
|
|
3369
3195
|
if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
|
|
@@ -3409,7 +3235,7 @@ function create$13(context, [options]) {
|
|
|
3409
3235
|
|
|
3410
3236
|
//#endregion
|
|
3411
3237
|
//#region src/rules/no-unused-class-component-members/no-unused-class-component-members.ts
|
|
3412
|
-
const RULE_NAME$
|
|
3238
|
+
const RULE_NAME$9 = "no-unused-class-component-members";
|
|
3413
3239
|
const LIFECYCLE_METHODS = new Set([
|
|
3414
3240
|
"componentDidCatch",
|
|
3415
3241
|
"componentDidMount",
|
|
@@ -3427,7 +3253,7 @@ const LIFECYCLE_METHODS = new Set([
|
|
|
3427
3253
|
"UNSAFE_componentWillReceiveProps",
|
|
3428
3254
|
"UNSAFE_componentWillUpdate"
|
|
3429
3255
|
]);
|
|
3430
|
-
function isKeyLiteral
|
|
3256
|
+
function isKeyLiteral(node, key) {
|
|
3431
3257
|
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
|
|
3432
3258
|
type: AST_NODE_TYPES.TemplateLiteral,
|
|
3433
3259
|
expressions: []
|
|
@@ -3440,11 +3266,11 @@ var no_unused_class_component_members_default = createRule({
|
|
|
3440
3266
|
messages: { default: "Unused method or property '{{methodName}}'' of class '{{className}}'." },
|
|
3441
3267
|
schema: []
|
|
3442
3268
|
},
|
|
3443
|
-
name: RULE_NAME$
|
|
3444
|
-
create: create$
|
|
3269
|
+
name: RULE_NAME$9,
|
|
3270
|
+
create: create$9,
|
|
3445
3271
|
defaultOptions: []
|
|
3446
3272
|
});
|
|
3447
|
-
function create$
|
|
3273
|
+
function create$9(context) {
|
|
3448
3274
|
const classStack = [];
|
|
3449
3275
|
const methodStack = [];
|
|
3450
3276
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -3481,7 +3307,7 @@ function create$12(context) {
|
|
|
3481
3307
|
const currentClass = classStack.at(-1);
|
|
3482
3308
|
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
3483
3309
|
if (node.static) return;
|
|
3484
|
-
if (isKeyLiteral
|
|
3310
|
+
if (isKeyLiteral(node, node.key)) propertyDefs.get(currentClass)?.add(node.key);
|
|
3485
3311
|
}
|
|
3486
3312
|
function methodExit() {
|
|
3487
3313
|
methodStack.pop();
|
|
@@ -3496,7 +3322,7 @@ function create$12(context) {
|
|
|
3496
3322
|
const currentMethod = methodStack.at(-1);
|
|
3497
3323
|
if (currentClass == null || currentMethod == null) return;
|
|
3498
3324
|
if (!core.isClassComponent(currentClass) || currentMethod.static) return;
|
|
3499
|
-
if (!ast.isThisExpressionLoose(node.object) || !isKeyLiteral
|
|
3325
|
+
if (!ast.isThisExpressionLoose(node.object) || !isKeyLiteral(node, node.property)) return;
|
|
3500
3326
|
if (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
|
|
3501
3327
|
propertyDefs.get(currentClass)?.add(node.property);
|
|
3502
3328
|
return;
|
|
@@ -3514,7 +3340,7 @@ function create$12(context) {
|
|
|
3514
3340
|
if (currentClass == null || currentMethod == null) return;
|
|
3515
3341
|
if (!core.isClassComponent(currentClass) || currentMethod.static) return;
|
|
3516
3342
|
if (node.init != null && ast.isThisExpressionLoose(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern) {
|
|
3517
|
-
for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && isKeyLiteral
|
|
3343
|
+
for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key)) {
|
|
3518
3344
|
const keyName = ast.getPropertyName(prop.key);
|
|
3519
3345
|
if (keyName != null) propertyUsages.get(currentClass)?.add(keyName);
|
|
3520
3346
|
}
|
|
@@ -3525,7 +3351,7 @@ function create$12(context) {
|
|
|
3525
3351
|
|
|
3526
3352
|
//#endregion
|
|
3527
3353
|
//#region src/rules/no-unused-props/no-unused-props.ts
|
|
3528
|
-
const RULE_NAME$
|
|
3354
|
+
const RULE_NAME$8 = "no-unused-props";
|
|
3529
3355
|
var no_unused_props_default = createRule({
|
|
3530
3356
|
meta: {
|
|
3531
3357
|
type: "suggestion",
|
|
@@ -3533,11 +3359,11 @@ var no_unused_props_default = createRule({
|
|
|
3533
3359
|
messages: { default: "Prop `{{name}}` is declared but never used" },
|
|
3534
3360
|
schema: []
|
|
3535
3361
|
},
|
|
3536
|
-
name: RULE_NAME$
|
|
3537
|
-
create: create$
|
|
3362
|
+
name: RULE_NAME$8,
|
|
3363
|
+
create: create$8,
|
|
3538
3364
|
defaultOptions: []
|
|
3539
3365
|
});
|
|
3540
|
-
function create$
|
|
3366
|
+
function create$8(context) {
|
|
3541
3367
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3542
3368
|
const checker = services.program.getTypeChecker();
|
|
3543
3369
|
const { api, visitor } = core.getFunctionComponentCollector(context);
|
|
@@ -3636,136 +3462,9 @@ function reportUnusedProp(context, services, prop) {
|
|
|
3636
3462
|
});
|
|
3637
3463
|
}
|
|
3638
3464
|
|
|
3639
|
-
//#endregion
|
|
3640
|
-
//#region src/rules/no-unused-state/no-unused-state.ts
|
|
3641
|
-
const RULE_NAME$10 = "no-unused-state";
|
|
3642
|
-
function isKeyLiteral(node, key) {
|
|
3643
|
-
return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
|
|
3644
|
-
type: AST_NODE_TYPES.TemplateLiteral,
|
|
3645
|
-
expressions: []
|
|
3646
|
-
}, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
|
|
3647
|
-
}
|
|
3648
|
-
var no_unused_state_default = createRule({
|
|
3649
|
-
meta: {
|
|
3650
|
-
type: "suggestion",
|
|
3651
|
-
docs: { description: "Warns about unused class component state." },
|
|
3652
|
-
messages: { default: "Unused class component state in '{{className}}'" },
|
|
3653
|
-
schema: []
|
|
3654
|
-
},
|
|
3655
|
-
name: RULE_NAME$10,
|
|
3656
|
-
create: create$10,
|
|
3657
|
-
defaultOptions: []
|
|
3658
|
-
});
|
|
3659
|
-
function create$10(context) {
|
|
3660
|
-
const classStack = [];
|
|
3661
|
-
const methodStack = [];
|
|
3662
|
-
const constructorStack = [];
|
|
3663
|
-
const stateDefs = /* @__PURE__ */ new WeakMap();
|
|
3664
|
-
function classEnter(node) {
|
|
3665
|
-
classStack.push(node);
|
|
3666
|
-
}
|
|
3667
|
-
function classExit() {
|
|
3668
|
-
const currentClass = classStack.pop();
|
|
3669
|
-
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
3670
|
-
const id = ast.getClassId(currentClass);
|
|
3671
|
-
const { isUsed = false, node: defNode } = stateDefs.get(currentClass) ?? {};
|
|
3672
|
-
if (defNode == null || isUsed) return;
|
|
3673
|
-
context.report({
|
|
3674
|
-
data: { className: id != null ? context.sourceCode.getText(id) : "Component" },
|
|
3675
|
-
messageId: "default",
|
|
3676
|
-
node: defNode
|
|
3677
|
-
});
|
|
3678
|
-
}
|
|
3679
|
-
function methodEnter(node) {
|
|
3680
|
-
methodStack.push(node);
|
|
3681
|
-
const currentClass = classStack.at(-1);
|
|
3682
|
-
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
3683
|
-
if (node.static) {
|
|
3684
|
-
if (core.isGetDerivedStateFromProps(node) && isMatching({ params: [P.nonNullable, ...P.array()] })(node.value)) {
|
|
3685
|
-
const defNode = stateDefs.get(currentClass)?.node ?? null;
|
|
3686
|
-
stateDefs.set(currentClass, {
|
|
3687
|
-
isUsed: true,
|
|
3688
|
-
node: defNode
|
|
3689
|
-
});
|
|
3690
|
-
}
|
|
3691
|
-
return;
|
|
3692
|
-
}
|
|
3693
|
-
if (ast.getPropertyName(node.key) === "state") stateDefs.set(currentClass, {
|
|
3694
|
-
isUsed: false,
|
|
3695
|
-
node: node.key
|
|
3696
|
-
});
|
|
3697
|
-
}
|
|
3698
|
-
function methodExit() {
|
|
3699
|
-
methodStack.pop();
|
|
3700
|
-
}
|
|
3701
|
-
function constructorEnter(node) {
|
|
3702
|
-
constructorStack.push(node);
|
|
3703
|
-
}
|
|
3704
|
-
function constructorExit() {
|
|
3705
|
-
constructorStack.pop();
|
|
3706
|
-
}
|
|
3707
|
-
return defineRuleListener({
|
|
3708
|
-
AssignmentExpression(node) {
|
|
3709
|
-
if (!core.isAssignmentToThisState(node)) return;
|
|
3710
|
-
const currentClass = classStack.at(-1);
|
|
3711
|
-
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
3712
|
-
const currentConstructor = constructorStack.at(-1);
|
|
3713
|
-
if (currentConstructor == null || !currentClass.body.body.includes(currentConstructor)) return;
|
|
3714
|
-
const isUsed = stateDefs.get(currentClass)?.isUsed ?? false;
|
|
3715
|
-
stateDefs.set(currentClass, {
|
|
3716
|
-
isUsed,
|
|
3717
|
-
node: node.left
|
|
3718
|
-
});
|
|
3719
|
-
},
|
|
3720
|
-
ClassDeclaration: classEnter,
|
|
3721
|
-
"ClassDeclaration:exit": classExit,
|
|
3722
|
-
ClassExpression: classEnter,
|
|
3723
|
-
"ClassExpression:exit": classExit,
|
|
3724
|
-
MemberExpression(node) {
|
|
3725
|
-
if (!ast.isThisExpressionLoose(node.object)) return;
|
|
3726
|
-
if (ast.getPropertyName(node.property) !== "state") return;
|
|
3727
|
-
const currentClass = classStack.at(-1);
|
|
3728
|
-
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
3729
|
-
const currentMethod = methodStack.at(-1);
|
|
3730
|
-
if (currentMethod == null || currentMethod.static) return;
|
|
3731
|
-
if (currentMethod === constructorStack.at(-1)) return;
|
|
3732
|
-
if (!currentClass.body.body.includes(currentMethod)) return;
|
|
3733
|
-
const defNode = stateDefs.get(currentClass)?.node ?? null;
|
|
3734
|
-
stateDefs.set(currentClass, {
|
|
3735
|
-
isUsed: true,
|
|
3736
|
-
node: defNode
|
|
3737
|
-
});
|
|
3738
|
-
},
|
|
3739
|
-
MethodDefinition: methodEnter,
|
|
3740
|
-
"MethodDefinition:exit": methodExit,
|
|
3741
|
-
"MethodDefinition[key.name='constructor']": constructorEnter,
|
|
3742
|
-
"MethodDefinition[key.name='constructor']:exit": constructorExit,
|
|
3743
|
-
PropertyDefinition: methodEnter,
|
|
3744
|
-
"PropertyDefinition:exit": methodExit,
|
|
3745
|
-
VariableDeclarator(node) {
|
|
3746
|
-
const currentClass = classStack.at(-1);
|
|
3747
|
-
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
3748
|
-
const currentMethod = methodStack.at(-1);
|
|
3749
|
-
if (currentMethod == null || currentMethod.static) return;
|
|
3750
|
-
if (currentMethod === constructorStack.at(-1)) return;
|
|
3751
|
-
if (!currentClass.body.body.includes(currentMethod)) return;
|
|
3752
|
-
if (node.init == null || !ast.isThisExpressionLoose(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
|
|
3753
|
-
if (!node.id.properties.some((prop) => {
|
|
3754
|
-
if (prop.type === AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key)) return ast.getPropertyName(prop.key) === "state";
|
|
3755
|
-
return false;
|
|
3756
|
-
})) return;
|
|
3757
|
-
const defNode = stateDefs.get(currentClass)?.node ?? null;
|
|
3758
|
-
stateDefs.set(currentClass, {
|
|
3759
|
-
isUsed: true,
|
|
3760
|
-
node: defNode
|
|
3761
|
-
});
|
|
3762
|
-
}
|
|
3763
|
-
});
|
|
3764
|
-
}
|
|
3765
|
-
|
|
3766
3465
|
//#endregion
|
|
3767
3466
|
//#region src/rules/no-use-context/no-use-context.ts
|
|
3768
|
-
const RULE_NAME$
|
|
3467
|
+
const RULE_NAME$7 = "no-use-context";
|
|
3769
3468
|
var no_use_context_default = createRule({
|
|
3770
3469
|
meta: {
|
|
3771
3470
|
type: "suggestion",
|
|
@@ -3778,11 +3477,11 @@ var no_use_context_default = createRule({
|
|
|
3778
3477
|
},
|
|
3779
3478
|
schema: []
|
|
3780
3479
|
},
|
|
3781
|
-
name: RULE_NAME$
|
|
3782
|
-
create: create$
|
|
3480
|
+
name: RULE_NAME$7,
|
|
3481
|
+
create: create$7,
|
|
3783
3482
|
defaultOptions: []
|
|
3784
3483
|
});
|
|
3785
|
-
function create$
|
|
3484
|
+
function create$7(context) {
|
|
3786
3485
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
3787
3486
|
const { version } = getSettingsFromContext(context);
|
|
3788
3487
|
if (compare(version, "19.0.0", "<")) return {};
|
|
@@ -3806,77 +3505,308 @@ function create$9(context) {
|
|
|
3806
3505
|
}
|
|
3807
3506
|
|
|
3808
3507
|
//#endregion
|
|
3809
|
-
//#region src/rules/
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3508
|
+
//#region src/rules/purity/lib.ts
|
|
3509
|
+
/**
|
|
3510
|
+
* Known impure functions
|
|
3511
|
+
*/
|
|
3512
|
+
const IMPURE_FUNCS = new Map([
|
|
3513
|
+
["Atomics", new Set([
|
|
3514
|
+
"add",
|
|
3515
|
+
"and",
|
|
3516
|
+
"compareExchange",
|
|
3517
|
+
"exchange",
|
|
3518
|
+
"load",
|
|
3519
|
+
"notify",
|
|
3520
|
+
"or",
|
|
3521
|
+
"store",
|
|
3522
|
+
"sub",
|
|
3523
|
+
"wait",
|
|
3524
|
+
"waitAsync",
|
|
3525
|
+
"xor"
|
|
3526
|
+
])],
|
|
3527
|
+
["caches", new Set([
|
|
3528
|
+
"delete",
|
|
3529
|
+
"has",
|
|
3530
|
+
"keys",
|
|
3531
|
+
"match",
|
|
3532
|
+
"open"
|
|
3533
|
+
])],
|
|
3534
|
+
["clipboard", new Set([
|
|
3535
|
+
"read",
|
|
3536
|
+
"readText",
|
|
3537
|
+
"write",
|
|
3538
|
+
"writeText"
|
|
3539
|
+
])],
|
|
3540
|
+
["cookieStore", new Set([
|
|
3541
|
+
"delete",
|
|
3542
|
+
"get",
|
|
3543
|
+
"getAll",
|
|
3544
|
+
"set"
|
|
3545
|
+
])],
|
|
3546
|
+
["crypto", new Set(["getRandomValues", "randomUUID"])],
|
|
3547
|
+
["Date", new Set(["now"])],
|
|
3548
|
+
["document", new Set([
|
|
3549
|
+
"adoptNode",
|
|
3550
|
+
"append",
|
|
3551
|
+
"close",
|
|
3552
|
+
"createAttribute",
|
|
3553
|
+
"createAttributeNS",
|
|
3554
|
+
"createCDATASection",
|
|
3555
|
+
"createComment",
|
|
3556
|
+
"createDocumentFragment",
|
|
3557
|
+
"createDocumentType",
|
|
3558
|
+
"createElement",
|
|
3559
|
+
"createElementNS",
|
|
3560
|
+
"createEvent",
|
|
3561
|
+
"createNodeIterator",
|
|
3562
|
+
"createProcessingInstruction",
|
|
3563
|
+
"createRange",
|
|
3564
|
+
"createTextNode",
|
|
3565
|
+
"createTreeWalker",
|
|
3566
|
+
"elementFromPoint",
|
|
3567
|
+
"elementsFromPoint",
|
|
3568
|
+
"execCommand",
|
|
3569
|
+
"exitFullscreen",
|
|
3570
|
+
"exitPictureInPicture",
|
|
3571
|
+
"exitPointerLock",
|
|
3572
|
+
"getAnimations",
|
|
3573
|
+
"getElementById",
|
|
3574
|
+
"getElementsByClassName",
|
|
3575
|
+
"getElementsByName",
|
|
3576
|
+
"getElementsByTagName",
|
|
3577
|
+
"getElementsByTagNameNS",
|
|
3578
|
+
"getSelection",
|
|
3579
|
+
"hasFocus",
|
|
3580
|
+
"importNode",
|
|
3581
|
+
"open",
|
|
3582
|
+
"prepend",
|
|
3583
|
+
"querySelector",
|
|
3584
|
+
"querySelectorAll",
|
|
3585
|
+
"replaceChildren",
|
|
3586
|
+
"requestStorageAccess",
|
|
3587
|
+
"startViewTransition",
|
|
3588
|
+
"write",
|
|
3589
|
+
"writeln"
|
|
3590
|
+
])],
|
|
3591
|
+
["globalThis", new Set([
|
|
3592
|
+
"addEventListener",
|
|
3593
|
+
"alert",
|
|
3594
|
+
"alert",
|
|
3595
|
+
"blur",
|
|
3596
|
+
"cancelAnimationFrame",
|
|
3597
|
+
"cancelIdleCallback",
|
|
3598
|
+
"clearInterval",
|
|
3599
|
+
"clearInterval",
|
|
3600
|
+
"clearTimeout",
|
|
3601
|
+
"clearTimeout",
|
|
3602
|
+
"close",
|
|
3603
|
+
"confirm",
|
|
3604
|
+
"confirm",
|
|
3605
|
+
"dispatchEvent",
|
|
3606
|
+
"fetch",
|
|
3607
|
+
"fetch",
|
|
3608
|
+
"focus",
|
|
3609
|
+
"getComputedStyle",
|
|
3610
|
+
"getSelection",
|
|
3611
|
+
"matchMedia",
|
|
3612
|
+
"moveBy",
|
|
3613
|
+
"moveTo",
|
|
3614
|
+
"open",
|
|
3615
|
+
"postMessage",
|
|
3616
|
+
"postMessage",
|
|
3617
|
+
"print",
|
|
3618
|
+
"prompt",
|
|
3619
|
+
"prompt",
|
|
3620
|
+
"queueMicrotask",
|
|
3621
|
+
"queueMicrotask",
|
|
3622
|
+
"removeEventListener",
|
|
3623
|
+
"reportError",
|
|
3624
|
+
"requestAnimationFrame",
|
|
3625
|
+
"requestIdleCallback",
|
|
3626
|
+
"resizeBy",
|
|
3627
|
+
"resizeTo",
|
|
3628
|
+
"scroll",
|
|
3629
|
+
"scrollBy",
|
|
3630
|
+
"scrollTo",
|
|
3631
|
+
"setInterval",
|
|
3632
|
+
"setInterval",
|
|
3633
|
+
"setTimeout",
|
|
3634
|
+
"setTimeout",
|
|
3635
|
+
"stop",
|
|
3636
|
+
"structuredClone"
|
|
3637
|
+
])],
|
|
3638
|
+
["history", new Set([
|
|
3639
|
+
"back",
|
|
3640
|
+
"forward",
|
|
3641
|
+
"go",
|
|
3642
|
+
"pushState",
|
|
3643
|
+
"replaceState"
|
|
3644
|
+
])],
|
|
3645
|
+
["indexedDB", new Set([
|
|
3646
|
+
"databases",
|
|
3647
|
+
"deleteDatabase",
|
|
3648
|
+
"open"
|
|
3649
|
+
])],
|
|
3650
|
+
["localStorage", new Set([
|
|
3651
|
+
"clear",
|
|
3652
|
+
"getItem",
|
|
3653
|
+
"key",
|
|
3654
|
+
"removeItem",
|
|
3655
|
+
"setItem"
|
|
3656
|
+
])],
|
|
3657
|
+
["location", new Set([
|
|
3658
|
+
"assign",
|
|
3659
|
+
"reload",
|
|
3660
|
+
"replace"
|
|
3661
|
+
])],
|
|
3662
|
+
["Math", new Set(["random"])],
|
|
3663
|
+
["navigation", new Set([
|
|
3664
|
+
"back",
|
|
3665
|
+
"forward",
|
|
3666
|
+
"navigate",
|
|
3667
|
+
"reload",
|
|
3668
|
+
"traverseTo",
|
|
3669
|
+
"updateCurrentEntry"
|
|
3670
|
+
])],
|
|
3671
|
+
["navigator", new Set([
|
|
3672
|
+
"canShare",
|
|
3673
|
+
"getBattery",
|
|
3674
|
+
"getGamepads",
|
|
3675
|
+
"getUserMedia",
|
|
3676
|
+
"javaEnabled",
|
|
3677
|
+
"registerProtocolHandler",
|
|
3678
|
+
"requestMediaKeySystemAccess",
|
|
3679
|
+
"requestMIDIAccess",
|
|
3680
|
+
"sendBeacon",
|
|
3681
|
+
"share",
|
|
3682
|
+
"vibrate"
|
|
3683
|
+
])],
|
|
3684
|
+
["Notification", new Set(["requestPermission"])],
|
|
3685
|
+
["Object", new Set([
|
|
3686
|
+
"assign",
|
|
3687
|
+
"defineProperties",
|
|
3688
|
+
"defineProperty",
|
|
3689
|
+
"freeze",
|
|
3690
|
+
"preventExtensions",
|
|
3691
|
+
"seal",
|
|
3692
|
+
"setPrototypeOf"
|
|
3693
|
+
])],
|
|
3694
|
+
["performance", new Set([
|
|
3695
|
+
"clearMarks",
|
|
3696
|
+
"clearMeasures",
|
|
3697
|
+
"getEntries",
|
|
3698
|
+
"getEntriesByName",
|
|
3699
|
+
"getEntriesByType",
|
|
3700
|
+
"mark",
|
|
3701
|
+
"measure",
|
|
3702
|
+
"now"
|
|
3703
|
+
])],
|
|
3704
|
+
["process", new Set([
|
|
3705
|
+
"abort",
|
|
3706
|
+
"chdir",
|
|
3707
|
+
"cpuUsage",
|
|
3708
|
+
"emitWarning",
|
|
3709
|
+
"exit",
|
|
3710
|
+
"hrtime",
|
|
3711
|
+
"kill",
|
|
3712
|
+
"memoryUsage",
|
|
3713
|
+
"nextTick",
|
|
3714
|
+
"send",
|
|
3715
|
+
"stderr",
|
|
3716
|
+
"stdout"
|
|
3717
|
+
])],
|
|
3718
|
+
["Reflect", new Set([
|
|
3719
|
+
"defineProperty",
|
|
3720
|
+
"deleteProperty",
|
|
3721
|
+
"preventExtensions",
|
|
3722
|
+
"set",
|
|
3723
|
+
"setPrototypeOf"
|
|
3724
|
+
])],
|
|
3725
|
+
["scheduler", new Set(["postTask", "yield"])],
|
|
3726
|
+
["sessionStorage", new Set([
|
|
3727
|
+
"clear",
|
|
3728
|
+
"getItem",
|
|
3729
|
+
"key",
|
|
3730
|
+
"removeItem",
|
|
3731
|
+
"setItem"
|
|
3732
|
+
])],
|
|
3733
|
+
["URL", new Set(["createObjectURL", "revokeObjectURL"])],
|
|
3734
|
+
["window", new Set([
|
|
3735
|
+
"addEventListener",
|
|
3736
|
+
"alert",
|
|
3737
|
+
"alert",
|
|
3738
|
+
"blur",
|
|
3739
|
+
"cancelAnimationFrame",
|
|
3740
|
+
"cancelIdleCallback",
|
|
3741
|
+
"clearInterval",
|
|
3742
|
+
"clearInterval",
|
|
3743
|
+
"clearTimeout",
|
|
3744
|
+
"clearTimeout",
|
|
3745
|
+
"close",
|
|
3746
|
+
"confirm",
|
|
3747
|
+
"confirm",
|
|
3748
|
+
"dispatchEvent",
|
|
3749
|
+
"fetch",
|
|
3750
|
+
"fetch",
|
|
3751
|
+
"focus",
|
|
3752
|
+
"getComputedStyle",
|
|
3753
|
+
"getSelection",
|
|
3754
|
+
"matchMedia",
|
|
3755
|
+
"moveBy",
|
|
3756
|
+
"moveTo",
|
|
3757
|
+
"open",
|
|
3758
|
+
"postMessage",
|
|
3759
|
+
"postMessage",
|
|
3760
|
+
"print",
|
|
3761
|
+
"prompt",
|
|
3762
|
+
"prompt",
|
|
3763
|
+
"queueMicrotask",
|
|
3764
|
+
"queueMicrotask",
|
|
3765
|
+
"removeEventListener",
|
|
3766
|
+
"reportError",
|
|
3767
|
+
"requestAnimationFrame",
|
|
3768
|
+
"requestIdleCallback",
|
|
3769
|
+
"resizeBy",
|
|
3770
|
+
"resizeTo",
|
|
3771
|
+
"scroll",
|
|
3772
|
+
"scrollBy",
|
|
3773
|
+
"scrollTo",
|
|
3774
|
+
"setInterval",
|
|
3775
|
+
"setInterval",
|
|
3776
|
+
"setTimeout",
|
|
3777
|
+
"setTimeout",
|
|
3778
|
+
"stop",
|
|
3779
|
+
"structuredClone"
|
|
3780
|
+
])]
|
|
3781
|
+
]);
|
|
3782
|
+
/**
|
|
3783
|
+
* Known impure global constructors used with `new`
|
|
3784
|
+
*/
|
|
3785
|
+
const IMPURE_CTORS = new Set([
|
|
3786
|
+
"Audio",
|
|
3787
|
+
"AudioContext",
|
|
3788
|
+
"BroadcastChannel",
|
|
3789
|
+
"Date",
|
|
3790
|
+
"EventSource",
|
|
3791
|
+
"FileReader",
|
|
3792
|
+
"Image",
|
|
3793
|
+
"IntersectionObserver",
|
|
3794
|
+
"MediaRecorder",
|
|
3795
|
+
"MediaSource",
|
|
3796
|
+
"MediaStream",
|
|
3797
|
+
"MessageChannel",
|
|
3798
|
+
"MutationObserver",
|
|
3799
|
+
"Notification",
|
|
3800
|
+
"OfflineAudioContext",
|
|
3801
|
+
"PerformanceObserver",
|
|
3802
|
+
"ReportingObserver",
|
|
3803
|
+
"ResizeObserver",
|
|
3804
|
+
"RTCPeerConnection",
|
|
3805
|
+
"SharedWorker",
|
|
3806
|
+
"WebSocket",
|
|
3807
|
+
"Worker",
|
|
3808
|
+
"XMLHttpRequest"
|
|
3809
|
+
]);
|
|
3880
3810
|
|
|
3881
3811
|
//#endregion
|
|
3882
3812
|
//#region src/rules/purity/purity.ts
|
|
@@ -6914,8 +6844,6 @@ const plugin = {
|
|
|
6914
6844
|
"no-set-state-in-component-did-mount": no_set_state_in_component_did_mount_default,
|
|
6915
6845
|
"no-set-state-in-component-did-update": no_set_state_in_component_did_update_default,
|
|
6916
6846
|
"no-set-state-in-component-will-update": no_set_state_in_component_will_update_default,
|
|
6917
|
-
"no-unnecessary-use-callback": no_unnecessary_use_callback_default,
|
|
6918
|
-
"no-unnecessary-use-memo": no_unnecessary_use_memo_default,
|
|
6919
6847
|
"no-unnecessary-use-prefix": no_unnecessary_use_prefix_default,
|
|
6920
6848
|
"no-unsafe-component-will-mount": no_unsafe_component_will_mount_default,
|
|
6921
6849
|
"no-unsafe-component-will-receive-props": no_unsafe_component_will_receive_props_default,
|
|
@@ -6924,10 +6852,7 @@ const plugin = {
|
|
|
6924
6852
|
"no-unstable-default-props": no_unstable_default_props_default,
|
|
6925
6853
|
"no-unused-class-component-members": no_unused_class_component_members_default,
|
|
6926
6854
|
"no-unused-props": no_unused_props_default,
|
|
6927
|
-
"no-unused-state": no_unused_state_default,
|
|
6928
6855
|
"no-use-context": no_use_context_default,
|
|
6929
|
-
"prefer-destructuring-assignment": prefer_destructuring_assignment_default,
|
|
6930
|
-
"prefer-namespace-import": prefer_namespace_import_default,
|
|
6931
6856
|
purity: purity_default,
|
|
6932
6857
|
refs: refs_default,
|
|
6933
6858
|
"rules-of-hooks": rule,
|
|
@@ -7042,12 +6967,8 @@ const rules$2 = {
|
|
|
7042
6967
|
...rules$6,
|
|
7043
6968
|
"react-x/no-class-component": "error",
|
|
7044
6969
|
"react-x/no-misused-capture-owner-stack": "error",
|
|
7045
|
-
"react-x/no-unnecessary-use-callback": "warn",
|
|
7046
|
-
"react-x/no-unnecessary-use-memo": "warn",
|
|
7047
6970
|
"react-x/no-unstable-context-value": "warn",
|
|
7048
|
-
"react-x/no-unstable-default-props": "warn"
|
|
7049
|
-
"react-x/no-unused-state": "warn",
|
|
7050
|
-
"react-x/prefer-destructuring-assignment": "warn"
|
|
6971
|
+
"react-x/no-unstable-default-props": "warn"
|
|
7051
6972
|
};
|
|
7052
6973
|
const plugins$2 = { ...plugins$5 };
|
|
7053
6974
|
const settings$2 = { ...settings$5 };
|