eslint-plugin-react-web-api 5.30.2 → 5.30.3
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 +18 -26
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __exportAll = (all, flags) => {
|
|
|
20
20
|
};
|
|
21
21
|
// package.json
|
|
22
22
|
var name$1 = "eslint-plugin-react-web-api";
|
|
23
|
-
var version = "5.30.
|
|
23
|
+
var version = "5.30.3";
|
|
24
24
|
// src/utils/create-rule.ts
|
|
25
25
|
function getDocsUrl(ruleName) {
|
|
26
26
|
return `https://eslint-react.xyz/docs/rules/web-api-${ruleName}`;
|
|
@@ -465,36 +465,28 @@ function resolveToObjectExpression(context, node) {
|
|
|
465
465
|
function isGlobalObject(node) {
|
|
466
466
|
return Check.isIdentifier(node) && (node.name === "window" || node.name === "globalThis" || node.name === "self");
|
|
467
467
|
}
|
|
468
|
-
function
|
|
469
|
-
let current = node.parent;
|
|
470
|
-
while (current != null) {
|
|
471
|
-
if (scopeBindsName(current, name)) return true;
|
|
472
|
-
current = current.parent;
|
|
473
|
-
}
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
476
|
-
function scopeBindsName(node, name) {
|
|
468
|
+
function isNameBoundInScope(name, node) {
|
|
477
469
|
switch (node.type) {
|
|
478
470
|
case AST_NODE_TYPES.FunctionDeclaration:
|
|
479
|
-
case AST_NODE_TYPES.ArrowFunctionExpression: return node.params.some((param) =>
|
|
480
|
-
case AST_NODE_TYPES.FunctionExpression: return node.id?.name === name || node.params.some((param) =>
|
|
481
|
-
case AST_NODE_TYPES.CatchClause: return node.param != null &&
|
|
471
|
+
case AST_NODE_TYPES.ArrowFunctionExpression: return node.params.some((param) => isNameBoundInPattern(name, param));
|
|
472
|
+
case AST_NODE_TYPES.FunctionExpression: return node.id?.name === name || node.params.some((param) => isNameBoundInPattern(name, param));
|
|
473
|
+
case AST_NODE_TYPES.CatchClause: return node.param != null && isNameBoundInPattern(name, node.param);
|
|
482
474
|
case AST_NODE_TYPES.BlockStatement:
|
|
483
475
|
case AST_NODE_TYPES.Program:
|
|
484
|
-
case AST_NODE_TYPES.StaticBlock: return node.body.some((statement) =>
|
|
485
|
-
case AST_NODE_TYPES.ForStatement: return node.init?.type === AST_NODE_TYPES.VariableDeclaration &&
|
|
476
|
+
case AST_NODE_TYPES.StaticBlock: return node.body.some((statement) => isNameBoundInStatement(name, statement));
|
|
477
|
+
case AST_NODE_TYPES.ForStatement: return node.init?.type === AST_NODE_TYPES.VariableDeclaration && isNameBoundInStatement(name, node.init);
|
|
486
478
|
case AST_NODE_TYPES.ForInStatement:
|
|
487
|
-
case AST_NODE_TYPES.ForOfStatement: return node.left.type === AST_NODE_TYPES.VariableDeclaration &&
|
|
479
|
+
case AST_NODE_TYPES.ForOfStatement: return node.left.type === AST_NODE_TYPES.VariableDeclaration && isNameBoundInStatement(name, node.left);
|
|
488
480
|
default: return false;
|
|
489
481
|
}
|
|
490
482
|
}
|
|
491
|
-
function
|
|
483
|
+
function isNameBoundInStatement(name, statement) {
|
|
492
484
|
switch (statement.type) {
|
|
493
485
|
case AST_NODE_TYPES.FunctionDeclaration:
|
|
494
486
|
case AST_NODE_TYPES.ClassDeclaration: return statement.id?.name === name;
|
|
495
|
-
case AST_NODE_TYPES.VariableDeclaration: return statement.declarations.some((declarator) =>
|
|
487
|
+
case AST_NODE_TYPES.VariableDeclaration: return statement.declarations.some((declarator) => isNameBoundInPattern(name, declarator.id));
|
|
496
488
|
case AST_NODE_TYPES.ImportDeclaration: return statement.specifiers.some((specifier) => specifier.local.name === name);
|
|
497
|
-
case AST_NODE_TYPES.ExportNamedDeclaration: return statement.declaration != null &&
|
|
489
|
+
case AST_NODE_TYPES.ExportNamedDeclaration: return statement.declaration != null && isNameBoundInStatement(name, statement.declaration);
|
|
498
490
|
case AST_NODE_TYPES.ExportDefaultDeclaration: return (statement.declaration.type === AST_NODE_TYPES.FunctionDeclaration || statement.declaration.type === AST_NODE_TYPES.ClassDeclaration) && statement.declaration.id?.name === name;
|
|
499
491
|
case AST_NODE_TYPES.TSImportEqualsDeclaration:
|
|
500
492
|
case AST_NODE_TYPES.TSEnumDeclaration: return statement.id.name === name;
|
|
@@ -502,14 +494,14 @@ function statementBindsName(statement, name) {
|
|
|
502
494
|
default: return false;
|
|
503
495
|
}
|
|
504
496
|
}
|
|
505
|
-
function
|
|
497
|
+
function isNameBoundInPattern(name, pattern) {
|
|
506
498
|
switch (pattern.type) {
|
|
507
499
|
case AST_NODE_TYPES.Identifier: return pattern.name === name;
|
|
508
|
-
case AST_NODE_TYPES.ArrayPattern: return pattern.elements.some((element) => element != null &&
|
|
509
|
-
case AST_NODE_TYPES.ObjectPattern: return pattern.properties.some((property) => property.type === AST_NODE_TYPES.RestElement ?
|
|
510
|
-
case AST_NODE_TYPES.AssignmentPattern: return
|
|
511
|
-
case AST_NODE_TYPES.RestElement: return
|
|
512
|
-
case AST_NODE_TYPES.TSParameterProperty: return
|
|
500
|
+
case AST_NODE_TYPES.ArrayPattern: return pattern.elements.some((element) => element != null && isNameBoundInPattern(name, element));
|
|
501
|
+
case AST_NODE_TYPES.ObjectPattern: return pattern.properties.some((property) => property.type === AST_NODE_TYPES.RestElement ? isNameBoundInPattern(name, property.argument) : isNameBoundInPattern(name, property.value));
|
|
502
|
+
case AST_NODE_TYPES.AssignmentPattern: return isNameBoundInPattern(name, pattern.left);
|
|
503
|
+
case AST_NODE_TYPES.RestElement: return isNameBoundInPattern(name, pattern.argument);
|
|
504
|
+
case AST_NODE_TYPES.TSParameterProperty: return isNameBoundInPattern(name, pattern.parameter);
|
|
513
505
|
default: return false;
|
|
514
506
|
}
|
|
515
507
|
}
|
|
@@ -576,7 +568,7 @@ const isUseEffectCallback$4 = or(isUseEffectSetupCallback, isUseEffectCleanupCal
|
|
|
576
568
|
function getCallKind$4(node) {
|
|
577
569
|
const callee = Extract.unwrap(node.callee);
|
|
578
570
|
switch (true) {
|
|
579
|
-
case Check.isIdentifier(callee, "fetch") && !
|
|
571
|
+
case Check.isIdentifier(callee, "fetch") && !Traverse.hasParent(node, (n) => isNameBoundInScope("fetch", n)): return "fetch";
|
|
580
572
|
case callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && Check.isIdentifier(callee.property, "fetch") && isGlobalObject(Extract.unwrap(callee.object)): return "fetch";
|
|
581
573
|
case Extract.getCalleeName(node) === "abort": return "abort";
|
|
582
574
|
default: return "other";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "5.30.
|
|
3
|
+
"version": "5.30.3",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@eslint-react/ast": "5.30.
|
|
41
|
-
"@eslint-react/core": "5.30.
|
|
42
|
-
"@eslint-react/eslint": "5.30.
|
|
43
|
-
"@eslint-react/shared": "5.30.
|
|
44
|
-
"@eslint-react/var": "5.30.
|
|
40
|
+
"@eslint-react/ast": "5.30.3",
|
|
41
|
+
"@eslint-react/core": "5.30.3",
|
|
42
|
+
"@eslint-react/eslint": "5.30.3",
|
|
43
|
+
"@eslint-react/shared": "5.30.3",
|
|
44
|
+
"@eslint-react/var": "5.30.3",
|
|
45
45
|
"@typescript-eslint/types": "^8.72.2",
|
|
46
46
|
"@typescript-eslint/utils": "^8.72.2",
|
|
47
47
|
"ts-pattern": "^5.9.2"
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"@local/configs": "0.0.0",
|
|
51
51
|
"@local/eff": "0.0.0",
|
|
52
52
|
"@local/testkit": "0.0.0",
|
|
53
|
-
"@tsconfig/node20": "^20.1.
|
|
53
|
+
"@tsconfig/node20": "^20.1.11",
|
|
54
54
|
"@types/node": "^20.19.43",
|
|
55
55
|
"@types/react": "^19.3.0",
|
|
56
56
|
"@types/react-dom": "^19.3.0",
|
|
57
57
|
"dedent": "^1.7.2",
|
|
58
|
-
"eslint": "^10.
|
|
58
|
+
"eslint": "^10.15.0",
|
|
59
59
|
"tsdown": "^0.23.7",
|
|
60
60
|
"typescript": "6.0.3"
|
|
61
61
|
},
|