eslint-plugin-react-x 1.26.3-beta.13 → 1.26.3-beta.16
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 -1
- package/dist/index.d.mts +281 -59
- package/dist/index.d.ts +281 -59
- package/dist/index.js +158 -36
- package/dist/index.mjs +158 -36
- package/package.json +13 -13
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.26.3-beta.
|
|
139
|
+
var name4 = "eslint-plugin-react-x";
|
|
140
|
+
var version = "1.26.3-beta.16";
|
|
46
141
|
var createRule = shared.createRuleForPlugin("x");
|
|
47
142
|
|
|
48
143
|
// src/utils/get-associated-tokens.ts
|
|
@@ -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({
|
|
@@ -1860,11 +1955,11 @@ var no_nested_components_default = createRule({
|
|
|
1860
1955
|
const isClassComponent11 = (node2) => {
|
|
1861
1956
|
return AST11__namespace.isClass(node2) && classComponents.some((component) => component.node === node2);
|
|
1862
1957
|
};
|
|
1863
|
-
for (const { name:
|
|
1958
|
+
for (const { name: name5, node: component } of functionComponents) {
|
|
1864
1959
|
if (core.isDirectValueOfRenderPropertyLoose(component)) {
|
|
1865
1960
|
continue;
|
|
1866
1961
|
}
|
|
1867
|
-
if (
|
|
1962
|
+
if (name5 === eff._) {
|
|
1868
1963
|
continue;
|
|
1869
1964
|
}
|
|
1870
1965
|
const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
|
|
@@ -1875,7 +1970,7 @@ var no_nested_components_default = createRule({
|
|
|
1875
1970
|
messageId: "nestedComponentInProps",
|
|
1876
1971
|
node: component,
|
|
1877
1972
|
data: {
|
|
1878
|
-
name:
|
|
1973
|
+
name: name5
|
|
1879
1974
|
}
|
|
1880
1975
|
});
|
|
1881
1976
|
}
|
|
@@ -1886,7 +1981,7 @@ var no_nested_components_default = createRule({
|
|
|
1886
1981
|
messageId: "nestedComponentInProps",
|
|
1887
1982
|
node: component,
|
|
1888
1983
|
data: {
|
|
1889
|
-
name:
|
|
1984
|
+
name: name5
|
|
1890
1985
|
}
|
|
1891
1986
|
});
|
|
1892
1987
|
continue;
|
|
@@ -1898,7 +1993,7 @@ var no_nested_components_default = createRule({
|
|
|
1898
1993
|
messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
|
|
1899
1994
|
node: component,
|
|
1900
1995
|
data: {
|
|
1901
|
-
name:
|
|
1996
|
+
name: name5
|
|
1902
1997
|
}
|
|
1903
1998
|
});
|
|
1904
1999
|
continue;
|
|
@@ -1908,12 +2003,12 @@ var no_nested_components_default = createRule({
|
|
|
1908
2003
|
messageId: "nestedComponent",
|
|
1909
2004
|
node: component,
|
|
1910
2005
|
data: {
|
|
1911
|
-
name:
|
|
2006
|
+
name: name5
|
|
1912
2007
|
}
|
|
1913
2008
|
});
|
|
1914
2009
|
}
|
|
1915
2010
|
}
|
|
1916
|
-
for (const { name:
|
|
2011
|
+
for (const { name: name5 = "unknown", node: component } of classComponents) {
|
|
1917
2012
|
if (AST11__namespace.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
|
|
1918
2013
|
continue;
|
|
1919
2014
|
}
|
|
@@ -1921,7 +2016,7 @@ var no_nested_components_default = createRule({
|
|
|
1921
2016
|
messageId: "nestedComponent",
|
|
1922
2017
|
node: component,
|
|
1923
2018
|
data: {
|
|
1924
|
-
name:
|
|
2019
|
+
name: name5
|
|
1925
2020
|
}
|
|
1926
2021
|
});
|
|
1927
2022
|
}
|
|
@@ -2014,7 +2109,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2014
2109
|
...listeners,
|
|
2015
2110
|
"Program:exit"(node) {
|
|
2016
2111
|
const components = ctx.getAllComponents(node);
|
|
2017
|
-
for (const { name:
|
|
2112
|
+
for (const { name: name5 = "PureComponent", node: component, flag } of components.values()) {
|
|
2018
2113
|
if ((flag & core.ERComponentFlag.PureComponent) === 0n) {
|
|
2019
2114
|
continue;
|
|
2020
2115
|
}
|
|
@@ -2025,7 +2120,7 @@ var no_redundant_should_component_update_default = createRule({
|
|
|
2025
2120
|
messageId: "noRedundantShouldComponentUpdate",
|
|
2026
2121
|
node: member,
|
|
2027
2122
|
data: {
|
|
2028
|
-
componentName:
|
|
2123
|
+
componentName: name5
|
|
2029
2124
|
}
|
|
2030
2125
|
});
|
|
2031
2126
|
}
|
|
@@ -2450,8 +2545,8 @@ var no_unstable_default_props_default = createRule({
|
|
|
2450
2545
|
if (props == null) {
|
|
2451
2546
|
continue;
|
|
2452
2547
|
}
|
|
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 ===
|
|
2548
|
+
const properties = tsPattern.match(props).with({ type: types.AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: types.AST_NODE_TYPES.Identifier }, ({ name: name5 }) => {
|
|
2549
|
+
return declarators.get(component)?.filter((d) => d.init.name === name5).flatMap((d) => d.id.properties) ?? [];
|
|
2455
2550
|
}).otherwise(() => []);
|
|
2456
2551
|
for (const prop of properties) {
|
|
2457
2552
|
if (prop.type !== types.AST_NODE_TYPES.Property || prop.value.type !== types.AST_NODE_TYPES.AssignmentPattern) {
|
|
@@ -2849,9 +2944,9 @@ var no_use_context_default = createRule({
|
|
|
2849
2944
|
name: RULE_NAME44,
|
|
2850
2945
|
create(context) {
|
|
2851
2946
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
2852
|
-
const
|
|
2947
|
+
const settings4 = shared.getSettingsFromContext(context);
|
|
2853
2948
|
const useContextAlias = /* @__PURE__ */ new Set();
|
|
2854
|
-
if (compareVersions.compare(
|
|
2949
|
+
if (compareVersions.compare(settings4.version, "19.0.0", "<")) {
|
|
2855
2950
|
return {};
|
|
2856
2951
|
}
|
|
2857
2952
|
return {
|
|
@@ -2877,7 +2972,7 @@ var no_use_context_default = createRule({
|
|
|
2877
2972
|
});
|
|
2878
2973
|
},
|
|
2879
2974
|
ImportDeclaration(node) {
|
|
2880
|
-
if (node.source.value !==
|
|
2975
|
+
if (node.source.value !== settings4.importSource) {
|
|
2881
2976
|
return;
|
|
2882
2977
|
}
|
|
2883
2978
|
const isUseImported = node.specifiers.some(tsPattern.isMatching({ local: { type: types.AST_NODE_TYPES.Identifier, name: "use" } }));
|
|
@@ -3366,10 +3461,10 @@ var use_jsx_vars_default = createRule({
|
|
|
3366
3461
|
defaultOptions: []
|
|
3367
3462
|
});
|
|
3368
3463
|
|
|
3369
|
-
// src/
|
|
3370
|
-
var
|
|
3464
|
+
// src/plugin.ts
|
|
3465
|
+
var plugin = {
|
|
3371
3466
|
meta: {
|
|
3372
|
-
name,
|
|
3467
|
+
name: name4,
|
|
3373
3468
|
version
|
|
3374
3469
|
},
|
|
3375
3470
|
rules: {
|
|
@@ -3434,4 +3529,31 @@ var index_default = {
|
|
|
3434
3529
|
}
|
|
3435
3530
|
};
|
|
3436
3531
|
|
|
3532
|
+
// src/index.ts
|
|
3533
|
+
function makeConfig(config) {
|
|
3534
|
+
return {
|
|
3535
|
+
...config,
|
|
3536
|
+
plugins: {
|
|
3537
|
+
"react-x": plugin
|
|
3538
|
+
}
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
function makeLegacyConfig(config) {
|
|
3542
|
+
return {
|
|
3543
|
+
plugins: ["react-x"],
|
|
3544
|
+
rules: config.rules
|
|
3545
|
+
};
|
|
3546
|
+
}
|
|
3547
|
+
var index_default = {
|
|
3548
|
+
...plugin,
|
|
3549
|
+
configs: {
|
|
3550
|
+
["recommended"]: makeConfig(recommended_exports),
|
|
3551
|
+
["recommended-legacy"]: makeLegacyConfig(recommended_exports),
|
|
3552
|
+
["recommended-type-checked"]: makeConfig(recommended_type_checked_exports),
|
|
3553
|
+
["recommended-type-checked-legacy"]: makeLegacyConfig(recommended_type_checked_exports),
|
|
3554
|
+
["recommended-typescript"]: makeConfig(recommended_typescript_exports),
|
|
3555
|
+
["recommended-typescript-legacy"]: makeLegacyConfig(recommended_typescript_exports)
|
|
3556
|
+
}
|
|
3557
|
+
};
|
|
3558
|
+
|
|
3437
3559
|
module.exports = index_default;
|