eslint-plugin-react-x 5.0.2-next.5 → 5.1.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/dist/index.js +53 -52
- package/package.json +14 -13
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DEFAULT_ESLINT_REACT_SETTINGS,
|
|
1
|
+
import { DEFAULT_ESLINT_REACT_SETTINGS, getSettingsFromContext, toRegExp } from "@eslint-react/shared";
|
|
2
2
|
import * as ast from "@eslint-react/ast";
|
|
3
3
|
import * as core from "@eslint-react/core";
|
|
4
4
|
import { isUseRefCall } from "@eslint-react/core";
|
|
5
|
+
import { merge } from "@eslint-react/eslint";
|
|
5
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
6
7
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
7
8
|
import { JsxDetectionHint, findParentAttribute, getElementFullType, hasAttribute, isJsxLike } from "@eslint-react/jsx";
|
|
@@ -141,7 +142,7 @@ const rules$7 = {
|
|
|
141
142
|
//#endregion
|
|
142
143
|
//#region package.json
|
|
143
144
|
var name$6 = "eslint-plugin-react-x";
|
|
144
|
-
var version = "5.0
|
|
145
|
+
var version = "5.1.0-beta.1";
|
|
145
146
|
|
|
146
147
|
//#endregion
|
|
147
148
|
//#region src/rules/component-hook-factories/lib.ts
|
|
@@ -212,7 +213,7 @@ function create$48(context) {
|
|
|
212
213
|
const cCollector = core.getClassComponentCollector(context);
|
|
213
214
|
const hCollector = core.getHookCollector(context);
|
|
214
215
|
const reported = /* @__PURE__ */ new Set();
|
|
215
|
-
return
|
|
216
|
+
return merge(fCollector.visitor, cCollector.visitor, hCollector.visitor, { "Program:exit"(program) {
|
|
216
217
|
const fComponents = [...fCollector.api.getAllComponents(program)];
|
|
217
218
|
const cComponents = [...cCollector.api.getAllComponents(program)];
|
|
218
219
|
const hooks = [...hCollector.api.getAllHooks(program)];
|
|
@@ -279,7 +280,7 @@ function create$47(context) {
|
|
|
279
280
|
const hCollector = core.getHookCollector(context);
|
|
280
281
|
const reported = /* @__PURE__ */ new Set();
|
|
281
282
|
const useCalls = /* @__PURE__ */ new Set();
|
|
282
|
-
return
|
|
283
|
+
return merge(fCollector.visitor, hCollector.visitor, {
|
|
283
284
|
CallExpression(node) {
|
|
284
285
|
if (!core.isUseCall(context, node)) return;
|
|
285
286
|
useCalls.add(node);
|
|
@@ -1311,7 +1312,7 @@ function create$46(context) {
|
|
|
1311
1312
|
}
|
|
1312
1313
|
return null;
|
|
1313
1314
|
}
|
|
1314
|
-
return
|
|
1315
|
+
return merge(hCollector.visitor, cCollector.visitor, {
|
|
1315
1316
|
CallExpression(node) {
|
|
1316
1317
|
if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
1317
1318
|
const { object, property } = node.callee;
|
|
@@ -1383,7 +1384,7 @@ function create$46(context) {
|
|
|
1383
1384
|
}
|
|
1384
1385
|
|
|
1385
1386
|
//#endregion
|
|
1386
|
-
//#region
|
|
1387
|
+
//#region ../../.pkgs/eff/dist/index.js
|
|
1387
1388
|
function not(predicate) {
|
|
1388
1389
|
return (data) => !predicate(data);
|
|
1389
1390
|
}
|
|
@@ -1583,7 +1584,7 @@ function create$45(context) {
|
|
|
1583
1584
|
const classStack = [];
|
|
1584
1585
|
const methodStack = [];
|
|
1585
1586
|
const setStateStack = [];
|
|
1586
|
-
return
|
|
1587
|
+
return merge({
|
|
1587
1588
|
CallExpression(node) {
|
|
1588
1589
|
if (!core.isThisSetStateCall(node)) return;
|
|
1589
1590
|
setStateStack.push([node, false]);
|
|
@@ -1751,7 +1752,7 @@ function create$44(context) {
|
|
|
1751
1752
|
}
|
|
1752
1753
|
return [];
|
|
1753
1754
|
}
|
|
1754
|
-
return
|
|
1755
|
+
return merge({
|
|
1755
1756
|
CallExpression(node) {
|
|
1756
1757
|
indexParamNames.push(getMapIndexParamName(context, node));
|
|
1757
1758
|
if (node.arguments.length === 0) return;
|
|
@@ -1791,7 +1792,7 @@ var no_children_count_default = createRule({
|
|
|
1791
1792
|
defaultOptions: []
|
|
1792
1793
|
});
|
|
1793
1794
|
function create$43(context) {
|
|
1794
|
-
return
|
|
1795
|
+
return merge({ MemberExpression(node) {
|
|
1795
1796
|
if (core.isChildrenCount(context, node)) context.report({
|
|
1796
1797
|
messageId: "default",
|
|
1797
1798
|
node: node.property
|
|
@@ -1814,7 +1815,7 @@ var no_children_for_each_default = createRule({
|
|
|
1814
1815
|
defaultOptions: []
|
|
1815
1816
|
});
|
|
1816
1817
|
function create$42(context) {
|
|
1817
|
-
return
|
|
1818
|
+
return merge({ MemberExpression(node) {
|
|
1818
1819
|
if (core.isChildrenForEach(context, node)) context.report({
|
|
1819
1820
|
messageId: "default",
|
|
1820
1821
|
node: node.property
|
|
@@ -1837,7 +1838,7 @@ var no_children_map_default = createRule({
|
|
|
1837
1838
|
defaultOptions: []
|
|
1838
1839
|
});
|
|
1839
1840
|
function create$41(context) {
|
|
1840
|
-
return
|
|
1841
|
+
return merge({ MemberExpression(node) {
|
|
1841
1842
|
if (core.isChildrenMap(context, node)) context.report({
|
|
1842
1843
|
messageId: "default",
|
|
1843
1844
|
node: node.property
|
|
@@ -1860,7 +1861,7 @@ var no_children_only_default = createRule({
|
|
|
1860
1861
|
defaultOptions: []
|
|
1861
1862
|
});
|
|
1862
1863
|
function create$40(context) {
|
|
1863
|
-
return
|
|
1864
|
+
return merge({ MemberExpression(node) {
|
|
1864
1865
|
if (core.isChildrenOnly(context, node)) context.report({
|
|
1865
1866
|
messageId: "default",
|
|
1866
1867
|
node: node.property
|
|
@@ -1883,7 +1884,7 @@ var no_children_to_array_default = createRule({
|
|
|
1883
1884
|
defaultOptions: []
|
|
1884
1885
|
});
|
|
1885
1886
|
function create$39(context) {
|
|
1886
|
-
return
|
|
1887
|
+
return merge({ MemberExpression(node) {
|
|
1887
1888
|
if (core.isChildrenToArray(context, node)) context.report({
|
|
1888
1889
|
messageId: "default",
|
|
1889
1890
|
node: node.property
|
|
@@ -1908,7 +1909,7 @@ var no_class_component_default = createRule({
|
|
|
1908
1909
|
function create$38(context) {
|
|
1909
1910
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
1910
1911
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
1911
|
-
return
|
|
1912
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
1912
1913
|
for (const { name = "anonymous", node: component } of api.getAllComponents(program)) {
|
|
1913
1914
|
if (component.body.body.some((m) => core.isComponentDidCatch(m) || core.isGetDerivedStateFromError(m))) continue;
|
|
1914
1915
|
context.report({
|
|
@@ -1935,7 +1936,7 @@ var no_clone_element_default = createRule({
|
|
|
1935
1936
|
defaultOptions: []
|
|
1936
1937
|
});
|
|
1937
1938
|
function create$37(context) {
|
|
1938
|
-
return
|
|
1939
|
+
return merge({ CallExpression(node) {
|
|
1939
1940
|
if (core.isCloneElementCall(context, node)) context.report({
|
|
1940
1941
|
messageId: "default",
|
|
1941
1942
|
node
|
|
@@ -1961,7 +1962,7 @@ var no_component_will_mount_default = createRule({
|
|
|
1961
1962
|
function create$36(context) {
|
|
1962
1963
|
if (!context.sourceCode.text.includes("componentWillMount")) return {};
|
|
1963
1964
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
1964
|
-
return
|
|
1965
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
1965
1966
|
for (const { node: component } of api.getAllComponents(program)) {
|
|
1966
1967
|
const { body } = component.body;
|
|
1967
1968
|
for (const member of body) if (core.isComponentWillMount(member)) context.report({
|
|
@@ -1994,7 +1995,7 @@ var no_component_will_receive_props_default = createRule({
|
|
|
1994
1995
|
function create$35(context) {
|
|
1995
1996
|
if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
|
|
1996
1997
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
1997
|
-
return
|
|
1998
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
1998
1999
|
for (const { node: component } of api.getAllComponents(program)) {
|
|
1999
2000
|
const { body } = component.body;
|
|
2000
2001
|
for (const member of body) if (core.isComponentWillReceiveProps(member)) context.report({
|
|
@@ -2027,7 +2028,7 @@ var no_component_will_update_default = createRule({
|
|
|
2027
2028
|
function create$34(context) {
|
|
2028
2029
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
2029
2030
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
2030
|
-
return
|
|
2031
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
2031
2032
|
for (const { node: component } of api.getAllComponents(program)) {
|
|
2032
2033
|
const { body } = component.body;
|
|
2033
2034
|
for (const member of body) if (core.isComponentWillUpdate(member)) context.report({
|
|
@@ -2065,7 +2066,7 @@ function create$33(context) {
|
|
|
2065
2066
|
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
2066
2067
|
const { version } = getSettingsFromContext(context);
|
|
2067
2068
|
if (compare(version, "19.0.0", "<")) return {};
|
|
2068
|
-
return
|
|
2069
|
+
return merge({ JSXElement(node) {
|
|
2069
2070
|
const parts = getElementFullType(node).split(".");
|
|
2070
2071
|
const selfName = parts.pop();
|
|
2071
2072
|
const contextFullName = parts.join(".");
|
|
@@ -2104,7 +2105,7 @@ var no_create_ref_default = createRule({
|
|
|
2104
2105
|
defaultOptions: []
|
|
2105
2106
|
});
|
|
2106
2107
|
function create$32(context) {
|
|
2107
|
-
return
|
|
2108
|
+
return merge({ CallExpression(node) {
|
|
2108
2109
|
if (core.isCreateRefCall(context, node) && ast.findParent(node, core.isClassComponent) == null) context.report({
|
|
2109
2110
|
messageId: "default",
|
|
2110
2111
|
node
|
|
@@ -2130,7 +2131,7 @@ var no_direct_mutation_state_default = createRule({
|
|
|
2130
2131
|
defaultOptions: []
|
|
2131
2132
|
});
|
|
2132
2133
|
function create$31(context) {
|
|
2133
|
-
return
|
|
2134
|
+
return merge({ AssignmentExpression(node) {
|
|
2134
2135
|
if (!core.isAssignmentToThisState(node)) return;
|
|
2135
2136
|
const parentClass = ast.findParent(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
|
|
2136
2137
|
if (parentClass == null) return;
|
|
@@ -2164,7 +2165,7 @@ function create$30(context) {
|
|
|
2164
2165
|
if (aValue == null || bValue == null) return false;
|
|
2165
2166
|
return ast.isNodeEqual(aValue, bValue);
|
|
2166
2167
|
}
|
|
2167
|
-
return
|
|
2168
|
+
return merge({
|
|
2168
2169
|
"JSXAttribute[name.name='key']"(node) {
|
|
2169
2170
|
const jsxElement = node.parent.parent;
|
|
2170
2171
|
switch (jsxElement.parent.type) {
|
|
@@ -2231,7 +2232,7 @@ function create$29(context) {
|
|
|
2231
2232
|
if (!context.sourceCode.text.includes("forwardRef")) return {};
|
|
2232
2233
|
const { version } = getSettingsFromContext(context);
|
|
2233
2234
|
if (compare(version, "19.0.0", "<")) return {};
|
|
2234
|
-
return
|
|
2235
|
+
return merge({ CallExpression(node) {
|
|
2235
2236
|
if (!core.isForwardRefCall(context, node)) return;
|
|
2236
2237
|
const id = ast.getFunctionId(node);
|
|
2237
2238
|
const suggest = canFix(context, node) ? [{
|
|
@@ -2348,7 +2349,7 @@ var no_implicit_children_default = createRule({
|
|
|
2348
2349
|
function create$28(context) {
|
|
2349
2350
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2350
2351
|
const checker = services.program.getTypeChecker();
|
|
2351
|
-
return
|
|
2352
|
+
return merge({ JSXSpreadAttribute(node) {
|
|
2352
2353
|
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
2353
2354
|
const children = type.getProperty("children");
|
|
2354
2355
|
if (children == null) continue;
|
|
@@ -2385,7 +2386,7 @@ var no_implicit_key_default = createRule({
|
|
|
2385
2386
|
function create$27(context) {
|
|
2386
2387
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2387
2388
|
const checker = services.program.getTypeChecker();
|
|
2388
|
-
return
|
|
2389
|
+
return merge({ JSXSpreadAttribute(node) {
|
|
2389
2390
|
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
2390
2391
|
const key = type.getProperty("key");
|
|
2391
2392
|
if (key == null) continue;
|
|
@@ -2420,7 +2421,7 @@ var no_implicit_ref_default = createRule({
|
|
|
2420
2421
|
function create$26(context) {
|
|
2421
2422
|
const services = ESLintUtils.getParserServices(context, false);
|
|
2422
2423
|
const checker = services.program.getTypeChecker();
|
|
2423
|
-
return
|
|
2424
|
+
return merge({ JSXSpreadAttribute(node) {
|
|
2424
2425
|
for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
|
|
2425
2426
|
const ref = type.getProperty("ref");
|
|
2426
2427
|
if (ref == null) continue;
|
|
@@ -2520,7 +2521,7 @@ function create$25(context) {
|
|
|
2520
2521
|
return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => null);
|
|
2521
2522
|
}).otherwise(() => null);
|
|
2522
2523
|
}
|
|
2523
|
-
return
|
|
2524
|
+
return merge({ JSXExpressionContainer: flow(getReportDescriptor, report$1(context)) });
|
|
2524
2525
|
}
|
|
2525
2526
|
|
|
2526
2527
|
//#endregion
|
|
@@ -2543,7 +2544,7 @@ function create$24(context) {
|
|
|
2543
2544
|
collectDisplayName: true,
|
|
2544
2545
|
hint: core.DEFAULT_COMPONENT_DETECTION_HINT
|
|
2545
2546
|
});
|
|
2546
|
-
return
|
|
2547
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
2547
2548
|
for (const { displayName, flag, node } of api.getAllComponents(program)) {
|
|
2548
2549
|
const id = ast.getFunctionId(node);
|
|
2549
2550
|
const isMemoOrForwardRef = (flag & (core.FunctionComponentFlag.ForwardRef | core.FunctionComponentFlag.Memo)) > 0n;
|
|
@@ -2576,7 +2577,7 @@ function create$23(context) {
|
|
|
2576
2577
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
2577
2578
|
const createCalls = [];
|
|
2578
2579
|
const displayNameAssignments = [];
|
|
2579
|
-
return
|
|
2580
|
+
return merge({
|
|
2580
2581
|
[ast.SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
2581
2582
|
displayNameAssignments.push(node);
|
|
2582
2583
|
},
|
|
@@ -2685,7 +2686,7 @@ function create$22(context) {
|
|
|
2685
2686
|
}
|
|
2686
2687
|
return descriptors;
|
|
2687
2688
|
}
|
|
2688
|
-
return
|
|
2689
|
+
return merge({
|
|
2689
2690
|
ArrayExpression(node) {
|
|
2690
2691
|
if (inChildrenToArray) return;
|
|
2691
2692
|
const elements = node.elements.filter(ast.is(AST_NODE_TYPES.JSXElement));
|
|
@@ -2741,7 +2742,7 @@ var no_misused_capture_owner_stack_default = createRule({
|
|
|
2741
2742
|
function create$21(context) {
|
|
2742
2743
|
if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
|
|
2743
2744
|
const { importSource } = getSettingsFromContext(context);
|
|
2744
|
-
return
|
|
2745
|
+
return merge({
|
|
2745
2746
|
CallExpression(node) {
|
|
2746
2747
|
if (!core.isCaptureOwnerStackCall(context, node)) return;
|
|
2747
2748
|
if (ast.findParent(node, isDevelopmentOnlyCheck) == null) context.report({
|
|
@@ -2785,7 +2786,7 @@ function create$20(context) {
|
|
|
2785
2786
|
const hint = core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.FunctionComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.FunctionComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayPatternElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayExpressionElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
|
|
2786
2787
|
const fCollector = core.getFunctionComponentCollector(context, { hint });
|
|
2787
2788
|
const cCollector = core.getClassComponentCollector(context);
|
|
2788
|
-
return
|
|
2789
|
+
return merge(fCollector.visitor, cCollector.visitor, { "Program:exit"(program) {
|
|
2789
2790
|
const fComponents = [...fCollector.api.getAllComponents(program)];
|
|
2790
2791
|
const cComponents = [...cCollector.api.getAllComponents(program)];
|
|
2791
2792
|
function findEnclosingComponent(node) {
|
|
@@ -2902,7 +2903,7 @@ function create$19(context) {
|
|
|
2902
2903
|
const cCollector = core.getClassComponentCollector(context);
|
|
2903
2904
|
const hCollector = core.getHookCollector(context);
|
|
2904
2905
|
const lazyCalls = /* @__PURE__ */ new Set();
|
|
2905
|
-
return
|
|
2906
|
+
return merge(fCollector.visitor, cCollector.visitor, hCollector.visitor, {
|
|
2906
2907
|
ImportExpression(node) {
|
|
2907
2908
|
const lazyCall = ast.findParent(node, (n) => core.isLazyCall(context, n));
|
|
2908
2909
|
if (lazyCall != null) lazyCalls.add(lazyCall);
|
|
@@ -2937,7 +2938,7 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
2937
2938
|
});
|
|
2938
2939
|
function create$18(context) {
|
|
2939
2940
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
2940
|
-
return
|
|
2941
|
+
return merge({ CallExpression(node) {
|
|
2941
2942
|
if (!core.isThisSetStateCall(node)) return;
|
|
2942
2943
|
const enclosingClassNode = ast.findParent(node, core.isClassComponent);
|
|
2943
2944
|
const enclosingMethodNode = ast.findParent(node, (n) => n === enclosingClassNode || core.isComponentDidMount(n));
|
|
@@ -2967,7 +2968,7 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
2967
2968
|
});
|
|
2968
2969
|
function create$17(context) {
|
|
2969
2970
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
2970
|
-
return
|
|
2971
|
+
return merge({ CallExpression(node) {
|
|
2971
2972
|
if (!core.isThisSetStateCall(node)) return;
|
|
2972
2973
|
const enclosingClassNode = ast.findParent(node, core.isClassComponent);
|
|
2973
2974
|
const enclosingMethodNode = ast.findParent(node, (n) => n === enclosingClassNode || core.isComponentDidUpdate(n));
|
|
@@ -2997,7 +2998,7 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
2997
2998
|
});
|
|
2998
2999
|
function create$16(context) {
|
|
2999
3000
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
3000
|
-
return
|
|
3001
|
+
return merge({ CallExpression(node) {
|
|
3001
3002
|
if (!core.isThisSetStateCall(node)) return;
|
|
3002
3003
|
const enclosingClassNode = ast.findParent(node, core.isClassComponent);
|
|
3003
3004
|
const enclosingMethodNode = ast.findParent(node, (n) => n === enclosingClassNode || core.isComponentWillUpdate(n));
|
|
@@ -3031,7 +3032,7 @@ var no_unnecessary_use_prefix_default = createRule({
|
|
|
3031
3032
|
});
|
|
3032
3033
|
function create$15(context) {
|
|
3033
3034
|
const { api, visitor } = core.getHookCollector(context);
|
|
3034
|
-
return
|
|
3035
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
3035
3036
|
for (const { id, name, hookCalls, node } of api.getAllHooks(program)) {
|
|
3036
3037
|
if (name == null) continue;
|
|
3037
3038
|
if (hookCalls.length > 0) continue;
|
|
@@ -3065,7 +3066,7 @@ var no_unsafe_component_will_mount_default = createRule({
|
|
|
3065
3066
|
function create$14(context) {
|
|
3066
3067
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
|
|
3067
3068
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
3068
|
-
return
|
|
3069
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
3069
3070
|
for (const { node: component } of api.getAllComponents(program)) {
|
|
3070
3071
|
const { body } = component.body;
|
|
3071
3072
|
for (const member of body) if (core.isUnsafeComponentWillMount(member)) context.report({
|
|
@@ -3093,7 +3094,7 @@ var no_unsafe_component_will_receive_props_default = createRule({
|
|
|
3093
3094
|
function create$13(context) {
|
|
3094
3095
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
|
|
3095
3096
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
3096
|
-
return
|
|
3097
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
3097
3098
|
for (const { node: component } of api.getAllComponents(program)) {
|
|
3098
3099
|
const { body } = component.body;
|
|
3099
3100
|
for (const member of body) if (core.isUnsafeComponentWillReceiveProps(member)) context.report({
|
|
@@ -3121,7 +3122,7 @@ var no_unsafe_component_will_update_default = createRule({
|
|
|
3121
3122
|
function create$12(context) {
|
|
3122
3123
|
if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
|
|
3123
3124
|
const { api, visitor } = core.getClassComponentCollector(context);
|
|
3124
|
-
return
|
|
3125
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
3125
3126
|
for (const { node: component } of api.getAllComponents(program)) {
|
|
3126
3127
|
const { body } = component.body;
|
|
3127
3128
|
for (const member of body) if (core.isUnsafeComponentWillUpdate(member)) context.report({
|
|
@@ -3153,7 +3154,7 @@ function create$11(context) {
|
|
|
3153
3154
|
const isReact18OrBelow = compare(version, "19.0.0", "<");
|
|
3154
3155
|
const { api, visitor } = core.getFunctionComponentCollector(context);
|
|
3155
3156
|
const constructions = /* @__PURE__ */ new WeakMap();
|
|
3156
|
-
return
|
|
3157
|
+
return merge(visitor, {
|
|
3157
3158
|
JSXOpeningElement(node) {
|
|
3158
3159
|
const selfName = getElementFullType(node.parent).split(".").at(-1);
|
|
3159
3160
|
if (selfName == null) return;
|
|
@@ -3235,7 +3236,7 @@ function create$10(context, [options]) {
|
|
|
3235
3236
|
const declarators = /* @__PURE__ */ new WeakMap();
|
|
3236
3237
|
const { safeDefaultProps = [] } = options;
|
|
3237
3238
|
const safePatterns = safeDefaultProps.map((s) => toRegExp(s));
|
|
3238
|
-
return
|
|
3239
|
+
return merge(visitor, {
|
|
3239
3240
|
[ast.SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR](node) {
|
|
3240
3241
|
const enclosingFunction = ast.findParent(node, ast.isFunction);
|
|
3241
3242
|
if (enclosingFunction == null) return;
|
|
@@ -3350,7 +3351,7 @@ function create$9(context) {
|
|
|
3350
3351
|
function methodExit() {
|
|
3351
3352
|
methodStack.pop();
|
|
3352
3353
|
}
|
|
3353
|
-
return
|
|
3354
|
+
return merge({
|
|
3354
3355
|
ClassDeclaration: classEnter,
|
|
3355
3356
|
"ClassDeclaration:exit": classExit,
|
|
3356
3357
|
ClassExpression: classEnter,
|
|
@@ -3405,7 +3406,7 @@ function create$8(context) {
|
|
|
3405
3406
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3406
3407
|
const checker = services.program.getTypeChecker();
|
|
3407
3408
|
const { api, visitor } = core.getFunctionComponentCollector(context);
|
|
3408
|
-
return
|
|
3409
|
+
return merge(visitor, { "Program:exit"(program) {
|
|
3409
3410
|
const totalDeclaredProps = /* @__PURE__ */ new Map();
|
|
3410
3411
|
const totalUsedDeclarations = /* @__PURE__ */ new Set();
|
|
3411
3412
|
for (const component of api.getAllComponents(program)) {
|
|
@@ -3523,7 +3524,7 @@ function create$7(context) {
|
|
|
3523
3524
|
if (!context.sourceCode.text.includes("useContext")) return {};
|
|
3524
3525
|
const { version } = getSettingsFromContext(context);
|
|
3525
3526
|
if (compare(version, "19.0.0", "<")) return {};
|
|
3526
|
-
return
|
|
3527
|
+
return merge({ CallExpression(node) {
|
|
3527
3528
|
if (!core.isUseContextCall(context, node)) return;
|
|
3528
3529
|
context.report({
|
|
3529
3530
|
messageId: "default",
|
|
@@ -3845,7 +3846,7 @@ function create$6(context) {
|
|
|
3845
3846
|
const cCollector = core.getFunctionComponentCollector(context);
|
|
3846
3847
|
const cEntries = [];
|
|
3847
3848
|
const nEntries = [];
|
|
3848
|
-
return
|
|
3849
|
+
return merge(hCollector.visitor, cCollector.visitor, {
|
|
3849
3850
|
CallExpression(node) {
|
|
3850
3851
|
const expr = ast.getUnderlyingExpression(node.callee);
|
|
3851
3852
|
switch (true) {
|
|
@@ -3968,7 +3969,7 @@ function create$5(context) {
|
|
|
3968
3969
|
}
|
|
3969
3970
|
return false;
|
|
3970
3971
|
}
|
|
3971
|
-
return
|
|
3972
|
+
return merge(hCollector.visitor, cCollector.visitor, {
|
|
3972
3973
|
JSXAttribute(node) {
|
|
3973
3974
|
switch (true) {
|
|
3974
3975
|
case node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name === "ref" && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === AST_NODE_TYPES.Identifier:
|
|
@@ -6310,7 +6311,7 @@ function create$4(context) {
|
|
|
6310
6311
|
}
|
|
6311
6312
|
return false;
|
|
6312
6313
|
}
|
|
6313
|
-
return
|
|
6314
|
+
return merge({
|
|
6314
6315
|
":function"(node) {
|
|
6315
6316
|
const kind = getFunctionKind(node);
|
|
6316
6317
|
functionEntries.push({
|
|
@@ -6516,7 +6517,7 @@ function create$3(context) {
|
|
|
6516
6517
|
if (parent.type === AST_NODE_TYPES.CallExpression && parent.callee !== node) return "callback";
|
|
6517
6518
|
return "other";
|
|
6518
6519
|
}
|
|
6519
|
-
return
|
|
6520
|
+
return merge({
|
|
6520
6521
|
":function"(node) {
|
|
6521
6522
|
const kind = getFunctionKind(node);
|
|
6522
6523
|
functionEntries.push({
|
|
@@ -6595,7 +6596,7 @@ function create$2(context) {
|
|
|
6595
6596
|
const cCollector = core.getFunctionComponentCollector(context);
|
|
6596
6597
|
const evalCalls = [];
|
|
6597
6598
|
const withStmts = [];
|
|
6598
|
-
return
|
|
6599
|
+
return merge(hCollector.visitor, cCollector.visitor, {
|
|
6599
6600
|
CallExpression(node) {
|
|
6600
6601
|
if (!isEvalCall(node)) return;
|
|
6601
6602
|
const func = ast.findParent(node, ast.isFunction);
|
|
@@ -6666,7 +6667,7 @@ var use_memo_default = createRule({
|
|
|
6666
6667
|
});
|
|
6667
6668
|
function create$1(context) {
|
|
6668
6669
|
if (!context.sourceCode.text.includes("useMemo")) return {};
|
|
6669
|
-
return
|
|
6670
|
+
return merge({ CallExpression(node) {
|
|
6670
6671
|
if (!core.isUseMemoCall(context, node)) return;
|
|
6671
6672
|
let parent = node.parent;
|
|
6672
6673
|
while (ast.isTypeExpression(parent)) parent = parent.parent;
|
|
@@ -6746,7 +6747,7 @@ var use_state_default = createRule({
|
|
|
6746
6747
|
function create(context) {
|
|
6747
6748
|
const { enforceAssignment = true, enforceLazyInitialization = true, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
|
|
6748
6749
|
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
6749
|
-
return
|
|
6750
|
+
return merge({ CallExpression(node) {
|
|
6750
6751
|
if (!core.isUseStateLikeCall(node, additionalStateHooks)) return;
|
|
6751
6752
|
if (enforceLazyInitialization) {
|
|
6752
6753
|
const [useStateInput] = node.arguments;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0-beta.1",
|
|
4
4
|
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "git+https://github.com/Rel1cx/eslint-react.git",
|
|
19
|
-
"directory": "packages/
|
|
19
|
+
"directory": "packages/eslint-plugin-react-x"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "Rel1cx",
|
|
@@ -37,19 +37,20 @@
|
|
|
37
37
|
"./package.json"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@typescript-eslint/scope-manager": "^8.58.
|
|
41
|
-
"@typescript-eslint/type-utils": "^8.58.
|
|
42
|
-
"@typescript-eslint/types": "^8.58.
|
|
43
|
-
"@typescript-eslint/utils": "^8.58.
|
|
40
|
+
"@typescript-eslint/scope-manager": "^8.58.1",
|
|
41
|
+
"@typescript-eslint/type-utils": "^8.58.1",
|
|
42
|
+
"@typescript-eslint/types": "^8.58.1",
|
|
43
|
+
"@typescript-eslint/utils": "^8.58.1",
|
|
44
44
|
"compare-versions": "^6.1.1",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-api-utils": "^2.5.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "5.0
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/ast": "5.1.0-beta.1",
|
|
49
|
+
"@eslint-react/jsx": "5.1.0-beta.1",
|
|
50
|
+
"@eslint-react/shared": "5.1.0-beta.1",
|
|
51
|
+
"@eslint-react/var": "5.1.0-beta.1",
|
|
52
|
+
"@eslint-react/eslint": "5.1.0-beta.1",
|
|
53
|
+
"@eslint-react/core": "5.1.0-beta.1"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@types/react": "^19.2.14",
|
|
@@ -57,8 +58,8 @@
|
|
|
57
58
|
"eslint": "^10.2.0",
|
|
58
59
|
"tsdown": "^0.21.7",
|
|
59
60
|
"tsl-dx": "^0.10.3",
|
|
60
|
-
"@local/
|
|
61
|
-
"@local/
|
|
61
|
+
"@local/configs": "0.0.0",
|
|
62
|
+
"@local/eff": "3.0.0-beta.72"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"eslint": "^10.2.0",
|