eslint-plugin-react-x 5.8.7-beta.4 → 5.8.7-beta.5
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 +34 -16
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -143,7 +143,7 @@ const rules$6 = {
|
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region package.json
|
|
145
145
|
var name$6 = "eslint-plugin-react-x";
|
|
146
|
-
var version = "5.8.7-beta.
|
|
146
|
+
var version = "5.8.7-beta.5";
|
|
147
147
|
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/utils/create-rule.ts
|
|
@@ -2236,7 +2236,7 @@ const RULE_NAME$34 = "no-create-ref";
|
|
|
2236
2236
|
var no_create_ref_default = createRule({
|
|
2237
2237
|
meta: {
|
|
2238
2238
|
type: "suggestion",
|
|
2239
|
-
docs: { description: "Disallows 'createRef' in function components." },
|
|
2239
|
+
docs: { description: "Disallows 'createRef' in function components and Hooks." },
|
|
2240
2240
|
messages: { default: "[Deprecated] Use 'useRef' instead." },
|
|
2241
2241
|
schema: []
|
|
2242
2242
|
},
|
|
@@ -2245,12 +2245,28 @@ var no_create_ref_default = createRule({
|
|
|
2245
2245
|
defaultOptions: []
|
|
2246
2246
|
});
|
|
2247
2247
|
function create$34(context) {
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2248
|
+
if (!context.sourceCode.text.includes("createRef")) return {};
|
|
2249
|
+
const fc = core.getFunctionComponentCollector(context);
|
|
2250
|
+
const hc = core.getHookCollector(context);
|
|
2251
|
+
const createRefCalls = /* @__PURE__ */ new Set();
|
|
2252
|
+
return merge(fc.visitor, hc.visitor, {
|
|
2253
|
+
CallExpression(node) {
|
|
2254
|
+
if (!core.isCreateRefCall(context, node)) return;
|
|
2255
|
+
createRefCalls.add(node);
|
|
2256
|
+
},
|
|
2257
|
+
"Program:exit"(node) {
|
|
2258
|
+
const comps = fc.api.getAllComponents(node);
|
|
2259
|
+
const hooks = hc.api.getAllHooks(node);
|
|
2260
|
+
const funcs = [...comps, ...hooks];
|
|
2261
|
+
for (const call of createRefCalls) {
|
|
2262
|
+
if (Traverse.findParent(call, (n) => funcs.some((f) => f.node === n)) == null) continue;
|
|
2263
|
+
context.report({
|
|
2264
|
+
messageId: "default",
|
|
2265
|
+
node: call
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2254
2270
|
}
|
|
2255
2271
|
|
|
2256
2272
|
//#endregion
|
|
@@ -2891,30 +2907,32 @@ function create$24(context) {
|
|
|
2891
2907
|
//#region src/rules/no-misused-capture-owner-stack/lib.ts
|
|
2892
2908
|
/**
|
|
2893
2909
|
* Check if the given node is a member expression that accesses `process.env.NODE_ENV`
|
|
2910
|
+
* @param context The rule context
|
|
2894
2911
|
* @param node The AST node
|
|
2895
2912
|
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
2896
2913
|
*/
|
|
2897
|
-
function isProcessEnvNodeEnv(node) {
|
|
2898
|
-
return node != null &&
|
|
2914
|
+
function isProcessEnvNodeEnv(context, node) {
|
|
2915
|
+
return node != null && core.isAPI("process.env.NODE_ENV")(context, node);
|
|
2899
2916
|
}
|
|
2900
2917
|
/**
|
|
2901
2918
|
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
|
|
2919
|
+
* @param context The rule context
|
|
2902
2920
|
* @param node The AST node
|
|
2903
2921
|
* @param operator The operator used in the comparison
|
|
2904
2922
|
* @param value The string literal value to compare against
|
|
2905
2923
|
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
2906
2924
|
*/
|
|
2907
|
-
function isProcessEnvNodeEnvCompare(node, operator, value) {
|
|
2925
|
+
function isProcessEnvNodeEnvCompare(context, node, operator, value) {
|
|
2908
2926
|
if (node == null) return false;
|
|
2909
2927
|
if (node.type !== AST_NODE_TYPES.BinaryExpression) return false;
|
|
2910
2928
|
if (node.operator !== operator) return false;
|
|
2911
|
-
if (isProcessEnvNodeEnv(node.left) && Check.isStringLiteral(node.right)) return node.right.value === value;
|
|
2912
|
-
if (Check.isStringLiteral(node.left) && isProcessEnvNodeEnv(node.right)) return node.left.value === value;
|
|
2929
|
+
if (isProcessEnvNodeEnv(context, node.left) && Check.isStringLiteral(node.right)) return node.right.value === value;
|
|
2930
|
+
if (Check.isStringLiteral(node.left) && isProcessEnvNodeEnv(context, node.right)) return node.left.value === value;
|
|
2913
2931
|
return false;
|
|
2914
2932
|
}
|
|
2915
|
-
function isDevelopmentOnlyCheck(node) {
|
|
2933
|
+
function isDevelopmentOnlyCheck(context, node) {
|
|
2916
2934
|
if (node.type !== AST_NODE_TYPES.IfStatement) return false;
|
|
2917
|
-
return isProcessEnvNodeEnvCompare(node.test, "!==", "production");
|
|
2935
|
+
return isProcessEnvNodeEnvCompare(context, node.test, "!==", "production");
|
|
2918
2936
|
}
|
|
2919
2937
|
|
|
2920
2938
|
//#endregion
|
|
@@ -2940,7 +2958,7 @@ function create$23(context) {
|
|
|
2940
2958
|
return merge({
|
|
2941
2959
|
CallExpression(node) {
|
|
2942
2960
|
if (!core.isCaptureOwnerStackCall(context, node)) return;
|
|
2943
|
-
if (Traverse.findParent(node, isDevelopmentOnlyCheck) == null) context.report({
|
|
2961
|
+
if (Traverse.findParent(node, (n) => isDevelopmentOnlyCheck(context, n)) == null) context.report({
|
|
2944
2962
|
messageId: "missingDevelopmentOnlyCheck",
|
|
2945
2963
|
node
|
|
2946
2964
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.8.7-beta.
|
|
3
|
+
"version": "5.8.7-beta.5",
|
|
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,12 +45,12 @@
|
|
|
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/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/jsx": "5.8.7-beta.
|
|
52
|
-
"@eslint-react/shared": "5.8.7-beta.
|
|
53
|
-
"@eslint-react/var": "5.8.7-beta.
|
|
48
|
+
"@eslint-react/core": "5.8.7-beta.5",
|
|
49
|
+
"@eslint-react/eslint": "5.8.7-beta.5",
|
|
50
|
+
"@eslint-react/ast": "5.8.7-beta.5",
|
|
51
|
+
"@eslint-react/jsx": "5.8.7-beta.5",
|
|
52
|
+
"@eslint-react/shared": "5.8.7-beta.5",
|
|
53
|
+
"@eslint-react/var": "5.8.7-beta.5"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.15",
|