eslint-plugin-react-x 1.26.3-next.8 → 1.27.0-beta.1
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/README.md +1 -4
- package/dist/index.d.mts +285 -59
- package/dist/index.d.ts +285 -59
- package/dist/index.js +314 -131
- package/dist/index.mjs +315 -132
- package/package.json +14 -14
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
|
|
1
2
|
import * as JSX7 from '@eslint-react/jsx';
|
|
2
|
-
import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings } from '@eslint-react/shared';
|
|
3
3
|
import * as AST11 from '@eslint-react/ast';
|
|
4
|
-
import { isForwardRefCall, isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, isReactHookCall, isReactHookCallWithNameAlias, isCreateElementCall, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
4
|
+
import { isForwardRefCall, isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, DISPLAY_NAME_ASSIGNMENT_SELECTOR, isCreateContextCall, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, isReactHookCall, isReactHookCallWithNameAlias, isCreateElementCall, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
5
5
|
import { _, getOrUpdate, identity } from '@eslint-react/eff';
|
|
6
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
7
7
|
import { isMatching, match, P } from 'ts-pattern';
|
|
@@ -13,9 +13,104 @@ import { unionTypeParts, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType }
|
|
|
13
13
|
import ts from 'typescript';
|
|
14
14
|
import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReadonlyDeep } from 'is-immutable-type';
|
|
15
15
|
|
|
16
|
+
var __defProp = Object.defineProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name5 in all)
|
|
19
|
+
__defProp(target, name5, { get: all[name5], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/configs/recommended.ts
|
|
23
|
+
var recommended_exports = {};
|
|
24
|
+
__export(recommended_exports, {
|
|
25
|
+
name: () => name,
|
|
26
|
+
rules: () => rules,
|
|
27
|
+
settings: () => settings
|
|
28
|
+
});
|
|
29
|
+
var name = "react-x/recommended";
|
|
30
|
+
var rules = {
|
|
31
|
+
"react-x/ensure-forward-ref-using-ref": "warn",
|
|
32
|
+
"react-x/no-access-state-in-setstate": "error",
|
|
33
|
+
"react-x/no-array-index-key": "warn",
|
|
34
|
+
"react-x/no-children-count": "warn",
|
|
35
|
+
"react-x/no-children-for-each": "warn",
|
|
36
|
+
"react-x/no-children-map": "warn",
|
|
37
|
+
"react-x/no-children-only": "warn",
|
|
38
|
+
"react-x/no-children-to-array": "warn",
|
|
39
|
+
"react-x/no-clone-element": "warn",
|
|
40
|
+
"react-x/no-comment-textnodes": "warn",
|
|
41
|
+
"react-x/no-component-will-mount": "error",
|
|
42
|
+
"react-x/no-component-will-receive-props": "error",
|
|
43
|
+
"react-x/no-component-will-update": "error",
|
|
44
|
+
"react-x/no-context-provider": "warn",
|
|
45
|
+
"react-x/no-create-ref": "error",
|
|
46
|
+
"react-x/no-default-props": "error",
|
|
47
|
+
"react-x/no-direct-mutation-state": "error",
|
|
48
|
+
"react-x/no-duplicate-jsx-props": "warn",
|
|
49
|
+
"react-x/no-duplicate-key": "warn",
|
|
50
|
+
"react-x/no-forward-ref": "warn",
|
|
51
|
+
"react-x/no-implicit-key": "warn",
|
|
52
|
+
"react-x/no-missing-key": "error",
|
|
53
|
+
"react-x/no-nested-components": "error",
|
|
54
|
+
"react-x/no-prop-types": "error",
|
|
55
|
+
"react-x/no-redundant-should-component-update": "error",
|
|
56
|
+
"react-x/no-set-state-in-component-did-mount": "warn",
|
|
57
|
+
"react-x/no-set-state-in-component-did-update": "warn",
|
|
58
|
+
"react-x/no-set-state-in-component-will-update": "warn",
|
|
59
|
+
"react-x/no-string-refs": "error",
|
|
60
|
+
"react-x/no-unsafe-component-will-mount": "warn",
|
|
61
|
+
"react-x/no-unsafe-component-will-receive-props": "warn",
|
|
62
|
+
"react-x/no-unsafe-component-will-update": "warn",
|
|
63
|
+
"react-x/no-unstable-context-value": "warn",
|
|
64
|
+
"react-x/no-unstable-default-props": "warn",
|
|
65
|
+
"react-x/no-unused-class-component-members": "warn",
|
|
66
|
+
"react-x/no-unused-state": "warn",
|
|
67
|
+
"react-x/no-use-context": "warn",
|
|
68
|
+
"react-x/use-jsx-vars": "warn"
|
|
69
|
+
};
|
|
70
|
+
var settings = {
|
|
71
|
+
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/configs/recommended-type-checked.ts
|
|
75
|
+
var recommended_type_checked_exports = {};
|
|
76
|
+
__export(recommended_type_checked_exports, {
|
|
77
|
+
name: () => name3,
|
|
78
|
+
rules: () => rules3,
|
|
79
|
+
settings: () => settings3
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// src/configs/recommended-typescript.ts
|
|
83
|
+
var recommended_typescript_exports = {};
|
|
84
|
+
__export(recommended_typescript_exports, {
|
|
85
|
+
name: () => name2,
|
|
86
|
+
rules: () => rules2,
|
|
87
|
+
settings: () => settings2
|
|
88
|
+
});
|
|
89
|
+
var name2 = "react-x/recommended-typescript";
|
|
90
|
+
var rules2 = {
|
|
91
|
+
...rules,
|
|
92
|
+
"react-x/dom/no-unknown-property": "off",
|
|
93
|
+
"react-x/no-duplicate-jsx-props": "off",
|
|
94
|
+
"react-x/use-jsx-vars": "off"
|
|
95
|
+
};
|
|
96
|
+
var settings2 = {
|
|
97
|
+
...settings
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/configs/recommended-type-checked.ts
|
|
101
|
+
var name3 = "react-x/recommended-type-checked";
|
|
102
|
+
var rules3 = {
|
|
103
|
+
...rules2,
|
|
104
|
+
"react-x/no-leaked-conditional-rendering": "warn"
|
|
105
|
+
// "react-x/prefer-read-only-props": "warn",
|
|
106
|
+
};
|
|
107
|
+
var settings3 = {
|
|
108
|
+
...settings2
|
|
109
|
+
};
|
|
110
|
+
|
|
16
111
|
// package.json
|
|
17
|
-
var
|
|
18
|
-
var version = "1.
|
|
112
|
+
var name4 = "eslint-plugin-react-x";
|
|
113
|
+
var version = "1.27.0-beta.1";
|
|
19
114
|
var createRule = createRuleForPlugin("x");
|
|
20
115
|
|
|
21
116
|
// src/utils/get-associated-tokens.ts
|
|
@@ -252,7 +347,7 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
252
347
|
if (setState == null || hasThisState) {
|
|
253
348
|
return;
|
|
254
349
|
}
|
|
255
|
-
if (
|
|
350
|
+
if (node.init == null || !AST11.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) {
|
|
256
351
|
return;
|
|
257
352
|
}
|
|
258
353
|
const hasState = node.id.properties.some(
|
|
@@ -286,8 +381,8 @@ var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
|
286
381
|
["reduceRight", 2],
|
|
287
382
|
["some", 1]
|
|
288
383
|
]);
|
|
289
|
-
function isReactChildrenMethod(
|
|
290
|
-
return reactChildrenMethod.some((method) => method ===
|
|
384
|
+
function isReactChildrenMethod(name5) {
|
|
385
|
+
return reactChildrenMethod.some((method) => method === name5);
|
|
291
386
|
}
|
|
292
387
|
function isUsingReactChildren(node, context) {
|
|
293
388
|
const { importSource = "react" } = unsafeDecodeSettings(context.settings);
|
|
@@ -315,8 +410,8 @@ function getMapIndexParamName(node, context) {
|
|
|
315
410
|
if (callee.property.type !== AST_NODE_TYPES.Identifier) {
|
|
316
411
|
return _;
|
|
317
412
|
}
|
|
318
|
-
const { name:
|
|
319
|
-
if (!iteratorFunctionIndexParamPosition.has(
|
|
413
|
+
const { name: name5 } = callee.property;
|
|
414
|
+
if (!iteratorFunctionIndexParamPosition.has(name5)) {
|
|
320
415
|
return _;
|
|
321
416
|
}
|
|
322
417
|
const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0];
|
|
@@ -327,7 +422,7 @@ function getMapIndexParamName(node, context) {
|
|
|
327
422
|
return _;
|
|
328
423
|
}
|
|
329
424
|
const { params } = callbackArg;
|
|
330
|
-
const indexParamPosition = iteratorFunctionIndexParamPosition.get(
|
|
425
|
+
const indexParamPosition = iteratorFunctionIndexParamPosition.get(name5);
|
|
331
426
|
if (indexParamPosition == null) {
|
|
332
427
|
return _;
|
|
333
428
|
}
|
|
@@ -353,7 +448,7 @@ var no_array_index_key_default = createRule({
|
|
|
353
448
|
create(context) {
|
|
354
449
|
const indexParamNames = [];
|
|
355
450
|
function isArrayIndex(node) {
|
|
356
|
-
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((
|
|
451
|
+
return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
357
452
|
}
|
|
358
453
|
function isCreateOrCloneElementCall(node) {
|
|
359
454
|
return isCreateElementCall(node, context) || isCloneElementCall(node, context);
|
|
@@ -362,7 +457,7 @@ var no_array_index_key_default = createRule({
|
|
|
362
457
|
switch (node.type) {
|
|
363
458
|
// key={bar}
|
|
364
459
|
case AST_NODE_TYPES.Identifier: {
|
|
365
|
-
if (indexParamNames.some((
|
|
460
|
+
if (indexParamNames.some((name5) => name5 != null && name5 === node.name)) {
|
|
366
461
|
return [{
|
|
367
462
|
messageId: "noArrayIndexKey",
|
|
368
463
|
node
|
|
@@ -672,7 +767,7 @@ var no_class_component_default = createRule({
|
|
|
672
767
|
...listeners,
|
|
673
768
|
"Program:exit"(node) {
|
|
674
769
|
const components = ctx.getAllComponents(node);
|
|
675
|
-
for (const { name:
|
|
770
|
+
for (const { name: name5 = "anonymous", node: component } of components.values()) {
|
|
676
771
|
if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
|
|
677
772
|
continue;
|
|
678
773
|
}
|
|
@@ -680,7 +775,7 @@ var no_class_component_default = createRule({
|
|
|
680
775
|
messageId: "noClassComponent",
|
|
681
776
|
node: component,
|
|
682
777
|
data: {
|
|
683
|
-
name:
|
|
778
|
+
name: name5
|
|
684
779
|
}
|
|
685
780
|
});
|
|
686
781
|
}
|
|
@@ -998,8 +1093,8 @@ var no_context_provider_default = createRule({
|
|
|
998
1093
|
}
|
|
999
1094
|
return {
|
|
1000
1095
|
JSXElement(node) {
|
|
1001
|
-
const [
|
|
1002
|
-
if (
|
|
1096
|
+
const [name5, ...rest] = JSX7.getElementName(node).split(".").reverse();
|
|
1097
|
+
if (name5 !== "Provider") return;
|
|
1003
1098
|
const contextName = rest.reverse().join(".");
|
|
1004
1099
|
context.report({
|
|
1005
1100
|
messageId: "noContextProvider",
|
|
@@ -1196,12 +1291,12 @@ var no_duplicate_jsx_props_default = createRule({
|
|
|
1196
1291
|
if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1197
1292
|
continue;
|
|
1198
1293
|
}
|
|
1199
|
-
const
|
|
1200
|
-
if (typeof
|
|
1294
|
+
const name5 = attr.name.name;
|
|
1295
|
+
if (typeof name5 !== "string") {
|
|
1201
1296
|
continue;
|
|
1202
1297
|
}
|
|
1203
|
-
if (!props.includes(
|
|
1204
|
-
props.push(
|
|
1298
|
+
if (!props.includes(name5)) {
|
|
1299
|
+
props.push(name5);
|
|
1205
1300
|
continue;
|
|
1206
1301
|
}
|
|
1207
1302
|
context.report({
|
|
@@ -1654,16 +1749,76 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1654
1749
|
},
|
|
1655
1750
|
defaultOptions: []
|
|
1656
1751
|
});
|
|
1657
|
-
var RULE_NAME29 = "no-missing-
|
|
1752
|
+
var RULE_NAME29 = "no-missing-context-display-name";
|
|
1658
1753
|
var RULE_FEATURES29 = [
|
|
1659
1754
|
"CHK"
|
|
1660
1755
|
];
|
|
1756
|
+
var no_missing_context_display_name_default = createRule({
|
|
1757
|
+
meta: {
|
|
1758
|
+
type: "problem",
|
|
1759
|
+
docs: {
|
|
1760
|
+
description: "require 'displayName' for contexts.",
|
|
1761
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1762
|
+
},
|
|
1763
|
+
messages: {
|
|
1764
|
+
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1765
|
+
},
|
|
1766
|
+
schema: []
|
|
1767
|
+
},
|
|
1768
|
+
name: RULE_NAME29,
|
|
1769
|
+
create(context) {
|
|
1770
|
+
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1771
|
+
const contexts = /* @__PURE__ */ new Set();
|
|
1772
|
+
const displayNameAssignments = /* @__PURE__ */ new Set();
|
|
1773
|
+
return {
|
|
1774
|
+
CallExpression(node) {
|
|
1775
|
+
if (!isCreateContextCall(node, context)) return;
|
|
1776
|
+
contexts.add(node);
|
|
1777
|
+
},
|
|
1778
|
+
[DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
1779
|
+
displayNameAssignments.add(node);
|
|
1780
|
+
},
|
|
1781
|
+
"Program:exit"() {
|
|
1782
|
+
for (const ctx of contexts) {
|
|
1783
|
+
const id = VAR.getVariableId(ctx);
|
|
1784
|
+
if (id == null) {
|
|
1785
|
+
context.report({
|
|
1786
|
+
messageId: "noMissingContextDisplayName",
|
|
1787
|
+
node: ctx
|
|
1788
|
+
});
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
const hasDisplayNameAssignment = [...displayNameAssignments].some((node) => {
|
|
1792
|
+
const left = node.left;
|
|
1793
|
+
if (left.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
1794
|
+
const object = left.object;
|
|
1795
|
+
return VAR.isVariableIdEqual(id, object, [
|
|
1796
|
+
context.sourceCode.getScope(id),
|
|
1797
|
+
context.sourceCode.getScope(object)
|
|
1798
|
+
]);
|
|
1799
|
+
});
|
|
1800
|
+
if (!hasDisplayNameAssignment) {
|
|
1801
|
+
context.report({
|
|
1802
|
+
messageId: "noMissingContextDisplayName",
|
|
1803
|
+
node: ctx
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
},
|
|
1810
|
+
defaultOptions: []
|
|
1811
|
+
});
|
|
1812
|
+
var RULE_NAME30 = "no-missing-key";
|
|
1813
|
+
var RULE_FEATURES30 = [
|
|
1814
|
+
"CHK"
|
|
1815
|
+
];
|
|
1661
1816
|
var no_missing_key_default = createRule({
|
|
1662
1817
|
meta: {
|
|
1663
1818
|
type: "problem",
|
|
1664
1819
|
docs: {
|
|
1665
1820
|
description: "require 'key' when rendering list",
|
|
1666
|
-
[Symbol.for("rule_features")]:
|
|
1821
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1667
1822
|
},
|
|
1668
1823
|
messages: {
|
|
1669
1824
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1671,7 +1826,7 @@ var no_missing_key_default = createRule({
|
|
|
1671
1826
|
},
|
|
1672
1827
|
schema: []
|
|
1673
1828
|
},
|
|
1674
|
-
name:
|
|
1829
|
+
name: RULE_NAME30,
|
|
1675
1830
|
create(context) {
|
|
1676
1831
|
const state = { isWithinChildrenToArray: false };
|
|
1677
1832
|
function checkIteratorElement(node) {
|
|
@@ -1795,8 +1950,8 @@ var no_missing_key_default = createRule({
|
|
|
1795
1950
|
function isArrayFromCall(node) {
|
|
1796
1951
|
return node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
|
|
1797
1952
|
}
|
|
1798
|
-
var
|
|
1799
|
-
var
|
|
1953
|
+
var RULE_NAME31 = "no-nested-components";
|
|
1954
|
+
var RULE_FEATURES31 = [
|
|
1800
1955
|
"CHK"
|
|
1801
1956
|
];
|
|
1802
1957
|
var no_nested_components_default = createRule({
|
|
@@ -1804,7 +1959,7 @@ var no_nested_components_default = createRule({
|
|
|
1804
1959
|
type: "problem",
|
|
1805
1960
|
docs: {
|
|
1806
1961
|
description: "disallow using unstable nested components",
|
|
1807
|
-
[Symbol.for("rule_features")]:
|
|
1962
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1808
1963
|
},
|
|
1809
1964
|
messages: {
|
|
1810
1965
|
nestedComponent: "Do not nest components inside other components. Move it to the top level.",
|
|
@@ -1812,7 +1967,7 @@ var no_nested_components_default = createRule({
|
|
|
1812
1967
|
},
|
|
1813
1968
|
schema: []
|
|
1814
1969
|
},
|
|
1815
|
-
name:
|
|
1970
|
+
name: RULE_NAME31,
|
|
1816
1971
|
create(context) {
|
|
1817
1972
|
const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1818
1973
|
const collector = useComponentCollector(context, hint);
|
|
@@ -1833,11 +1988,11 @@ var no_nested_components_default = createRule({
|
|
|
1833
1988
|
const isClassComponent11 = (node2) => {
|
|
1834
1989
|
return AST11.isClass(node2) && classComponents.some((component) => component.node === node2);
|
|
1835
1990
|
};
|
|
1836
|
-
for (const { name:
|
|
1991
|
+
for (const { name: name5, node: component } of functionComponents) {
|
|
1837
1992
|
if (isDirectValueOfRenderPropertyLoose(component)) {
|
|
1838
1993
|
continue;
|
|
1839
1994
|
}
|
|
1840
|
-
if (
|
|
1995
|
+
if (name5 === _) {
|
|
1841
1996
|
continue;
|
|
1842
1997
|
}
|
|
1843
1998
|
const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
|
|
@@ -1848,7 +2003,7 @@ var no_nested_components_default = createRule({
|
|
|
1848
2003
|
messageId: "nestedComponentInProps",
|
|
1849
2004
|
node: component,
|
|
1850
2005
|
data: {
|
|
1851
|
-
name:
|
|
2006
|
+
name: name5
|
|
1852
2007
|
}
|
|
1853
2008
|
});
|
|
1854
2009
|
}
|
|
@@ -1859,19 +2014,19 @@ var no_nested_components_default = createRule({
|
|
|
1859
2014
|
messageId: "nestedComponentInProps",
|
|
1860
2015
|
node: component,
|
|
1861
2016
|
data: {
|
|
1862
|
-
name:
|
|
2017
|
+
name: name5
|
|
1863
2018
|
}
|
|
1864
2019
|
});
|
|
1865
2020
|
continue;
|
|
1866
2021
|
}
|
|
1867
2022
|
const parentComponent = AST11.findParentNode(component, isFunctionComponent);
|
|
1868
|
-
const
|
|
1869
|
-
if (
|
|
2023
|
+
const isParentComponentNotDirectValueOfRenderProperty = parentComponent != null && !isDirectValueOfRenderPropertyLoose(parentComponent);
|
|
2024
|
+
if (isParentComponentNotDirectValueOfRenderProperty) {
|
|
1870
2025
|
context.report({
|
|
1871
2026
|
messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
|
|
1872
2027
|
node: component,
|
|
1873
2028
|
data: {
|
|
1874
|
-
name:
|
|
2029
|
+
name: name5
|
|
1875
2030
|
}
|
|
1876
2031
|
});
|
|
1877
2032
|
continue;
|
|
@@ -1881,12 +2036,12 @@ var no_nested_components_default = createRule({
|
|
|
1881
2036
|
messageId: "nestedComponent",
|
|
1882
2037
|
node: component,
|
|
1883
2038
|
data: {
|
|
1884
|
-
name:
|
|
2039
|
+
name: name5
|
|
1885
2040
|
}
|
|
1886
2041
|
});
|
|
1887
2042
|
}
|
|
1888
2043
|
}
|
|
1889
|
-
for (const { name:
|
|
2044
|
+
for (const { name: name5 = "unknown", node: component } of classComponents) {
|
|
1890
2045
|
if (AST11.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
|
|
1891
2046
|
continue;
|
|
1892
2047
|
}
|
|
@@ -1894,7 +2049,7 @@ var no_nested_components_default = createRule({
|
|
|
1894
2049
|
messageId: "nestedComponent",
|
|
1895
2050
|
node: component,
|
|
1896
2051
|
data: {
|
|
1897
|
-
name:
|
|
2052
|
+
name: name5
|
|
1898
2053
|
}
|
|
1899
2054
|
});
|
|
1900
2055
|
}
|
|
@@ -1903,8 +2058,8 @@ var no_nested_components_default = createRule({
|
|
|
1903
2058
|
},
|
|
1904
2059
|
defaultOptions: []
|
|
1905
2060
|
});
|
|
1906
|
-
var
|
|
1907
|
-
var
|
|
2061
|
+
var RULE_NAME32 = "no-prop-types";
|
|
2062
|
+
var RULE_FEATURES32 = [
|
|
1908
2063
|
"CHK"
|
|
1909
2064
|
];
|
|
1910
2065
|
var no_prop_types_default = createRule({
|
|
@@ -1912,14 +2067,14 @@ var no_prop_types_default = createRule({
|
|
|
1912
2067
|
type: "problem",
|
|
1913
2068
|
docs: {
|
|
1914
2069
|
description: "disallow using 'propTypes' property in components",
|
|
1915
|
-
[Symbol.for("rule_features")]:
|
|
2070
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1916
2071
|
},
|
|
1917
2072
|
messages: {
|
|
1918
2073
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1919
2074
|
},
|
|
1920
2075
|
schema: []
|
|
1921
2076
|
},
|
|
1922
|
-
name:
|
|
2077
|
+
name: RULE_NAME32,
|
|
1923
2078
|
create(context) {
|
|
1924
2079
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1925
2080
|
return {};
|
|
@@ -1958,8 +2113,8 @@ var no_prop_types_default = createRule({
|
|
|
1958
2113
|
},
|
|
1959
2114
|
defaultOptions: []
|
|
1960
2115
|
});
|
|
1961
|
-
var
|
|
1962
|
-
var
|
|
2116
|
+
var RULE_NAME33 = "no-redundant-should-component-update";
|
|
2117
|
+
var RULE_FEATURES33 = [
|
|
1963
2118
|
"CHK"
|
|
1964
2119
|
];
|
|
1965
2120
|
function isShouldComponentUpdate(node) {
|
|
@@ -1970,14 +2125,14 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1970
2125
|
type: "problem",
|
|
1971
2126
|
docs: {
|
|
1972
2127
|
description: "disallow using 'shouldComponentUpdate' in class component extends 'React.PureComponent'",
|
|
1973
|
-
[Symbol.for("rule_features")]:
|
|
2128
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
1974
2129
|
},
|
|
1975
2130
|
messages: {
|
|
1976
2131
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
1977
2132
|
},
|
|
1978
2133
|
schema: []
|
|
1979
2134
|
},
|
|
1980
|
-
name:
|
|
2135
|
+
name: RULE_NAME33,
|
|
1981
2136
|
create(context) {
|
|
1982
2137
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) {
|
|
1983
2138
|
return {};
|
|
@@ -1987,7 +2142,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1987
2142
|
...listeners,
|
|
1988
2143
|
"Program:exit"(node) {
|
|
1989
2144
|
const components = ctx.getAllComponents(node);
|
|
1990
|
-
for (const { name:
|
|
2145
|
+
for (const { name: name5 = "PureComponent", node: component, flag } of components.values()) {
|
|
1991
2146
|
if ((flag & ERComponentFlag.PureComponent) === 0n) {
|
|
1992
2147
|
continue;
|
|
1993
2148
|
}
|
|
@@ -1998,7 +2153,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1998
2153
|
messageId: "noRedundantShouldComponentUpdate",
|
|
1999
2154
|
node: member,
|
|
2000
2155
|
data: {
|
|
2001
|
-
componentName:
|
|
2156
|
+
componentName: name5
|
|
2002
2157
|
}
|
|
2003
2158
|
});
|
|
2004
2159
|
}
|
|
@@ -2009,8 +2164,8 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2009
2164
|
},
|
|
2010
2165
|
defaultOptions: []
|
|
2011
2166
|
});
|
|
2012
|
-
var
|
|
2013
|
-
var
|
|
2167
|
+
var RULE_NAME34 = "no-set-state-in-component-did-mount";
|
|
2168
|
+
var RULE_FEATURES34 = [
|
|
2014
2169
|
"CHK"
|
|
2015
2170
|
];
|
|
2016
2171
|
function isComponentDidMount(node) {
|
|
@@ -2021,14 +2176,14 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2021
2176
|
type: "problem",
|
|
2022
2177
|
docs: {
|
|
2023
2178
|
description: "disallow using 'setState' in 'componentDidMount'",
|
|
2024
|
-
[Symbol.for("rule_features")]:
|
|
2179
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2025
2180
|
},
|
|
2026
2181
|
messages: {
|
|
2027
2182
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2028
2183
|
},
|
|
2029
2184
|
schema: []
|
|
2030
2185
|
},
|
|
2031
|
-
name:
|
|
2186
|
+
name: RULE_NAME34,
|
|
2032
2187
|
create(context) {
|
|
2033
2188
|
if (!context.sourceCode.text.includes("componentDidMount")) {
|
|
2034
2189
|
return {};
|
|
@@ -2054,8 +2209,8 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2054
2209
|
},
|
|
2055
2210
|
defaultOptions: []
|
|
2056
2211
|
});
|
|
2057
|
-
var
|
|
2058
|
-
var
|
|
2212
|
+
var RULE_NAME35 = "no-set-state-in-component-did-update";
|
|
2213
|
+
var RULE_FEATURES35 = [
|
|
2059
2214
|
"CHK"
|
|
2060
2215
|
];
|
|
2061
2216
|
function isComponentDidUpdate(node) {
|
|
@@ -2066,14 +2221,14 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2066
2221
|
type: "problem",
|
|
2067
2222
|
docs: {
|
|
2068
2223
|
description: "disallow using 'setState' in 'componentDidUpdate'",
|
|
2069
|
-
[Symbol.for("rule_features")]:
|
|
2224
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2070
2225
|
},
|
|
2071
2226
|
messages: {
|
|
2072
2227
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2073
2228
|
},
|
|
2074
2229
|
schema: []
|
|
2075
2230
|
},
|
|
2076
|
-
name:
|
|
2231
|
+
name: RULE_NAME35,
|
|
2077
2232
|
create(context) {
|
|
2078
2233
|
if (!context.sourceCode.text.includes("componentDidUpdate")) {
|
|
2079
2234
|
return {};
|
|
@@ -2099,8 +2254,8 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2099
2254
|
},
|
|
2100
2255
|
defaultOptions: []
|
|
2101
2256
|
});
|
|
2102
|
-
var
|
|
2103
|
-
var
|
|
2257
|
+
var RULE_NAME36 = "no-set-state-in-component-will-update";
|
|
2258
|
+
var RULE_FEATURES36 = [
|
|
2104
2259
|
"CHK"
|
|
2105
2260
|
];
|
|
2106
2261
|
function isComponentWillUpdate3(node) {
|
|
@@ -2111,14 +2266,14 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2111
2266
|
type: "problem",
|
|
2112
2267
|
docs: {
|
|
2113
2268
|
description: "disallow using 'setState' in 'componentWillUpdate'",
|
|
2114
|
-
[Symbol.for("rule_features")]:
|
|
2269
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2115
2270
|
},
|
|
2116
2271
|
messages: {
|
|
2117
2272
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2118
2273
|
},
|
|
2119
2274
|
schema: []
|
|
2120
2275
|
},
|
|
2121
|
-
name:
|
|
2276
|
+
name: RULE_NAME36,
|
|
2122
2277
|
create(context) {
|
|
2123
2278
|
if (!context.sourceCode.text.includes("componentWillUpdate")) {
|
|
2124
2279
|
return {};
|
|
@@ -2144,8 +2299,8 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2144
2299
|
},
|
|
2145
2300
|
defaultOptions: []
|
|
2146
2301
|
});
|
|
2147
|
-
var
|
|
2148
|
-
var
|
|
2302
|
+
var RULE_NAME37 = "no-string-refs";
|
|
2303
|
+
var RULE_FEATURES37 = [
|
|
2149
2304
|
"CHK"
|
|
2150
2305
|
];
|
|
2151
2306
|
function containsStringLiteral({ value }) {
|
|
@@ -2165,14 +2320,14 @@ var no_string_refs_default = createRule({
|
|
|
2165
2320
|
type: "problem",
|
|
2166
2321
|
docs: {
|
|
2167
2322
|
description: "disallow using deprecated string refs",
|
|
2168
|
-
[Symbol.for("rule_features")]:
|
|
2323
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2169
2324
|
},
|
|
2170
2325
|
messages: {
|
|
2171
2326
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2172
2327
|
},
|
|
2173
2328
|
schema: []
|
|
2174
2329
|
},
|
|
2175
|
-
name:
|
|
2330
|
+
name: RULE_NAME37,
|
|
2176
2331
|
create(context) {
|
|
2177
2332
|
return {
|
|
2178
2333
|
JSXAttribute(node) {
|
|
@@ -2190,8 +2345,8 @@ var no_string_refs_default = createRule({
|
|
|
2190
2345
|
},
|
|
2191
2346
|
defaultOptions: []
|
|
2192
2347
|
});
|
|
2193
|
-
var
|
|
2194
|
-
var
|
|
2348
|
+
var RULE_NAME38 = "no-unsafe-component-will-mount";
|
|
2349
|
+
var RULE_FEATURES38 = [
|
|
2195
2350
|
"CHK"
|
|
2196
2351
|
];
|
|
2197
2352
|
function isUnsafeComponentWillMount(node) {
|
|
@@ -2202,14 +2357,14 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2202
2357
|
type: "problem",
|
|
2203
2358
|
docs: {
|
|
2204
2359
|
description: "disallow using 'UNSAFE_componentWillMount'",
|
|
2205
|
-
[Symbol.for("rule_features")]:
|
|
2360
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2206
2361
|
},
|
|
2207
2362
|
messages: {
|
|
2208
2363
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2209
2364
|
},
|
|
2210
2365
|
schema: []
|
|
2211
2366
|
},
|
|
2212
|
-
name:
|
|
2367
|
+
name: RULE_NAME38,
|
|
2213
2368
|
create(context) {
|
|
2214
2369
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) {
|
|
2215
2370
|
return {};
|
|
@@ -2235,8 +2390,8 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2235
2390
|
},
|
|
2236
2391
|
defaultOptions: []
|
|
2237
2392
|
});
|
|
2238
|
-
var
|
|
2239
|
-
var
|
|
2393
|
+
var RULE_NAME39 = "no-unsafe-component-will-receive-props";
|
|
2394
|
+
var RULE_FEATURES39 = [
|
|
2240
2395
|
"CHK"
|
|
2241
2396
|
];
|
|
2242
2397
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
@@ -2247,14 +2402,14 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2247
2402
|
type: "problem",
|
|
2248
2403
|
docs: {
|
|
2249
2404
|
description: "disallow using 'UNSAFE_componentWillReceiveProps'",
|
|
2250
|
-
[Symbol.for("rule_features")]:
|
|
2405
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2251
2406
|
},
|
|
2252
2407
|
messages: {
|
|
2253
2408
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2254
2409
|
},
|
|
2255
2410
|
schema: []
|
|
2256
2411
|
},
|
|
2257
|
-
name:
|
|
2412
|
+
name: RULE_NAME39,
|
|
2258
2413
|
create(context) {
|
|
2259
2414
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2260
2415
|
return {};
|
|
@@ -2280,8 +2435,8 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2280
2435
|
},
|
|
2281
2436
|
defaultOptions: []
|
|
2282
2437
|
});
|
|
2283
|
-
var
|
|
2284
|
-
var
|
|
2438
|
+
var RULE_NAME40 = "no-unsafe-component-will-update";
|
|
2439
|
+
var RULE_FEATURES40 = [
|
|
2285
2440
|
"CHK"
|
|
2286
2441
|
];
|
|
2287
2442
|
function isUnsafeComponentWillUpdate(node) {
|
|
@@ -2292,14 +2447,14 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2292
2447
|
type: "problem",
|
|
2293
2448
|
docs: {
|
|
2294
2449
|
description: "disallow using 'UNSAFE_componentWillUpdate'",
|
|
2295
|
-
[Symbol.for("rule_features")]:
|
|
2450
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2296
2451
|
},
|
|
2297
2452
|
messages: {
|
|
2298
2453
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2299
2454
|
},
|
|
2300
2455
|
schema: []
|
|
2301
2456
|
},
|
|
2302
|
-
name:
|
|
2457
|
+
name: RULE_NAME40,
|
|
2303
2458
|
create(context) {
|
|
2304
2459
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) {
|
|
2305
2460
|
return {};
|
|
@@ -2325,8 +2480,8 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2325
2480
|
},
|
|
2326
2481
|
defaultOptions: []
|
|
2327
2482
|
});
|
|
2328
|
-
var
|
|
2329
|
-
var
|
|
2483
|
+
var RULE_NAME41 = "no-unstable-context-value";
|
|
2484
|
+
var RULE_FEATURES41 = [
|
|
2330
2485
|
"CHK"
|
|
2331
2486
|
];
|
|
2332
2487
|
var no_unstable_context_value_default = createRule({
|
|
@@ -2334,14 +2489,14 @@ var no_unstable_context_value_default = createRule({
|
|
|
2334
2489
|
type: "problem",
|
|
2335
2490
|
docs: {
|
|
2336
2491
|
description: "disallow passing constructed values to context providers",
|
|
2337
|
-
[Symbol.for("rule_features")]:
|
|
2492
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2338
2493
|
},
|
|
2339
2494
|
messages: {
|
|
2340
2495
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2341
2496
|
},
|
|
2342
2497
|
schema: []
|
|
2343
2498
|
},
|
|
2344
|
-
name:
|
|
2499
|
+
name: RULE_NAME41,
|
|
2345
2500
|
create(context) {
|
|
2346
2501
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2347
2502
|
const constructions = /* @__PURE__ */ new Map();
|
|
@@ -2393,8 +2548,8 @@ var no_unstable_context_value_default = createRule({
|
|
|
2393
2548
|
},
|
|
2394
2549
|
defaultOptions: []
|
|
2395
2550
|
});
|
|
2396
|
-
var
|
|
2397
|
-
var
|
|
2551
|
+
var RULE_NAME42 = "no-unstable-default-props";
|
|
2552
|
+
var RULE_FEATURES42 = [
|
|
2398
2553
|
"CHK"
|
|
2399
2554
|
];
|
|
2400
2555
|
var no_unstable_default_props_default = createRule({
|
|
@@ -2402,14 +2557,14 @@ var no_unstable_default_props_default = createRule({
|
|
|
2402
2557
|
type: "problem",
|
|
2403
2558
|
docs: {
|
|
2404
2559
|
description: "disallow using unstable value as default param in function component",
|
|
2405
|
-
[Symbol.for("rule_features")]:
|
|
2560
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2406
2561
|
},
|
|
2407
2562
|
messages: {
|
|
2408
2563
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2409
2564
|
},
|
|
2410
2565
|
schema: []
|
|
2411
2566
|
},
|
|
2412
|
-
name:
|
|
2567
|
+
name: RULE_NAME42,
|
|
2413
2568
|
create(context) {
|
|
2414
2569
|
const { ctx, listeners } = useComponentCollector(context);
|
|
2415
2570
|
const declarators = /* @__PURE__ */ new Map();
|
|
@@ -2423,8 +2578,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
2423
2578
|
if (props == null) {
|
|
2424
2579
|
continue;
|
|
2425
2580
|
}
|
|
2426
|
-
const properties = match(props).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: AST_NODE_TYPES.Identifier }, ({ name:
|
|
2427
|
-
return declarators.get(component)?.filter((d) => d.init.name ===
|
|
2581
|
+
const properties = match(props).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name5 }) => {
|
|
2582
|
+
return declarators.get(component)?.filter((d) => d.init.name === name5).flatMap((d) => d.id.properties) ?? [];
|
|
2428
2583
|
}).otherwise(() => []);
|
|
2429
2584
|
for (const prop of properties) {
|
|
2430
2585
|
if (prop.type !== AST_NODE_TYPES.Property || prop.value.type !== AST_NODE_TYPES.AssignmentPattern) {
|
|
@@ -2468,8 +2623,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
2468
2623
|
},
|
|
2469
2624
|
defaultOptions: []
|
|
2470
2625
|
});
|
|
2471
|
-
var
|
|
2472
|
-
var
|
|
2626
|
+
var RULE_NAME43 = "no-unused-class-component-members";
|
|
2627
|
+
var RULE_FEATURES43 = [
|
|
2473
2628
|
"CHK"
|
|
2474
2629
|
];
|
|
2475
2630
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -2509,14 +2664,14 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2509
2664
|
type: "problem",
|
|
2510
2665
|
docs: {
|
|
2511
2666
|
description: "disallow unused class component members",
|
|
2512
|
-
[Symbol.for("rule_features")]:
|
|
2667
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2513
2668
|
},
|
|
2514
2669
|
messages: {
|
|
2515
2670
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2516
2671
|
},
|
|
2517
2672
|
schema: []
|
|
2518
2673
|
},
|
|
2519
|
-
name:
|
|
2674
|
+
name: RULE_NAME43,
|
|
2520
2675
|
create(context) {
|
|
2521
2676
|
const classEntries = [];
|
|
2522
2677
|
const methodEntries = [];
|
|
@@ -2629,8 +2784,8 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2629
2784
|
},
|
|
2630
2785
|
defaultOptions: []
|
|
2631
2786
|
});
|
|
2632
|
-
var
|
|
2633
|
-
var
|
|
2787
|
+
var RULE_NAME44 = "no-unused-state";
|
|
2788
|
+
var RULE_FEATURES44 = [
|
|
2634
2789
|
"CHK"
|
|
2635
2790
|
];
|
|
2636
2791
|
function getName4(node) {
|
|
@@ -2657,14 +2812,14 @@ var no_unused_state_default = createRule({
|
|
|
2657
2812
|
type: "problem",
|
|
2658
2813
|
docs: {
|
|
2659
2814
|
description: "disallow unused state of class component",
|
|
2660
|
-
[Symbol.for("rule_features")]:
|
|
2815
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2661
2816
|
},
|
|
2662
2817
|
messages: {
|
|
2663
2818
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2664
2819
|
},
|
|
2665
2820
|
schema: []
|
|
2666
2821
|
},
|
|
2667
|
-
name:
|
|
2822
|
+
name: RULE_NAME44,
|
|
2668
2823
|
create(context) {
|
|
2669
2824
|
const classEntries = [];
|
|
2670
2825
|
const methodEntries = [];
|
|
@@ -2782,7 +2937,7 @@ var no_unused_state_default = createRule({
|
|
|
2782
2937
|
if (!currentClass.body.body.includes(currentMethod)) {
|
|
2783
2938
|
return;
|
|
2784
2939
|
}
|
|
2785
|
-
if (
|
|
2940
|
+
if (node.init == null || !AST11.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) {
|
|
2786
2941
|
return;
|
|
2787
2942
|
}
|
|
2788
2943
|
const hasState = node.id.properties.some((prop) => {
|
|
@@ -2801,8 +2956,8 @@ var no_unused_state_default = createRule({
|
|
|
2801
2956
|
},
|
|
2802
2957
|
defaultOptions: []
|
|
2803
2958
|
});
|
|
2804
|
-
var
|
|
2805
|
-
var
|
|
2959
|
+
var RULE_NAME45 = "no-use-context";
|
|
2960
|
+
var RULE_FEATURES45 = [
|
|
2806
2961
|
"CHK",
|
|
2807
2962
|
"MOD"
|
|
2808
2963
|
];
|
|
@@ -2811,7 +2966,7 @@ var no_use_context_default = createRule({
|
|
|
2811
2966
|
type: "problem",
|
|
2812
2967
|
docs: {
|
|
2813
2968
|
description: "disallow the use of 'useContext'",
|
|
2814
|
-
[Symbol.for("rule_features")]:
|
|
2969
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2815
2970
|
},
|
|
2816
2971
|
fixable: "code",
|
|
2817
2972
|
messages: {
|
|
@@ -2819,12 +2974,12 @@ var no_use_context_default = createRule({
|
|
|
2819
2974
|
},
|
|
2820
2975
|
schema: []
|
|
2821
2976
|
},
|
|
2822
|
-
name:
|
|
2977
|
+
name: RULE_NAME45,
|
|
2823
2978
|
create(context) {
|
|
2824
2979
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2825
|
-
const
|
|
2980
|
+
const settings4 = getSettingsFromContext(context);
|
|
2826
2981
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
2827
|
-
if (compare(
|
|
2982
|
+
if (compare(settings4.version, "19.0.0", "<")) {
|
|
2828
2983
|
return {};
|
|
2829
2984
|
}
|
|
2830
2985
|
return {
|
|
@@ -2850,7 +3005,7 @@ var no_use_context_default = createRule({
|
|
|
2850
3005
|
});
|
|
2851
3006
|
},
|
|
2852
3007
|
ImportDeclaration(node) {
|
|
2853
|
-
if (node.source.value !==
|
|
3008
|
+
if (node.source.value !== settings4.importSource) {
|
|
2854
3009
|
return;
|
|
2855
3010
|
}
|
|
2856
3011
|
const isUseImported = node.specifiers.some(isMatching({ local: { type: AST_NODE_TYPES.Identifier, name: "use" } }));
|
|
@@ -2886,7 +3041,7 @@ var no_use_context_default = createRule({
|
|
|
2886
3041
|
},
|
|
2887
3042
|
defaultOptions: []
|
|
2888
3043
|
});
|
|
2889
|
-
var
|
|
3044
|
+
var RULE_NAME46 = "no-useless-fragment";
|
|
2890
3045
|
var defaultOptions = [{
|
|
2891
3046
|
allowExpressions: true
|
|
2892
3047
|
}];
|
|
@@ -2899,7 +3054,7 @@ function trimLikeReact(text) {
|
|
|
2899
3054
|
}
|
|
2900
3055
|
function checkAndReport(node, context, allowExpressions) {
|
|
2901
3056
|
function fix(fixer) {
|
|
2902
|
-
if (
|
|
3057
|
+
if (node.parent.type !== AST_NODE_TYPES.JSXElement && node.parent.type !== AST_NODE_TYPES.JSXFragment) {
|
|
2903
3058
|
if (node.children.length === 0) {
|
|
2904
3059
|
return null;
|
|
2905
3060
|
}
|
|
@@ -3012,7 +3167,7 @@ var no_useless_fragment_default = createRule({
|
|
|
3012
3167
|
}
|
|
3013
3168
|
}]
|
|
3014
3169
|
},
|
|
3015
|
-
name:
|
|
3170
|
+
name: RULE_NAME46,
|
|
3016
3171
|
create(context, [option]) {
|
|
3017
3172
|
const { allowExpressions = true } = option;
|
|
3018
3173
|
return {
|
|
@@ -3027,8 +3182,8 @@ var no_useless_fragment_default = createRule({
|
|
|
3027
3182
|
},
|
|
3028
3183
|
defaultOptions
|
|
3029
3184
|
});
|
|
3030
|
-
var
|
|
3031
|
-
var
|
|
3185
|
+
var RULE_NAME47 = "prefer-destructuring-assignment";
|
|
3186
|
+
var RULE_FEATURES46 = [
|
|
3032
3187
|
"CHK"
|
|
3033
3188
|
];
|
|
3034
3189
|
function isMemberExpressionWithObjectName(node) {
|
|
@@ -3039,14 +3194,14 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3039
3194
|
type: "problem",
|
|
3040
3195
|
docs: {
|
|
3041
3196
|
description: "enforce using destructuring assignment in component props and context",
|
|
3042
|
-
[Symbol.for("rule_features")]:
|
|
3197
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
3043
3198
|
},
|
|
3044
3199
|
messages: {
|
|
3045
3200
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3046
3201
|
},
|
|
3047
3202
|
schema: []
|
|
3048
3203
|
},
|
|
3049
|
-
name:
|
|
3204
|
+
name: RULE_NAME47,
|
|
3050
3205
|
create(context) {
|
|
3051
3206
|
const { ctx, listeners } = useComponentCollector(context);
|
|
3052
3207
|
const memberExpressionWithNames = [];
|
|
@@ -3109,8 +3264,8 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3109
3264
|
},
|
|
3110
3265
|
defaultOptions: []
|
|
3111
3266
|
});
|
|
3112
|
-
var
|
|
3113
|
-
var
|
|
3267
|
+
var RULE_NAME48 = "prefer-react-namespace-import";
|
|
3268
|
+
var RULE_FEATURES47 = [
|
|
3114
3269
|
"CHK",
|
|
3115
3270
|
"FIX"
|
|
3116
3271
|
];
|
|
@@ -3119,7 +3274,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3119
3274
|
type: "problem",
|
|
3120
3275
|
docs: {
|
|
3121
3276
|
description: "enforce React is imported via a namespace import",
|
|
3122
|
-
[Symbol.for("rule_features")]:
|
|
3277
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
3123
3278
|
},
|
|
3124
3279
|
fixable: "code",
|
|
3125
3280
|
messages: {
|
|
@@ -3127,7 +3282,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3127
3282
|
},
|
|
3128
3283
|
schema: []
|
|
3129
3284
|
},
|
|
3130
|
-
name:
|
|
3285
|
+
name: RULE_NAME48,
|
|
3131
3286
|
create(context) {
|
|
3132
3287
|
const { importSource } = getSettingsFromContext(context);
|
|
3133
3288
|
return {
|
|
@@ -3163,8 +3318,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3163
3318
|
},
|
|
3164
3319
|
defaultOptions: []
|
|
3165
3320
|
});
|
|
3166
|
-
var
|
|
3167
|
-
var
|
|
3321
|
+
var RULE_NAME49 = "prefer-read-only-props";
|
|
3322
|
+
var RULE_FEATURES48 = [
|
|
3168
3323
|
"CHK",
|
|
3169
3324
|
"TSC"
|
|
3170
3325
|
];
|
|
@@ -3181,14 +3336,14 @@ var prefer_read_only_props_default = createRule({
|
|
|
3181
3336
|
type: "problem",
|
|
3182
3337
|
docs: {
|
|
3183
3338
|
description: "enforce read-only props in components",
|
|
3184
|
-
[Symbol.for("rule_features")]:
|
|
3339
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3185
3340
|
},
|
|
3186
3341
|
messages: {
|
|
3187
3342
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3188
3343
|
},
|
|
3189
3344
|
schema: []
|
|
3190
3345
|
},
|
|
3191
|
-
name:
|
|
3346
|
+
name: RULE_NAME49,
|
|
3192
3347
|
create(context) {
|
|
3193
3348
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3194
3349
|
const { ctx, listeners } = useComponentCollector(context);
|
|
@@ -3212,8 +3367,8 @@ var prefer_read_only_props_default = createRule({
|
|
|
3212
3367
|
},
|
|
3213
3368
|
defaultOptions: []
|
|
3214
3369
|
});
|
|
3215
|
-
var
|
|
3216
|
-
var
|
|
3370
|
+
var RULE_NAME50 = "prefer-shorthand-boolean";
|
|
3371
|
+
var RULE_FEATURES49 = [
|
|
3217
3372
|
"CHK",
|
|
3218
3373
|
"FIX"
|
|
3219
3374
|
];
|
|
@@ -3222,7 +3377,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3222
3377
|
type: "problem",
|
|
3223
3378
|
docs: {
|
|
3224
3379
|
description: "enforce using shorthand boolean attributes",
|
|
3225
|
-
[Symbol.for("rule_features")]:
|
|
3380
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3226
3381
|
},
|
|
3227
3382
|
fixable: "code",
|
|
3228
3383
|
messages: {
|
|
@@ -3230,7 +3385,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3230
3385
|
},
|
|
3231
3386
|
schema: []
|
|
3232
3387
|
},
|
|
3233
|
-
name:
|
|
3388
|
+
name: RULE_NAME50,
|
|
3234
3389
|
create(context) {
|
|
3235
3390
|
return {
|
|
3236
3391
|
JSXAttribute(node) {
|
|
@@ -3253,8 +3408,8 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3253
3408
|
},
|
|
3254
3409
|
defaultOptions: []
|
|
3255
3410
|
});
|
|
3256
|
-
var
|
|
3257
|
-
var
|
|
3411
|
+
var RULE_NAME51 = "prefer-shorthand-fragment";
|
|
3412
|
+
var RULE_FEATURES50 = [
|
|
3258
3413
|
"CHK",
|
|
3259
3414
|
"FIX"
|
|
3260
3415
|
];
|
|
@@ -3263,7 +3418,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3263
3418
|
type: "problem",
|
|
3264
3419
|
docs: {
|
|
3265
3420
|
description: "enforce using fragment syntax instead of 'Fragment' component",
|
|
3266
|
-
[Symbol.for("rule_features")]:
|
|
3421
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3267
3422
|
},
|
|
3268
3423
|
fixable: "code",
|
|
3269
3424
|
messages: {
|
|
@@ -3271,7 +3426,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3271
3426
|
},
|
|
3272
3427
|
schema: []
|
|
3273
3428
|
},
|
|
3274
|
-
name:
|
|
3429
|
+
name: RULE_NAME51,
|
|
3275
3430
|
create(context) {
|
|
3276
3431
|
return {
|
|
3277
3432
|
JSXElement(node) {
|
|
@@ -3299,21 +3454,21 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3299
3454
|
},
|
|
3300
3455
|
defaultOptions: []
|
|
3301
3456
|
});
|
|
3302
|
-
var
|
|
3303
|
-
var
|
|
3457
|
+
var RULE_NAME52 = "use-jsx-vars";
|
|
3458
|
+
var RULE_FEATURES51 = [];
|
|
3304
3459
|
var use_jsx_vars_default = createRule({
|
|
3305
3460
|
meta: {
|
|
3306
3461
|
type: "problem",
|
|
3307
3462
|
docs: {
|
|
3308
|
-
description: "
|
|
3309
|
-
[Symbol.for("rule_features")]:
|
|
3463
|
+
description: "marks variables used in JSX as used",
|
|
3464
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3310
3465
|
},
|
|
3311
3466
|
messages: {
|
|
3312
3467
|
useJsxVars: ""
|
|
3313
3468
|
},
|
|
3314
3469
|
schema: []
|
|
3315
3470
|
},
|
|
3316
|
-
name:
|
|
3471
|
+
name: RULE_NAME52,
|
|
3317
3472
|
create(context) {
|
|
3318
3473
|
return {
|
|
3319
3474
|
JSXOpeningElement(node) {
|
|
@@ -3339,10 +3494,10 @@ var use_jsx_vars_default = createRule({
|
|
|
3339
3494
|
defaultOptions: []
|
|
3340
3495
|
});
|
|
3341
3496
|
|
|
3342
|
-
// src/
|
|
3343
|
-
var
|
|
3497
|
+
// src/plugin.ts
|
|
3498
|
+
var plugin = {
|
|
3344
3499
|
meta: {
|
|
3345
|
-
name,
|
|
3500
|
+
name: name4,
|
|
3346
3501
|
version
|
|
3347
3502
|
},
|
|
3348
3503
|
rules: {
|
|
@@ -3374,6 +3529,7 @@ var index_default = {
|
|
|
3374
3529
|
"no-implicit-key": no_implicit_key_default,
|
|
3375
3530
|
"no-leaked-conditional-rendering": no_leaked_conditional_rendering_default,
|
|
3376
3531
|
"no-missing-component-display-name": no_missing_component_display_name_default,
|
|
3532
|
+
"no-missing-context-display-name": no_missing_context_display_name_default,
|
|
3377
3533
|
"no-missing-key": no_missing_key_default,
|
|
3378
3534
|
"no-nested-components": no_nested_components_default,
|
|
3379
3535
|
"no-prop-types": no_prop_types_default,
|
|
@@ -3407,4 +3563,31 @@ var index_default = {
|
|
|
3407
3563
|
}
|
|
3408
3564
|
};
|
|
3409
3565
|
|
|
3566
|
+
// src/index.ts
|
|
3567
|
+
function makeConfig(config) {
|
|
3568
|
+
return {
|
|
3569
|
+
...config,
|
|
3570
|
+
plugins: {
|
|
3571
|
+
"react-x": plugin
|
|
3572
|
+
}
|
|
3573
|
+
};
|
|
3574
|
+
}
|
|
3575
|
+
function makeLegacyConfig({ rules: rules4 }) {
|
|
3576
|
+
return {
|
|
3577
|
+
plugins: ["react-x"],
|
|
3578
|
+
rules: rules4
|
|
3579
|
+
};
|
|
3580
|
+
}
|
|
3581
|
+
var index_default = {
|
|
3582
|
+
...plugin,
|
|
3583
|
+
configs: {
|
|
3584
|
+
["recommended"]: makeConfig(recommended_exports),
|
|
3585
|
+
["recommended-legacy"]: makeLegacyConfig(recommended_exports),
|
|
3586
|
+
["recommended-type-checked"]: makeConfig(recommended_type_checked_exports),
|
|
3587
|
+
["recommended-type-checked-legacy"]: makeLegacyConfig(recommended_type_checked_exports),
|
|
3588
|
+
["recommended-typescript"]: makeConfig(recommended_typescript_exports),
|
|
3589
|
+
["recommended-typescript-legacy"]: makeLegacyConfig(recommended_typescript_exports)
|
|
3590
|
+
}
|
|
3591
|
+
};
|
|
3592
|
+
|
|
3410
3593
|
export { index_default as default };
|