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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var JSX7 = require('@eslint-react/jsx');
|
|
4
3
|
var shared = require('@eslint-react/shared');
|
|
4
|
+
var JSX7 = require('@eslint-react/jsx');
|
|
5
5
|
var AST11 = require('@eslint-react/ast');
|
|
6
6
|
var core = require('@eslint-react/core');
|
|
7
7
|
var eff = require('@eslint-react/eff');
|
|
@@ -40,9 +40,104 @@ var AST11__namespace = /*#__PURE__*/_interopNamespace(AST11);
|
|
|
40
40
|
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
41
41
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
42
42
|
|
|
43
|
+
var __defProp = Object.defineProperty;
|
|
44
|
+
var __export = (target, all) => {
|
|
45
|
+
for (var name5 in all)
|
|
46
|
+
__defProp(target, name5, { get: all[name5], enumerable: true });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/configs/recommended.ts
|
|
50
|
+
var recommended_exports = {};
|
|
51
|
+
__export(recommended_exports, {
|
|
52
|
+
name: () => name,
|
|
53
|
+
rules: () => rules,
|
|
54
|
+
settings: () => settings
|
|
55
|
+
});
|
|
56
|
+
var name = "react-x/recommended";
|
|
57
|
+
var rules = {
|
|
58
|
+
"react-x/ensure-forward-ref-using-ref": "warn",
|
|
59
|
+
"react-x/no-access-state-in-setstate": "error",
|
|
60
|
+
"react-x/no-array-index-key": "warn",
|
|
61
|
+
"react-x/no-children-count": "warn",
|
|
62
|
+
"react-x/no-children-for-each": "warn",
|
|
63
|
+
"react-x/no-children-map": "warn",
|
|
64
|
+
"react-x/no-children-only": "warn",
|
|
65
|
+
"react-x/no-children-to-array": "warn",
|
|
66
|
+
"react-x/no-clone-element": "warn",
|
|
67
|
+
"react-x/no-comment-textnodes": "warn",
|
|
68
|
+
"react-x/no-component-will-mount": "error",
|
|
69
|
+
"react-x/no-component-will-receive-props": "error",
|
|
70
|
+
"react-x/no-component-will-update": "error",
|
|
71
|
+
"react-x/no-context-provider": "warn",
|
|
72
|
+
"react-x/no-create-ref": "error",
|
|
73
|
+
"react-x/no-default-props": "error",
|
|
74
|
+
"react-x/no-direct-mutation-state": "error",
|
|
75
|
+
"react-x/no-duplicate-jsx-props": "warn",
|
|
76
|
+
"react-x/no-duplicate-key": "warn",
|
|
77
|
+
"react-x/no-forward-ref": "warn",
|
|
78
|
+
"react-x/no-implicit-key": "warn",
|
|
79
|
+
"react-x/no-missing-key": "error",
|
|
80
|
+
"react-x/no-nested-components": "error",
|
|
81
|
+
"react-x/no-prop-types": "error",
|
|
82
|
+
"react-x/no-redundant-should-component-update": "error",
|
|
83
|
+
"react-x/no-set-state-in-component-did-mount": "warn",
|
|
84
|
+
"react-x/no-set-state-in-component-did-update": "warn",
|
|
85
|
+
"react-x/no-set-state-in-component-will-update": "warn",
|
|
86
|
+
"react-x/no-string-refs": "error",
|
|
87
|
+
"react-x/no-unsafe-component-will-mount": "warn",
|
|
88
|
+
"react-x/no-unsafe-component-will-receive-props": "warn",
|
|
89
|
+
"react-x/no-unsafe-component-will-update": "warn",
|
|
90
|
+
"react-x/no-unstable-context-value": "warn",
|
|
91
|
+
"react-x/no-unstable-default-props": "warn",
|
|
92
|
+
"react-x/no-unused-class-component-members": "warn",
|
|
93
|
+
"react-x/no-unused-state": "warn",
|
|
94
|
+
"react-x/no-use-context": "warn",
|
|
95
|
+
"react-x/use-jsx-vars": "warn"
|
|
96
|
+
};
|
|
97
|
+
var settings = {
|
|
98
|
+
"react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/configs/recommended-type-checked.ts
|
|
102
|
+
var recommended_type_checked_exports = {};
|
|
103
|
+
__export(recommended_type_checked_exports, {
|
|
104
|
+
name: () => name3,
|
|
105
|
+
rules: () => rules3,
|
|
106
|
+
settings: () => settings3
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// src/configs/recommended-typescript.ts
|
|
110
|
+
var recommended_typescript_exports = {};
|
|
111
|
+
__export(recommended_typescript_exports, {
|
|
112
|
+
name: () => name2,
|
|
113
|
+
rules: () => rules2,
|
|
114
|
+
settings: () => settings2
|
|
115
|
+
});
|
|
116
|
+
var name2 = "react-x/recommended-typescript";
|
|
117
|
+
var rules2 = {
|
|
118
|
+
...rules,
|
|
119
|
+
"react-x/dom/no-unknown-property": "off",
|
|
120
|
+
"react-x/no-duplicate-jsx-props": "off",
|
|
121
|
+
"react-x/use-jsx-vars": "off"
|
|
122
|
+
};
|
|
123
|
+
var settings2 = {
|
|
124
|
+
...settings
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/configs/recommended-type-checked.ts
|
|
128
|
+
var name3 = "react-x/recommended-type-checked";
|
|
129
|
+
var rules3 = {
|
|
130
|
+
...rules2,
|
|
131
|
+
"react-x/no-leaked-conditional-rendering": "warn"
|
|
132
|
+
// "react-x/prefer-read-only-props": "warn",
|
|
133
|
+
};
|
|
134
|
+
var settings3 = {
|
|
135
|
+
...settings2
|
|
136
|
+
};
|
|
137
|
+
|
|
43
138
|
// package.json
|
|
44
|
-
var
|
|
45
|
-
var version = "1.
|
|
139
|
+
var name4 = "eslint-plugin-react-x";
|
|
140
|
+
var version = "1.27.0-beta.1";
|
|
46
141
|
var createRule = shared.createRuleForPlugin("x");
|
|
47
142
|
|
|
48
143
|
// src/utils/get-associated-tokens.ts
|
|
@@ -279,7 +374,7 @@ var no_access_state_in_setstate_default = createRule({
|
|
|
279
374
|
if (setState == null || hasThisState) {
|
|
280
375
|
return;
|
|
281
376
|
}
|
|
282
|
-
if (
|
|
377
|
+
if (node.init == null || !AST11__namespace.isThisExpression(node.init) || node.id.type !== types.AST_NODE_TYPES.ObjectPattern) {
|
|
283
378
|
return;
|
|
284
379
|
}
|
|
285
380
|
const hasState = node.id.properties.some(
|
|
@@ -313,8 +408,8 @@ var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
|
313
408
|
["reduceRight", 2],
|
|
314
409
|
["some", 1]
|
|
315
410
|
]);
|
|
316
|
-
function isReactChildrenMethod(
|
|
317
|
-
return reactChildrenMethod.some((method) => method ===
|
|
411
|
+
function isReactChildrenMethod(name5) {
|
|
412
|
+
return reactChildrenMethod.some((method) => method === name5);
|
|
318
413
|
}
|
|
319
414
|
function isUsingReactChildren(node, context) {
|
|
320
415
|
const { importSource = "react" } = shared.unsafeDecodeSettings(context.settings);
|
|
@@ -342,8 +437,8 @@ function getMapIndexParamName(node, context) {
|
|
|
342
437
|
if (callee.property.type !== types.AST_NODE_TYPES.Identifier) {
|
|
343
438
|
return eff._;
|
|
344
439
|
}
|
|
345
|
-
const { name:
|
|
346
|
-
if (!iteratorFunctionIndexParamPosition.has(
|
|
440
|
+
const { name: name5 } = callee.property;
|
|
441
|
+
if (!iteratorFunctionIndexParamPosition.has(name5)) {
|
|
347
442
|
return eff._;
|
|
348
443
|
}
|
|
349
444
|
const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0];
|
|
@@ -354,7 +449,7 @@ function getMapIndexParamName(node, context) {
|
|
|
354
449
|
return eff._;
|
|
355
450
|
}
|
|
356
451
|
const { params } = callbackArg;
|
|
357
|
-
const indexParamPosition = iteratorFunctionIndexParamPosition.get(
|
|
452
|
+
const indexParamPosition = iteratorFunctionIndexParamPosition.get(name5);
|
|
358
453
|
if (indexParamPosition == null) {
|
|
359
454
|
return eff._;
|
|
360
455
|
}
|
|
@@ -380,7 +475,7 @@ var no_array_index_key_default = createRule({
|
|
|
380
475
|
create(context) {
|
|
381
476
|
const indexParamNames = [];
|
|
382
477
|
function isArrayIndex(node) {
|
|
383
|
-
return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((
|
|
478
|
+
return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
|
|
384
479
|
}
|
|
385
480
|
function isCreateOrCloneElementCall(node) {
|
|
386
481
|
return core.isCreateElementCall(node, context) || core.isCloneElementCall(node, context);
|
|
@@ -389,7 +484,7 @@ var no_array_index_key_default = createRule({
|
|
|
389
484
|
switch (node.type) {
|
|
390
485
|
// key={bar}
|
|
391
486
|
case types.AST_NODE_TYPES.Identifier: {
|
|
392
|
-
if (indexParamNames.some((
|
|
487
|
+
if (indexParamNames.some((name5) => name5 != null && name5 === node.name)) {
|
|
393
488
|
return [{
|
|
394
489
|
messageId: "noArrayIndexKey",
|
|
395
490
|
node
|
|
@@ -699,7 +794,7 @@ var no_class_component_default = createRule({
|
|
|
699
794
|
...listeners,
|
|
700
795
|
"Program:exit"(node) {
|
|
701
796
|
const components = ctx.getAllComponents(node);
|
|
702
|
-
for (const { name:
|
|
797
|
+
for (const { name: name5 = "anonymous", node: component } of components.values()) {
|
|
703
798
|
if (component.body.body.some((m) => core.isComponentDidCatch(m) || core.isGetDerivedStateFromError(m))) {
|
|
704
799
|
continue;
|
|
705
800
|
}
|
|
@@ -707,7 +802,7 @@ var no_class_component_default = createRule({
|
|
|
707
802
|
messageId: "noClassComponent",
|
|
708
803
|
node: component,
|
|
709
804
|
data: {
|
|
710
|
-
name:
|
|
805
|
+
name: name5
|
|
711
806
|
}
|
|
712
807
|
});
|
|
713
808
|
}
|
|
@@ -1025,8 +1120,8 @@ var no_context_provider_default = createRule({
|
|
|
1025
1120
|
}
|
|
1026
1121
|
return {
|
|
1027
1122
|
JSXElement(node) {
|
|
1028
|
-
const [
|
|
1029
|
-
if (
|
|
1123
|
+
const [name5, ...rest] = JSX7__namespace.getElementName(node).split(".").reverse();
|
|
1124
|
+
if (name5 !== "Provider") return;
|
|
1030
1125
|
const contextName = rest.reverse().join(".");
|
|
1031
1126
|
context.report({
|
|
1032
1127
|
messageId: "noContextProvider",
|
|
@@ -1223,12 +1318,12 @@ var no_duplicate_jsx_props_default = createRule({
|
|
|
1223
1318
|
if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1224
1319
|
continue;
|
|
1225
1320
|
}
|
|
1226
|
-
const
|
|
1227
|
-
if (typeof
|
|
1321
|
+
const name5 = attr.name.name;
|
|
1322
|
+
if (typeof name5 !== "string") {
|
|
1228
1323
|
continue;
|
|
1229
1324
|
}
|
|
1230
|
-
if (!props.includes(
|
|
1231
|
-
props.push(
|
|
1325
|
+
if (!props.includes(name5)) {
|
|
1326
|
+
props.push(name5);
|
|
1232
1327
|
continue;
|
|
1233
1328
|
}
|
|
1234
1329
|
context.report({
|
|
@@ -1681,16 +1776,76 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1681
1776
|
},
|
|
1682
1777
|
defaultOptions: []
|
|
1683
1778
|
});
|
|
1684
|
-
var RULE_NAME29 = "no-missing-
|
|
1779
|
+
var RULE_NAME29 = "no-missing-context-display-name";
|
|
1685
1780
|
var RULE_FEATURES29 = [
|
|
1686
1781
|
"CHK"
|
|
1687
1782
|
];
|
|
1783
|
+
var no_missing_context_display_name_default = createRule({
|
|
1784
|
+
meta: {
|
|
1785
|
+
type: "problem",
|
|
1786
|
+
docs: {
|
|
1787
|
+
description: "require 'displayName' for contexts.",
|
|
1788
|
+
[Symbol.for("rule_features")]: RULE_FEATURES29
|
|
1789
|
+
},
|
|
1790
|
+
messages: {
|
|
1791
|
+
noMissingContextDisplayName: "Add missing 'displayName' for context."
|
|
1792
|
+
},
|
|
1793
|
+
schema: []
|
|
1794
|
+
},
|
|
1795
|
+
name: RULE_NAME29,
|
|
1796
|
+
create(context) {
|
|
1797
|
+
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
1798
|
+
const contexts = /* @__PURE__ */ new Set();
|
|
1799
|
+
const displayNameAssignments = /* @__PURE__ */ new Set();
|
|
1800
|
+
return {
|
|
1801
|
+
CallExpression(node) {
|
|
1802
|
+
if (!core.isCreateContextCall(node, context)) return;
|
|
1803
|
+
contexts.add(node);
|
|
1804
|
+
},
|
|
1805
|
+
[core.DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
1806
|
+
displayNameAssignments.add(node);
|
|
1807
|
+
},
|
|
1808
|
+
"Program:exit"() {
|
|
1809
|
+
for (const ctx of contexts) {
|
|
1810
|
+
const id = VAR__namespace.getVariableId(ctx);
|
|
1811
|
+
if (id == null) {
|
|
1812
|
+
context.report({
|
|
1813
|
+
messageId: "noMissingContextDisplayName",
|
|
1814
|
+
node: ctx
|
|
1815
|
+
});
|
|
1816
|
+
continue;
|
|
1817
|
+
}
|
|
1818
|
+
const hasDisplayNameAssignment = [...displayNameAssignments].some((node) => {
|
|
1819
|
+
const left = node.left;
|
|
1820
|
+
if (left.type !== types.AST_NODE_TYPES.MemberExpression) return false;
|
|
1821
|
+
const object = left.object;
|
|
1822
|
+
return VAR__namespace.isVariableIdEqual(id, object, [
|
|
1823
|
+
context.sourceCode.getScope(id),
|
|
1824
|
+
context.sourceCode.getScope(object)
|
|
1825
|
+
]);
|
|
1826
|
+
});
|
|
1827
|
+
if (!hasDisplayNameAssignment) {
|
|
1828
|
+
context.report({
|
|
1829
|
+
messageId: "noMissingContextDisplayName",
|
|
1830
|
+
node: ctx
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
};
|
|
1836
|
+
},
|
|
1837
|
+
defaultOptions: []
|
|
1838
|
+
});
|
|
1839
|
+
var RULE_NAME30 = "no-missing-key";
|
|
1840
|
+
var RULE_FEATURES30 = [
|
|
1841
|
+
"CHK"
|
|
1842
|
+
];
|
|
1688
1843
|
var no_missing_key_default = createRule({
|
|
1689
1844
|
meta: {
|
|
1690
1845
|
type: "problem",
|
|
1691
1846
|
docs: {
|
|
1692
1847
|
description: "require 'key' when rendering list",
|
|
1693
|
-
[Symbol.for("rule_features")]:
|
|
1848
|
+
[Symbol.for("rule_features")]: RULE_FEATURES30
|
|
1694
1849
|
},
|
|
1695
1850
|
messages: {
|
|
1696
1851
|
missingKey: "Missing 'key' for element when rendering list.",
|
|
@@ -1698,7 +1853,7 @@ var no_missing_key_default = createRule({
|
|
|
1698
1853
|
},
|
|
1699
1854
|
schema: []
|
|
1700
1855
|
},
|
|
1701
|
-
name:
|
|
1856
|
+
name: RULE_NAME30,
|
|
1702
1857
|
create(context) {
|
|
1703
1858
|
const state = { isWithinChildrenToArray: false };
|
|
1704
1859
|
function checkIteratorElement(node) {
|
|
@@ -1822,8 +1977,8 @@ var no_missing_key_default = createRule({
|
|
|
1822
1977
|
function isArrayFromCall(node) {
|
|
1823
1978
|
return node.type === types.AST_NODE_TYPES.CallExpression && node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
|
|
1824
1979
|
}
|
|
1825
|
-
var
|
|
1826
|
-
var
|
|
1980
|
+
var RULE_NAME31 = "no-nested-components";
|
|
1981
|
+
var RULE_FEATURES31 = [
|
|
1827
1982
|
"CHK"
|
|
1828
1983
|
];
|
|
1829
1984
|
var no_nested_components_default = createRule({
|
|
@@ -1831,7 +1986,7 @@ var no_nested_components_default = createRule({
|
|
|
1831
1986
|
type: "problem",
|
|
1832
1987
|
docs: {
|
|
1833
1988
|
description: "disallow using unstable nested components",
|
|
1834
|
-
[Symbol.for("rule_features")]:
|
|
1989
|
+
[Symbol.for("rule_features")]: RULE_FEATURES31
|
|
1835
1990
|
},
|
|
1836
1991
|
messages: {
|
|
1837
1992
|
nestedComponent: "Do not nest components inside other components. Move it to the top level.",
|
|
@@ -1839,7 +1994,7 @@ var no_nested_components_default = createRule({
|
|
|
1839
1994
|
},
|
|
1840
1995
|
schema: []
|
|
1841
1996
|
},
|
|
1842
|
-
name:
|
|
1997
|
+
name: RULE_NAME31,
|
|
1843
1998
|
create(context) {
|
|
1844
1999
|
const hint = core.ERComponentHint.SkipMapCallback | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefined | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1845
2000
|
const collector = core.useComponentCollector(context, hint);
|
|
@@ -1860,11 +2015,11 @@ var no_nested_components_default = createRule({
|
|
|
1860
2015
|
const isClassComponent11 = (node2) => {
|
|
1861
2016
|
return AST11__namespace.isClass(node2) && classComponents.some((component) => component.node === node2);
|
|
1862
2017
|
};
|
|
1863
|
-
for (const { name:
|
|
2018
|
+
for (const { name: name5, node: component } of functionComponents) {
|
|
1864
2019
|
if (core.isDirectValueOfRenderPropertyLoose(component)) {
|
|
1865
2020
|
continue;
|
|
1866
2021
|
}
|
|
1867
|
-
if (
|
|
2022
|
+
if (name5 === eff._) {
|
|
1868
2023
|
continue;
|
|
1869
2024
|
}
|
|
1870
2025
|
const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
|
|
@@ -1875,7 +2030,7 @@ var no_nested_components_default = createRule({
|
|
|
1875
2030
|
messageId: "nestedComponentInProps",
|
|
1876
2031
|
node: component,
|
|
1877
2032
|
data: {
|
|
1878
|
-
name:
|
|
2033
|
+
name: name5
|
|
1879
2034
|
}
|
|
1880
2035
|
});
|
|
1881
2036
|
}
|
|
@@ -1886,19 +2041,19 @@ var no_nested_components_default = createRule({
|
|
|
1886
2041
|
messageId: "nestedComponentInProps",
|
|
1887
2042
|
node: component,
|
|
1888
2043
|
data: {
|
|
1889
|
-
name:
|
|
2044
|
+
name: name5
|
|
1890
2045
|
}
|
|
1891
2046
|
});
|
|
1892
2047
|
continue;
|
|
1893
2048
|
}
|
|
1894
2049
|
const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
|
|
1895
|
-
const
|
|
1896
|
-
if (
|
|
2050
|
+
const isParentComponentNotDirectValueOfRenderProperty = parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent);
|
|
2051
|
+
if (isParentComponentNotDirectValueOfRenderProperty) {
|
|
1897
2052
|
context.report({
|
|
1898
2053
|
messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
|
|
1899
2054
|
node: component,
|
|
1900
2055
|
data: {
|
|
1901
|
-
name:
|
|
2056
|
+
name: name5
|
|
1902
2057
|
}
|
|
1903
2058
|
});
|
|
1904
2059
|
continue;
|
|
@@ -1908,12 +2063,12 @@ var no_nested_components_default = createRule({
|
|
|
1908
2063
|
messageId: "nestedComponent",
|
|
1909
2064
|
node: component,
|
|
1910
2065
|
data: {
|
|
1911
|
-
name:
|
|
2066
|
+
name: name5
|
|
1912
2067
|
}
|
|
1913
2068
|
});
|
|
1914
2069
|
}
|
|
1915
2070
|
}
|
|
1916
|
-
for (const { name:
|
|
2071
|
+
for (const { name: name5 = "unknown", node: component } of classComponents) {
|
|
1917
2072
|
if (AST11__namespace.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
|
|
1918
2073
|
continue;
|
|
1919
2074
|
}
|
|
@@ -1921,7 +2076,7 @@ var no_nested_components_default = createRule({
|
|
|
1921
2076
|
messageId: "nestedComponent",
|
|
1922
2077
|
node: component,
|
|
1923
2078
|
data: {
|
|
1924
|
-
name:
|
|
2079
|
+
name: name5
|
|
1925
2080
|
}
|
|
1926
2081
|
});
|
|
1927
2082
|
}
|
|
@@ -1930,8 +2085,8 @@ var no_nested_components_default = createRule({
|
|
|
1930
2085
|
},
|
|
1931
2086
|
defaultOptions: []
|
|
1932
2087
|
});
|
|
1933
|
-
var
|
|
1934
|
-
var
|
|
2088
|
+
var RULE_NAME32 = "no-prop-types";
|
|
2089
|
+
var RULE_FEATURES32 = [
|
|
1935
2090
|
"CHK"
|
|
1936
2091
|
];
|
|
1937
2092
|
var no_prop_types_default = createRule({
|
|
@@ -1939,14 +2094,14 @@ var no_prop_types_default = createRule({
|
|
|
1939
2094
|
type: "problem",
|
|
1940
2095
|
docs: {
|
|
1941
2096
|
description: "disallow using 'propTypes' property in components",
|
|
1942
|
-
[Symbol.for("rule_features")]:
|
|
2097
|
+
[Symbol.for("rule_features")]: RULE_FEATURES32
|
|
1943
2098
|
},
|
|
1944
2099
|
messages: {
|
|
1945
2100
|
noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead."
|
|
1946
2101
|
},
|
|
1947
2102
|
schema: []
|
|
1948
2103
|
},
|
|
1949
|
-
name:
|
|
2104
|
+
name: RULE_NAME32,
|
|
1950
2105
|
create(context) {
|
|
1951
2106
|
if (!context.sourceCode.text.includes("propTypes")) {
|
|
1952
2107
|
return {};
|
|
@@ -1985,8 +2140,8 @@ var no_prop_types_default = createRule({
|
|
|
1985
2140
|
},
|
|
1986
2141
|
defaultOptions: []
|
|
1987
2142
|
});
|
|
1988
|
-
var
|
|
1989
|
-
var
|
|
2143
|
+
var RULE_NAME33 = "no-redundant-should-component-update";
|
|
2144
|
+
var RULE_FEATURES33 = [
|
|
1990
2145
|
"CHK"
|
|
1991
2146
|
];
|
|
1992
2147
|
function isShouldComponentUpdate(node) {
|
|
@@ -1997,14 +2152,14 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
1997
2152
|
type: "problem",
|
|
1998
2153
|
docs: {
|
|
1999
2154
|
description: "disallow using 'shouldComponentUpdate' in class component extends 'React.PureComponent'",
|
|
2000
|
-
[Symbol.for("rule_features")]:
|
|
2155
|
+
[Symbol.for("rule_features")]: RULE_FEATURES33
|
|
2001
2156
|
},
|
|
2002
2157
|
messages: {
|
|
2003
2158
|
noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'."
|
|
2004
2159
|
},
|
|
2005
2160
|
schema: []
|
|
2006
2161
|
},
|
|
2007
|
-
name:
|
|
2162
|
+
name: RULE_NAME33,
|
|
2008
2163
|
create(context) {
|
|
2009
2164
|
if (!context.sourceCode.text.includes("shouldComponentUpdate")) {
|
|
2010
2165
|
return {};
|
|
@@ -2014,7 +2169,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2014
2169
|
...listeners,
|
|
2015
2170
|
"Program:exit"(node) {
|
|
2016
2171
|
const components = ctx.getAllComponents(node);
|
|
2017
|
-
for (const { name:
|
|
2172
|
+
for (const { name: name5 = "PureComponent", node: component, flag } of components.values()) {
|
|
2018
2173
|
if ((flag & core.ERComponentFlag.PureComponent) === 0n) {
|
|
2019
2174
|
continue;
|
|
2020
2175
|
}
|
|
@@ -2025,7 +2180,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2025
2180
|
messageId: "noRedundantShouldComponentUpdate",
|
|
2026
2181
|
node: member,
|
|
2027
2182
|
data: {
|
|
2028
|
-
componentName:
|
|
2183
|
+
componentName: name5
|
|
2029
2184
|
}
|
|
2030
2185
|
});
|
|
2031
2186
|
}
|
|
@@ -2036,8 +2191,8 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2036
2191
|
},
|
|
2037
2192
|
defaultOptions: []
|
|
2038
2193
|
});
|
|
2039
|
-
var
|
|
2040
|
-
var
|
|
2194
|
+
var RULE_NAME34 = "no-set-state-in-component-did-mount";
|
|
2195
|
+
var RULE_FEATURES34 = [
|
|
2041
2196
|
"CHK"
|
|
2042
2197
|
];
|
|
2043
2198
|
function isComponentDidMount(node) {
|
|
@@ -2048,14 +2203,14 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2048
2203
|
type: "problem",
|
|
2049
2204
|
docs: {
|
|
2050
2205
|
description: "disallow using 'setState' in 'componentDidMount'",
|
|
2051
|
-
[Symbol.for("rule_features")]:
|
|
2206
|
+
[Symbol.for("rule_features")]: RULE_FEATURES34
|
|
2052
2207
|
},
|
|
2053
2208
|
messages: {
|
|
2054
2209
|
noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside of functions, such as callbacks."
|
|
2055
2210
|
},
|
|
2056
2211
|
schema: []
|
|
2057
2212
|
},
|
|
2058
|
-
name:
|
|
2213
|
+
name: RULE_NAME34,
|
|
2059
2214
|
create(context) {
|
|
2060
2215
|
if (!context.sourceCode.text.includes("componentDidMount")) {
|
|
2061
2216
|
return {};
|
|
@@ -2081,8 +2236,8 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2081
2236
|
},
|
|
2082
2237
|
defaultOptions: []
|
|
2083
2238
|
});
|
|
2084
|
-
var
|
|
2085
|
-
var
|
|
2239
|
+
var RULE_NAME35 = "no-set-state-in-component-did-update";
|
|
2240
|
+
var RULE_FEATURES35 = [
|
|
2086
2241
|
"CHK"
|
|
2087
2242
|
];
|
|
2088
2243
|
function isComponentDidUpdate(node) {
|
|
@@ -2093,14 +2248,14 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2093
2248
|
type: "problem",
|
|
2094
2249
|
docs: {
|
|
2095
2250
|
description: "disallow using 'setState' in 'componentDidUpdate'",
|
|
2096
|
-
[Symbol.for("rule_features")]:
|
|
2251
|
+
[Symbol.for("rule_features")]: RULE_FEATURES35
|
|
2097
2252
|
},
|
|
2098
2253
|
messages: {
|
|
2099
2254
|
noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside of functions, such as callbacks."
|
|
2100
2255
|
},
|
|
2101
2256
|
schema: []
|
|
2102
2257
|
},
|
|
2103
|
-
name:
|
|
2258
|
+
name: RULE_NAME35,
|
|
2104
2259
|
create(context) {
|
|
2105
2260
|
if (!context.sourceCode.text.includes("componentDidUpdate")) {
|
|
2106
2261
|
return {};
|
|
@@ -2126,8 +2281,8 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2126
2281
|
},
|
|
2127
2282
|
defaultOptions: []
|
|
2128
2283
|
});
|
|
2129
|
-
var
|
|
2130
|
-
var
|
|
2284
|
+
var RULE_NAME36 = "no-set-state-in-component-will-update";
|
|
2285
|
+
var RULE_FEATURES36 = [
|
|
2131
2286
|
"CHK"
|
|
2132
2287
|
];
|
|
2133
2288
|
function isComponentWillUpdate3(node) {
|
|
@@ -2138,14 +2293,14 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2138
2293
|
type: "problem",
|
|
2139
2294
|
docs: {
|
|
2140
2295
|
description: "disallow using 'setState' in 'componentWillUpdate'",
|
|
2141
|
-
[Symbol.for("rule_features")]:
|
|
2296
|
+
[Symbol.for("rule_features")]: RULE_FEATURES36
|
|
2142
2297
|
},
|
|
2143
2298
|
messages: {
|
|
2144
2299
|
noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside of functions, such as callbacks."
|
|
2145
2300
|
},
|
|
2146
2301
|
schema: []
|
|
2147
2302
|
},
|
|
2148
|
-
name:
|
|
2303
|
+
name: RULE_NAME36,
|
|
2149
2304
|
create(context) {
|
|
2150
2305
|
if (!context.sourceCode.text.includes("componentWillUpdate")) {
|
|
2151
2306
|
return {};
|
|
@@ -2171,8 +2326,8 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2171
2326
|
},
|
|
2172
2327
|
defaultOptions: []
|
|
2173
2328
|
});
|
|
2174
|
-
var
|
|
2175
|
-
var
|
|
2329
|
+
var RULE_NAME37 = "no-string-refs";
|
|
2330
|
+
var RULE_FEATURES37 = [
|
|
2176
2331
|
"CHK"
|
|
2177
2332
|
];
|
|
2178
2333
|
function containsStringLiteral({ value }) {
|
|
@@ -2192,14 +2347,14 @@ var no_string_refs_default = createRule({
|
|
|
2192
2347
|
type: "problem",
|
|
2193
2348
|
docs: {
|
|
2194
2349
|
description: "disallow using deprecated string refs",
|
|
2195
|
-
[Symbol.for("rule_features")]:
|
|
2350
|
+
[Symbol.for("rule_features")]: RULE_FEATURES37
|
|
2196
2351
|
},
|
|
2197
2352
|
messages: {
|
|
2198
2353
|
noStringRefs: "[Deprecated] Use callback refs instead."
|
|
2199
2354
|
},
|
|
2200
2355
|
schema: []
|
|
2201
2356
|
},
|
|
2202
|
-
name:
|
|
2357
|
+
name: RULE_NAME37,
|
|
2203
2358
|
create(context) {
|
|
2204
2359
|
return {
|
|
2205
2360
|
JSXAttribute(node) {
|
|
@@ -2217,8 +2372,8 @@ var no_string_refs_default = createRule({
|
|
|
2217
2372
|
},
|
|
2218
2373
|
defaultOptions: []
|
|
2219
2374
|
});
|
|
2220
|
-
var
|
|
2221
|
-
var
|
|
2375
|
+
var RULE_NAME38 = "no-unsafe-component-will-mount";
|
|
2376
|
+
var RULE_FEATURES38 = [
|
|
2222
2377
|
"CHK"
|
|
2223
2378
|
];
|
|
2224
2379
|
function isUnsafeComponentWillMount(node) {
|
|
@@ -2229,14 +2384,14 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2229
2384
|
type: "problem",
|
|
2230
2385
|
docs: {
|
|
2231
2386
|
description: "disallow using 'UNSAFE_componentWillMount'",
|
|
2232
|
-
[Symbol.for("rule_features")]:
|
|
2387
|
+
[Symbol.for("rule_features")]: RULE_FEATURES38
|
|
2233
2388
|
},
|
|
2234
2389
|
messages: {
|
|
2235
2390
|
noUnsafeComponentWillMount: "Do not use 'UNSAFE_componentWillMount'."
|
|
2236
2391
|
},
|
|
2237
2392
|
schema: []
|
|
2238
2393
|
},
|
|
2239
|
-
name:
|
|
2394
|
+
name: RULE_NAME38,
|
|
2240
2395
|
create(context) {
|
|
2241
2396
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) {
|
|
2242
2397
|
return {};
|
|
@@ -2262,8 +2417,8 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
2262
2417
|
},
|
|
2263
2418
|
defaultOptions: []
|
|
2264
2419
|
});
|
|
2265
|
-
var
|
|
2266
|
-
var
|
|
2420
|
+
var RULE_NAME39 = "no-unsafe-component-will-receive-props";
|
|
2421
|
+
var RULE_FEATURES39 = [
|
|
2267
2422
|
"CHK"
|
|
2268
2423
|
];
|
|
2269
2424
|
function isUnsafeComponentWillReceiveProps(node) {
|
|
@@ -2274,14 +2429,14 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2274
2429
|
type: "problem",
|
|
2275
2430
|
docs: {
|
|
2276
2431
|
description: "disallow using 'UNSAFE_componentWillReceiveProps'",
|
|
2277
|
-
[Symbol.for("rule_features")]:
|
|
2432
|
+
[Symbol.for("rule_features")]: RULE_FEATURES39
|
|
2278
2433
|
},
|
|
2279
2434
|
messages: {
|
|
2280
2435
|
noUnsafeComponentWillReceiveProps: "Do not use 'UNSAFE_componentWillReceiveProps'."
|
|
2281
2436
|
},
|
|
2282
2437
|
schema: []
|
|
2283
2438
|
},
|
|
2284
|
-
name:
|
|
2439
|
+
name: RULE_NAME39,
|
|
2285
2440
|
create(context) {
|
|
2286
2441
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
|
|
2287
2442
|
return {};
|
|
@@ -2307,8 +2462,8 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
2307
2462
|
},
|
|
2308
2463
|
defaultOptions: []
|
|
2309
2464
|
});
|
|
2310
|
-
var
|
|
2311
|
-
var
|
|
2465
|
+
var RULE_NAME40 = "no-unsafe-component-will-update";
|
|
2466
|
+
var RULE_FEATURES40 = [
|
|
2312
2467
|
"CHK"
|
|
2313
2468
|
];
|
|
2314
2469
|
function isUnsafeComponentWillUpdate(node) {
|
|
@@ -2319,14 +2474,14 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2319
2474
|
type: "problem",
|
|
2320
2475
|
docs: {
|
|
2321
2476
|
description: "disallow using 'UNSAFE_componentWillUpdate'",
|
|
2322
|
-
[Symbol.for("rule_features")]:
|
|
2477
|
+
[Symbol.for("rule_features")]: RULE_FEATURES40
|
|
2323
2478
|
},
|
|
2324
2479
|
messages: {
|
|
2325
2480
|
noUnsafeComponentWillUpdate: "Do not use 'UNSAFE_componentWillUpdate'."
|
|
2326
2481
|
},
|
|
2327
2482
|
schema: []
|
|
2328
2483
|
},
|
|
2329
|
-
name:
|
|
2484
|
+
name: RULE_NAME40,
|
|
2330
2485
|
create(context) {
|
|
2331
2486
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) {
|
|
2332
2487
|
return {};
|
|
@@ -2352,8 +2507,8 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
2352
2507
|
},
|
|
2353
2508
|
defaultOptions: []
|
|
2354
2509
|
});
|
|
2355
|
-
var
|
|
2356
|
-
var
|
|
2510
|
+
var RULE_NAME41 = "no-unstable-context-value";
|
|
2511
|
+
var RULE_FEATURES41 = [
|
|
2357
2512
|
"CHK"
|
|
2358
2513
|
];
|
|
2359
2514
|
var no_unstable_context_value_default = createRule({
|
|
@@ -2361,14 +2516,14 @@ var no_unstable_context_value_default = createRule({
|
|
|
2361
2516
|
type: "problem",
|
|
2362
2517
|
docs: {
|
|
2363
2518
|
description: "disallow passing constructed values to context providers",
|
|
2364
|
-
[Symbol.for("rule_features")]:
|
|
2519
|
+
[Symbol.for("rule_features")]: RULE_FEATURES41
|
|
2365
2520
|
},
|
|
2366
2521
|
messages: {
|
|
2367
2522
|
unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
|
|
2368
2523
|
},
|
|
2369
2524
|
schema: []
|
|
2370
2525
|
},
|
|
2371
|
-
name:
|
|
2526
|
+
name: RULE_NAME41,
|
|
2372
2527
|
create(context) {
|
|
2373
2528
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2374
2529
|
const constructions = /* @__PURE__ */ new Map();
|
|
@@ -2420,8 +2575,8 @@ var no_unstable_context_value_default = createRule({
|
|
|
2420
2575
|
},
|
|
2421
2576
|
defaultOptions: []
|
|
2422
2577
|
});
|
|
2423
|
-
var
|
|
2424
|
-
var
|
|
2578
|
+
var RULE_NAME42 = "no-unstable-default-props";
|
|
2579
|
+
var RULE_FEATURES42 = [
|
|
2425
2580
|
"CHK"
|
|
2426
2581
|
];
|
|
2427
2582
|
var no_unstable_default_props_default = createRule({
|
|
@@ -2429,14 +2584,14 @@ var no_unstable_default_props_default = createRule({
|
|
|
2429
2584
|
type: "problem",
|
|
2430
2585
|
docs: {
|
|
2431
2586
|
description: "disallow using unstable value as default param in function component",
|
|
2432
|
-
[Symbol.for("rule_features")]:
|
|
2587
|
+
[Symbol.for("rule_features")]: RULE_FEATURES42
|
|
2433
2588
|
},
|
|
2434
2589
|
messages: {
|
|
2435
2590
|
noUnstableDefaultProps: "A/an '{{forbiddenType}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{forbiddenType}}'."
|
|
2436
2591
|
},
|
|
2437
2592
|
schema: []
|
|
2438
2593
|
},
|
|
2439
|
-
name:
|
|
2594
|
+
name: RULE_NAME42,
|
|
2440
2595
|
create(context) {
|
|
2441
2596
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
2442
2597
|
const declarators = /* @__PURE__ */ new Map();
|
|
@@ -2450,8 +2605,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
2450
2605
|
if (props == null) {
|
|
2451
2606
|
continue;
|
|
2452
2607
|
}
|
|
2453
|
-
const properties = tsPattern.match(props).with({ type: types.AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: types.AST_NODE_TYPES.Identifier }, ({ name:
|
|
2454
|
-
return declarators.get(component)?.filter((d) => d.init.name ===
|
|
2608
|
+
const properties = tsPattern.match(props).with({ type: types.AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: types.AST_NODE_TYPES.Identifier }, ({ name: name5 }) => {
|
|
2609
|
+
return declarators.get(component)?.filter((d) => d.init.name === name5).flatMap((d) => d.id.properties) ?? [];
|
|
2455
2610
|
}).otherwise(() => []);
|
|
2456
2611
|
for (const prop of properties) {
|
|
2457
2612
|
if (prop.type !== types.AST_NODE_TYPES.Property || prop.value.type !== types.AST_NODE_TYPES.AssignmentPattern) {
|
|
@@ -2495,8 +2650,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
2495
2650
|
},
|
|
2496
2651
|
defaultOptions: []
|
|
2497
2652
|
});
|
|
2498
|
-
var
|
|
2499
|
-
var
|
|
2653
|
+
var RULE_NAME43 = "no-unused-class-component-members";
|
|
2654
|
+
var RULE_FEATURES43 = [
|
|
2500
2655
|
"CHK"
|
|
2501
2656
|
];
|
|
2502
2657
|
var LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -2536,14 +2691,14 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2536
2691
|
type: "problem",
|
|
2537
2692
|
docs: {
|
|
2538
2693
|
description: "disallow unused class component members",
|
|
2539
|
-
[Symbol.for("rule_features")]:
|
|
2694
|
+
[Symbol.for("rule_features")]: RULE_FEATURES43
|
|
2540
2695
|
},
|
|
2541
2696
|
messages: {
|
|
2542
2697
|
noUnusedClassComponentMembers: "Unused method or property '{{methodName}}'' of class '{{className}}'."
|
|
2543
2698
|
},
|
|
2544
2699
|
schema: []
|
|
2545
2700
|
},
|
|
2546
|
-
name:
|
|
2701
|
+
name: RULE_NAME43,
|
|
2547
2702
|
create(context) {
|
|
2548
2703
|
const classEntries = [];
|
|
2549
2704
|
const methodEntries = [];
|
|
@@ -2656,8 +2811,8 @@ var no_unused_class_component_members_default = createRule({
|
|
|
2656
2811
|
},
|
|
2657
2812
|
defaultOptions: []
|
|
2658
2813
|
});
|
|
2659
|
-
var
|
|
2660
|
-
var
|
|
2814
|
+
var RULE_NAME44 = "no-unused-state";
|
|
2815
|
+
var RULE_FEATURES44 = [
|
|
2661
2816
|
"CHK"
|
|
2662
2817
|
];
|
|
2663
2818
|
function getName4(node) {
|
|
@@ -2684,14 +2839,14 @@ var no_unused_state_default = createRule({
|
|
|
2684
2839
|
type: "problem",
|
|
2685
2840
|
docs: {
|
|
2686
2841
|
description: "disallow unused state of class component",
|
|
2687
|
-
[Symbol.for("rule_features")]:
|
|
2842
|
+
[Symbol.for("rule_features")]: RULE_FEATURES44
|
|
2688
2843
|
},
|
|
2689
2844
|
messages: {
|
|
2690
2845
|
noUnusedState: "Unused class component state in '{{className}}'"
|
|
2691
2846
|
},
|
|
2692
2847
|
schema: []
|
|
2693
2848
|
},
|
|
2694
|
-
name:
|
|
2849
|
+
name: RULE_NAME44,
|
|
2695
2850
|
create(context) {
|
|
2696
2851
|
const classEntries = [];
|
|
2697
2852
|
const methodEntries = [];
|
|
@@ -2809,7 +2964,7 @@ var no_unused_state_default = createRule({
|
|
|
2809
2964
|
if (!currentClass.body.body.includes(currentMethod)) {
|
|
2810
2965
|
return;
|
|
2811
2966
|
}
|
|
2812
|
-
if (
|
|
2967
|
+
if (node.init == null || !AST11__namespace.isThisExpression(node.init) || node.id.type !== types.AST_NODE_TYPES.ObjectPattern) {
|
|
2813
2968
|
return;
|
|
2814
2969
|
}
|
|
2815
2970
|
const hasState = node.id.properties.some((prop) => {
|
|
@@ -2828,8 +2983,8 @@ var no_unused_state_default = createRule({
|
|
|
2828
2983
|
},
|
|
2829
2984
|
defaultOptions: []
|
|
2830
2985
|
});
|
|
2831
|
-
var
|
|
2832
|
-
var
|
|
2986
|
+
var RULE_NAME45 = "no-use-context";
|
|
2987
|
+
var RULE_FEATURES45 = [
|
|
2833
2988
|
"CHK",
|
|
2834
2989
|
"MOD"
|
|
2835
2990
|
];
|
|
@@ -2838,7 +2993,7 @@ var no_use_context_default = createRule({
|
|
|
2838
2993
|
type: "problem",
|
|
2839
2994
|
docs: {
|
|
2840
2995
|
description: "disallow the use of 'useContext'",
|
|
2841
|
-
[Symbol.for("rule_features")]:
|
|
2996
|
+
[Symbol.for("rule_features")]: RULE_FEATURES45
|
|
2842
2997
|
},
|
|
2843
2998
|
fixable: "code",
|
|
2844
2999
|
messages: {
|
|
@@ -2846,12 +3001,12 @@ var no_use_context_default = createRule({
|
|
|
2846
3001
|
},
|
|
2847
3002
|
schema: []
|
|
2848
3003
|
},
|
|
2849
|
-
name:
|
|
3004
|
+
name: RULE_NAME45,
|
|
2850
3005
|
create(context) {
|
|
2851
3006
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2852
|
-
const
|
|
3007
|
+
const settings4 = shared.getSettingsFromContext(context);
|
|
2853
3008
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
2854
|
-
if (compareVersions.compare(
|
|
3009
|
+
if (compareVersions.compare(settings4.version, "19.0.0", "<")) {
|
|
2855
3010
|
return {};
|
|
2856
3011
|
}
|
|
2857
3012
|
return {
|
|
@@ -2877,7 +3032,7 @@ var no_use_context_default = createRule({
|
|
|
2877
3032
|
});
|
|
2878
3033
|
},
|
|
2879
3034
|
ImportDeclaration(node) {
|
|
2880
|
-
if (node.source.value !==
|
|
3035
|
+
if (node.source.value !== settings4.importSource) {
|
|
2881
3036
|
return;
|
|
2882
3037
|
}
|
|
2883
3038
|
const isUseImported = node.specifiers.some(tsPattern.isMatching({ local: { type: types.AST_NODE_TYPES.Identifier, name: "use" } }));
|
|
@@ -2913,7 +3068,7 @@ var no_use_context_default = createRule({
|
|
|
2913
3068
|
},
|
|
2914
3069
|
defaultOptions: []
|
|
2915
3070
|
});
|
|
2916
|
-
var
|
|
3071
|
+
var RULE_NAME46 = "no-useless-fragment";
|
|
2917
3072
|
var defaultOptions = [{
|
|
2918
3073
|
allowExpressions: true
|
|
2919
3074
|
}];
|
|
@@ -2926,7 +3081,7 @@ function trimLikeReact(text) {
|
|
|
2926
3081
|
}
|
|
2927
3082
|
function checkAndReport(node, context, allowExpressions) {
|
|
2928
3083
|
function fix(fixer) {
|
|
2929
|
-
if (
|
|
3084
|
+
if (node.parent.type !== types.AST_NODE_TYPES.JSXElement && node.parent.type !== types.AST_NODE_TYPES.JSXFragment) {
|
|
2930
3085
|
if (node.children.length === 0) {
|
|
2931
3086
|
return null;
|
|
2932
3087
|
}
|
|
@@ -3039,7 +3194,7 @@ var no_useless_fragment_default = createRule({
|
|
|
3039
3194
|
}
|
|
3040
3195
|
}]
|
|
3041
3196
|
},
|
|
3042
|
-
name:
|
|
3197
|
+
name: RULE_NAME46,
|
|
3043
3198
|
create(context, [option]) {
|
|
3044
3199
|
const { allowExpressions = true } = option;
|
|
3045
3200
|
return {
|
|
@@ -3054,8 +3209,8 @@ var no_useless_fragment_default = createRule({
|
|
|
3054
3209
|
},
|
|
3055
3210
|
defaultOptions
|
|
3056
3211
|
});
|
|
3057
|
-
var
|
|
3058
|
-
var
|
|
3212
|
+
var RULE_NAME47 = "prefer-destructuring-assignment";
|
|
3213
|
+
var RULE_FEATURES46 = [
|
|
3059
3214
|
"CHK"
|
|
3060
3215
|
];
|
|
3061
3216
|
function isMemberExpressionWithObjectName(node) {
|
|
@@ -3066,14 +3221,14 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3066
3221
|
type: "problem",
|
|
3067
3222
|
docs: {
|
|
3068
3223
|
description: "enforce using destructuring assignment in component props and context",
|
|
3069
|
-
[Symbol.for("rule_features")]:
|
|
3224
|
+
[Symbol.for("rule_features")]: RULE_FEATURES46
|
|
3070
3225
|
},
|
|
3071
3226
|
messages: {
|
|
3072
3227
|
preferDestructuringAssignment: "Use destructuring assignment for {{name}}."
|
|
3073
3228
|
},
|
|
3074
3229
|
schema: []
|
|
3075
3230
|
},
|
|
3076
|
-
name:
|
|
3231
|
+
name: RULE_NAME47,
|
|
3077
3232
|
create(context) {
|
|
3078
3233
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
3079
3234
|
const memberExpressionWithNames = [];
|
|
@@ -3136,8 +3291,8 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3136
3291
|
},
|
|
3137
3292
|
defaultOptions: []
|
|
3138
3293
|
});
|
|
3139
|
-
var
|
|
3140
|
-
var
|
|
3294
|
+
var RULE_NAME48 = "prefer-react-namespace-import";
|
|
3295
|
+
var RULE_FEATURES47 = [
|
|
3141
3296
|
"CHK",
|
|
3142
3297
|
"FIX"
|
|
3143
3298
|
];
|
|
@@ -3146,7 +3301,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3146
3301
|
type: "problem",
|
|
3147
3302
|
docs: {
|
|
3148
3303
|
description: "enforce React is imported via a namespace import",
|
|
3149
|
-
[Symbol.for("rule_features")]:
|
|
3304
|
+
[Symbol.for("rule_features")]: RULE_FEATURES47
|
|
3150
3305
|
},
|
|
3151
3306
|
fixable: "code",
|
|
3152
3307
|
messages: {
|
|
@@ -3154,7 +3309,7 @@ var prefer_react_namespace_import_default = createRule({
|
|
|
3154
3309
|
},
|
|
3155
3310
|
schema: []
|
|
3156
3311
|
},
|
|
3157
|
-
name:
|
|
3312
|
+
name: RULE_NAME48,
|
|
3158
3313
|
create(context) {
|
|
3159
3314
|
const { importSource } = shared.getSettingsFromContext(context);
|
|
3160
3315
|
return {
|
|
@@ -3190,8 +3345,8 @@ ${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semiColon}`
|
|
|
3190
3345
|
},
|
|
3191
3346
|
defaultOptions: []
|
|
3192
3347
|
});
|
|
3193
|
-
var
|
|
3194
|
-
var
|
|
3348
|
+
var RULE_NAME49 = "prefer-read-only-props";
|
|
3349
|
+
var RULE_FEATURES48 = [
|
|
3195
3350
|
"CHK",
|
|
3196
3351
|
"TSC"
|
|
3197
3352
|
];
|
|
@@ -3208,14 +3363,14 @@ var prefer_read_only_props_default = createRule({
|
|
|
3208
3363
|
type: "problem",
|
|
3209
3364
|
docs: {
|
|
3210
3365
|
description: "enforce read-only props in components",
|
|
3211
|
-
[Symbol.for("rule_features")]:
|
|
3366
|
+
[Symbol.for("rule_features")]: RULE_FEATURES48
|
|
3212
3367
|
},
|
|
3213
3368
|
messages: {
|
|
3214
3369
|
preferReadOnlyProps: "A function component's props should be read-only."
|
|
3215
3370
|
},
|
|
3216
3371
|
schema: []
|
|
3217
3372
|
},
|
|
3218
|
-
name:
|
|
3373
|
+
name: RULE_NAME49,
|
|
3219
3374
|
create(context) {
|
|
3220
3375
|
const services = utils.ESLintUtils.getParserServices(context, false);
|
|
3221
3376
|
const { ctx, listeners } = core.useComponentCollector(context);
|
|
@@ -3239,8 +3394,8 @@ var prefer_read_only_props_default = createRule({
|
|
|
3239
3394
|
},
|
|
3240
3395
|
defaultOptions: []
|
|
3241
3396
|
});
|
|
3242
|
-
var
|
|
3243
|
-
var
|
|
3397
|
+
var RULE_NAME50 = "prefer-shorthand-boolean";
|
|
3398
|
+
var RULE_FEATURES49 = [
|
|
3244
3399
|
"CHK",
|
|
3245
3400
|
"FIX"
|
|
3246
3401
|
];
|
|
@@ -3249,7 +3404,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3249
3404
|
type: "problem",
|
|
3250
3405
|
docs: {
|
|
3251
3406
|
description: "enforce using shorthand boolean attributes",
|
|
3252
|
-
[Symbol.for("rule_features")]:
|
|
3407
|
+
[Symbol.for("rule_features")]: RULE_FEATURES49
|
|
3253
3408
|
},
|
|
3254
3409
|
fixable: "code",
|
|
3255
3410
|
messages: {
|
|
@@ -3257,7 +3412,7 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3257
3412
|
},
|
|
3258
3413
|
schema: []
|
|
3259
3414
|
},
|
|
3260
|
-
name:
|
|
3415
|
+
name: RULE_NAME50,
|
|
3261
3416
|
create(context) {
|
|
3262
3417
|
return {
|
|
3263
3418
|
JSXAttribute(node) {
|
|
@@ -3280,8 +3435,8 @@ var prefer_shorthand_boolean_default = createRule({
|
|
|
3280
3435
|
},
|
|
3281
3436
|
defaultOptions: []
|
|
3282
3437
|
});
|
|
3283
|
-
var
|
|
3284
|
-
var
|
|
3438
|
+
var RULE_NAME51 = "prefer-shorthand-fragment";
|
|
3439
|
+
var RULE_FEATURES50 = [
|
|
3285
3440
|
"CHK",
|
|
3286
3441
|
"FIX"
|
|
3287
3442
|
];
|
|
@@ -3290,7 +3445,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3290
3445
|
type: "problem",
|
|
3291
3446
|
docs: {
|
|
3292
3447
|
description: "enforce using fragment syntax instead of 'Fragment' component",
|
|
3293
|
-
[Symbol.for("rule_features")]:
|
|
3448
|
+
[Symbol.for("rule_features")]: RULE_FEATURES50
|
|
3294
3449
|
},
|
|
3295
3450
|
fixable: "code",
|
|
3296
3451
|
messages: {
|
|
@@ -3298,7 +3453,7 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3298
3453
|
},
|
|
3299
3454
|
schema: []
|
|
3300
3455
|
},
|
|
3301
|
-
name:
|
|
3456
|
+
name: RULE_NAME51,
|
|
3302
3457
|
create(context) {
|
|
3303
3458
|
return {
|
|
3304
3459
|
JSXElement(node) {
|
|
@@ -3326,21 +3481,21 @@ var prefer_shorthand_fragment_default = createRule({
|
|
|
3326
3481
|
},
|
|
3327
3482
|
defaultOptions: []
|
|
3328
3483
|
});
|
|
3329
|
-
var
|
|
3330
|
-
var
|
|
3484
|
+
var RULE_NAME52 = "use-jsx-vars";
|
|
3485
|
+
var RULE_FEATURES51 = [];
|
|
3331
3486
|
var use_jsx_vars_default = createRule({
|
|
3332
3487
|
meta: {
|
|
3333
3488
|
type: "problem",
|
|
3334
3489
|
docs: {
|
|
3335
|
-
description: "
|
|
3336
|
-
[Symbol.for("rule_features")]:
|
|
3490
|
+
description: "marks variables used in JSX as used",
|
|
3491
|
+
[Symbol.for("rule_features")]: RULE_FEATURES51
|
|
3337
3492
|
},
|
|
3338
3493
|
messages: {
|
|
3339
3494
|
useJsxVars: ""
|
|
3340
3495
|
},
|
|
3341
3496
|
schema: []
|
|
3342
3497
|
},
|
|
3343
|
-
name:
|
|
3498
|
+
name: RULE_NAME52,
|
|
3344
3499
|
create(context) {
|
|
3345
3500
|
return {
|
|
3346
3501
|
JSXOpeningElement(node) {
|
|
@@ -3366,10 +3521,10 @@ var use_jsx_vars_default = createRule({
|
|
|
3366
3521
|
defaultOptions: []
|
|
3367
3522
|
});
|
|
3368
3523
|
|
|
3369
|
-
// src/
|
|
3370
|
-
var
|
|
3524
|
+
// src/plugin.ts
|
|
3525
|
+
var plugin = {
|
|
3371
3526
|
meta: {
|
|
3372
|
-
name,
|
|
3527
|
+
name: name4,
|
|
3373
3528
|
version
|
|
3374
3529
|
},
|
|
3375
3530
|
rules: {
|
|
@@ -3401,6 +3556,7 @@ var index_default = {
|
|
|
3401
3556
|
"no-implicit-key": no_implicit_key_default,
|
|
3402
3557
|
"no-leaked-conditional-rendering": no_leaked_conditional_rendering_default,
|
|
3403
3558
|
"no-missing-component-display-name": no_missing_component_display_name_default,
|
|
3559
|
+
"no-missing-context-display-name": no_missing_context_display_name_default,
|
|
3404
3560
|
"no-missing-key": no_missing_key_default,
|
|
3405
3561
|
"no-nested-components": no_nested_components_default,
|
|
3406
3562
|
"no-prop-types": no_prop_types_default,
|
|
@@ -3434,4 +3590,31 @@ var index_default = {
|
|
|
3434
3590
|
}
|
|
3435
3591
|
};
|
|
3436
3592
|
|
|
3593
|
+
// src/index.ts
|
|
3594
|
+
function makeConfig(config) {
|
|
3595
|
+
return {
|
|
3596
|
+
...config,
|
|
3597
|
+
plugins: {
|
|
3598
|
+
"react-x": plugin
|
|
3599
|
+
}
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
function makeLegacyConfig({ rules: rules4 }) {
|
|
3603
|
+
return {
|
|
3604
|
+
plugins: ["react-x"],
|
|
3605
|
+
rules: rules4
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
var index_default = {
|
|
3609
|
+
...plugin,
|
|
3610
|
+
configs: {
|
|
3611
|
+
["recommended"]: makeConfig(recommended_exports),
|
|
3612
|
+
["recommended-legacy"]: makeLegacyConfig(recommended_exports),
|
|
3613
|
+
["recommended-type-checked"]: makeConfig(recommended_type_checked_exports),
|
|
3614
|
+
["recommended-type-checked-legacy"]: makeLegacyConfig(recommended_type_checked_exports),
|
|
3615
|
+
["recommended-typescript"]: makeConfig(recommended_typescript_exports),
|
|
3616
|
+
["recommended-typescript-legacy"]: makeLegacyConfig(recommended_typescript_exports)
|
|
3617
|
+
}
|
|
3618
|
+
};
|
|
3619
|
+
|
|
3437
3620
|
module.exports = index_default;
|