eslint-plugin-react-x 3.0.0-next.17 → 3.0.0-next.19
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 +19 -15
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ const rules$7 = {
|
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region package.json
|
|
71
71
|
var name$6 = "eslint-plugin-react-x";
|
|
72
|
-
var version = "3.0.0-next.
|
|
72
|
+
var version = "3.0.0-next.19";
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/utils/create-rule.ts
|
|
@@ -2787,18 +2787,20 @@ function create$17(context) {
|
|
|
2787
2787
|
getOrElseUpdate(constructions, functionEntry.node, () => []).push(construction);
|
|
2788
2788
|
},
|
|
2789
2789
|
"Program:exit"(program) {
|
|
2790
|
-
for (const { node: component, directives } of ctx.getAllComponents(program))
|
|
2791
|
-
if (directives.some((d) => d.directive === "use memo"))
|
|
2792
|
-
const
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2790
|
+
for (const { node: component, directives } of ctx.getAllComponents(program)) {
|
|
2791
|
+
if (compilationMode === "annotation" && directives.some((d) => d.directive === "use memo")) continue;
|
|
2792
|
+
for (const construction of constructions.get(component) ?? []) {
|
|
2793
|
+
const { kind, node: constructionNode } = construction;
|
|
2794
|
+
const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
|
|
2795
|
+
context.report({
|
|
2796
|
+
messageId: "unstableContextValue",
|
|
2797
|
+
node: constructionNode,
|
|
2798
|
+
data: {
|
|
2799
|
+
kind: ast.getHumanReadableKind(constructionNode),
|
|
2800
|
+
suggestion
|
|
2801
|
+
}
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2802
2804
|
}
|
|
2803
2805
|
}
|
|
2804
2806
|
});
|
|
@@ -3016,9 +3018,9 @@ var no_unused_props_default = createRule({
|
|
|
3016
3018
|
});
|
|
3017
3019
|
function create$14(context) {
|
|
3018
3020
|
const services = ESLintUtils.getParserServices(context, false);
|
|
3021
|
+
const checker = services.program.getTypeChecker();
|
|
3019
3022
|
const { ctx, visitor } = core.useComponentCollector(context);
|
|
3020
3023
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
3021
|
-
const checker = services.program.getTypeChecker();
|
|
3022
3024
|
const totalDeclaredProps = /* @__PURE__ */ new Set();
|
|
3023
3025
|
const totalUsedProps = /* @__PURE__ */ new Set();
|
|
3024
3026
|
for (const component of ctx.getAllComponents(program)) {
|
|
@@ -3093,7 +3095,9 @@ function collectUsedPropKeysOfReference(context, usedPropKeys, identifier, ref)
|
|
|
3093
3095
|
function getKeyOfExpression(expr) {
|
|
3094
3096
|
switch (expr.type) {
|
|
3095
3097
|
case AST_NODE_TYPES.Identifier: return expr.name;
|
|
3096
|
-
case AST_NODE_TYPES.Literal:
|
|
3098
|
+
case AST_NODE_TYPES.Literal:
|
|
3099
|
+
if (typeof expr.value === "string") return expr.value;
|
|
3100
|
+
break;
|
|
3097
3101
|
}
|
|
3098
3102
|
return null;
|
|
3099
3103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.19",
|
|
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",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"is-immutable-type": "^5.0.1",
|
|
46
46
|
"ts-api-utils": "^2.4.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/ast": "3.0.0-next.19",
|
|
49
|
+
"@eslint-react/core": "3.0.0-next.19",
|
|
50
|
+
"@eslint-react/eff": "3.0.0-next.19",
|
|
51
|
+
"@eslint-react/shared": "3.0.0-next.19",
|
|
52
|
+
"@eslint-react/var": "3.0.0-next.19"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.14",
|