eslint-plugin-react-x 4.2.4-beta.0 → 4.2.5-beta.0
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.js +22 -12
- package/package.json +6 -6
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -145,7 +145,7 @@ const rules$7 = {
|
|
|
145
145
|
//#endregion
|
|
146
146
|
//#region package.json
|
|
147
147
|
var name$6 = "eslint-plugin-react-x";
|
|
148
|
-
var version = "4.2.
|
|
148
|
+
var version = "4.2.5-beta.0";
|
|
149
149
|
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/utils/create-rule.ts
|
|
@@ -429,22 +429,31 @@ var error_boundaries_default = createRule({
|
|
|
429
429
|
function create$53(context) {
|
|
430
430
|
if (!context.sourceCode.text.includes("try")) return {};
|
|
431
431
|
const hint = JsxDetectionHint.DoNotIncludeJsxWithNullValue | JsxDetectionHint.DoNotIncludeJsxWithNumberValue | JsxDetectionHint.DoNotIncludeJsxWithBigIntValue | JsxDetectionHint.DoNotIncludeJsxWithStringValue | JsxDetectionHint.DoNotIncludeJsxWithBooleanValue | JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue | JsxDetectionHint.DoNotIncludeJsxWithEmptyArrayValue;
|
|
432
|
-
const
|
|
432
|
+
const fCollector = core.getComponentCollector(context);
|
|
433
|
+
const hCollector = core.getHookCollector(context);
|
|
433
434
|
const reported = /* @__PURE__ */ new Set();
|
|
434
|
-
|
|
435
|
+
const useCalls = /* @__PURE__ */ new Set();
|
|
436
|
+
return defineRuleListener(fCollector.visitor, hCollector.visitor, {
|
|
435
437
|
CallExpression(node) {
|
|
436
438
|
if (!core.isUseCall(node)) return;
|
|
437
|
-
|
|
438
|
-
if (stmt != null && !reported.has(stmt)) {
|
|
439
|
-
context.report({
|
|
440
|
-
messageId: "tryCatchWithUse",
|
|
441
|
-
node
|
|
442
|
-
});
|
|
443
|
-
reported.add(stmt);
|
|
444
|
-
}
|
|
439
|
+
useCalls.add(node);
|
|
445
440
|
},
|
|
446
441
|
"Program:exit"(node) {
|
|
447
|
-
|
|
442
|
+
const comps = fCollector.api.getAllComponents(node);
|
|
443
|
+
const hooks = hCollector.api.getAllHooks(node);
|
|
444
|
+
const funcs = [...comps, ...hooks];
|
|
445
|
+
for (const call of useCalls) {
|
|
446
|
+
const stmt = ast.findParent(call, ast.is(AST_NODE_TYPES.TryStatement));
|
|
447
|
+
const func = ast.findParent(stmt, (n) => funcs.some((f) => f.node === n));
|
|
448
|
+
if (stmt != null && func != null && !reported.has(stmt)) {
|
|
449
|
+
context.report({
|
|
450
|
+
messageId: "tryCatchWithUse",
|
|
451
|
+
node: stmt
|
|
452
|
+
});
|
|
453
|
+
reported.add(stmt);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
for (const { rets } of funcs) for (const ret of rets) {
|
|
448
457
|
if (ret == null) continue;
|
|
449
458
|
if (!isJsxLike(context, ret, hint)) continue;
|
|
450
459
|
const stmt = ast.findParent(ret, ast.is(AST_NODE_TYPES.TryStatement));
|
|
@@ -3340,6 +3349,7 @@ function create$18(context) {
|
|
|
3340
3349
|
const { api, visitor } = core.getHookCollector(context);
|
|
3341
3350
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
3342
3351
|
for (const { id, name, hookCalls, node } of api.getAllHooks(program)) {
|
|
3352
|
+
if (name == null) continue;
|
|
3343
3353
|
if (hookCalls.length > 0) continue;
|
|
3344
3354
|
if (ast.isFunctionEmpty(node)) continue;
|
|
3345
3355
|
if (WELL_KNOWN_HOOKS.includes(name)) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.5-beta.0",
|
|
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
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-api-utils": "^2.5.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "4.2.
|
|
49
|
-
"@eslint-react/core": "4.2.
|
|
50
|
-
"@eslint-react/shared": "4.2.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/ast": "4.2.5-beta.0",
|
|
49
|
+
"@eslint-react/core": "4.2.5-beta.0",
|
|
50
|
+
"@eslint-react/shared": "4.2.5-beta.0",
|
|
51
|
+
"@eslint-react/var": "4.2.5-beta.0",
|
|
52
|
+
"@eslint-react/jsx": "4.2.5-beta.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.14",
|