eslint-plugin-react-web-api 1.48.3-next.1 → 2.0.0-next.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/dist/index.js +21 -2
- package/dist/index.mjs +21 -2
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var eff = require('@eslint-react/eff');
|
|
|
7
7
|
var VAR = require('@eslint-react/var');
|
|
8
8
|
var utils = require('@typescript-eslint/utils');
|
|
9
9
|
var tsPattern = require('ts-pattern');
|
|
10
|
+
var types = require('@typescript-eslint/types');
|
|
10
11
|
|
|
11
12
|
function _interopNamespace(e) {
|
|
12
13
|
if (e && e.__esModule) return e;
|
|
@@ -56,10 +57,28 @@ var settings = {
|
|
|
56
57
|
|
|
57
58
|
// package.json
|
|
58
59
|
var name2 = "eslint-plugin-react-web-api";
|
|
59
|
-
var version = "
|
|
60
|
+
var version = "2.0.0-next.0";
|
|
60
61
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("web-api"));
|
|
61
62
|
function getPhaseKindOfFunction(node) {
|
|
62
|
-
return tsPattern.match(node).when(
|
|
63
|
+
return tsPattern.match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfUseEffectCleanup, () => "cleanup").when(isFunctionOfComponentDidMount, () => "mount").when(isFunctionOfComponentWillUnmount, () => "unmount").otherwise(() => null);
|
|
64
|
+
}
|
|
65
|
+
function isFunctionOfUseEffectSetup(node) {
|
|
66
|
+
if (node == null) return false;
|
|
67
|
+
return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === types.AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && ER4__namespace.isUseEffectCallLoose(node.parent);
|
|
68
|
+
}
|
|
69
|
+
function isFunctionOfUseEffectCleanup(node) {
|
|
70
|
+
if (node == null) return false;
|
|
71
|
+
const pReturn = AST__namespace.findParentNode(node, AST__namespace.is(types.AST_NODE_TYPES.ReturnStatement));
|
|
72
|
+
const pFunction = AST__namespace.findParentNode(node, AST__namespace.isFunction);
|
|
73
|
+
const pFunctionOfReturn = AST__namespace.findParentNode(pReturn, AST__namespace.isFunction);
|
|
74
|
+
if (pFunction !== pFunctionOfReturn) return false;
|
|
75
|
+
return isFunctionOfUseEffectSetup(pFunction);
|
|
76
|
+
}
|
|
77
|
+
function isFunctionOfComponentDidMount(node) {
|
|
78
|
+
return AST__namespace.isFunction(node) && ER4__namespace.isComponentDidMount(node.parent) && node.parent.value === node;
|
|
79
|
+
}
|
|
80
|
+
function isFunctionOfComponentWillUnmount(node) {
|
|
81
|
+
return AST__namespace.isFunction(node) && ER4__namespace.isComponentWillUnmount(node.parent) && node.parent.value === node;
|
|
63
82
|
}
|
|
64
83
|
|
|
65
84
|
// src/rules/no-leaked-event-listener.ts
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { _, or } from '@eslint-react/eff';
|
|
|
5
5
|
import * as VAR from '@eslint-react/var';
|
|
6
6
|
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
7
7
|
import { match, isMatching, P } from 'ts-pattern';
|
|
8
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/types';
|
|
8
9
|
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __export = (target, all) => {
|
|
@@ -32,10 +33,28 @@ var settings = {
|
|
|
32
33
|
|
|
33
34
|
// package.json
|
|
34
35
|
var name2 = "eslint-plugin-react-web-api";
|
|
35
|
-
var version = "
|
|
36
|
+
var version = "2.0.0-next.0";
|
|
36
37
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("web-api"));
|
|
37
38
|
function getPhaseKindOfFunction(node) {
|
|
38
|
-
return match(node).when(
|
|
39
|
+
return match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfUseEffectCleanup, () => "cleanup").when(isFunctionOfComponentDidMount, () => "mount").when(isFunctionOfComponentWillUnmount, () => "unmount").otherwise(() => null);
|
|
40
|
+
}
|
|
41
|
+
function isFunctionOfUseEffectSetup(node) {
|
|
42
|
+
if (node == null) return false;
|
|
43
|
+
return node.parent?.type === AST_NODE_TYPES$1.CallExpression && node.parent.callee !== node && node.parent.callee.type === AST_NODE_TYPES$1.Identifier && node.parent.arguments.at(0) === node && ER4.isUseEffectCallLoose(node.parent);
|
|
44
|
+
}
|
|
45
|
+
function isFunctionOfUseEffectCleanup(node) {
|
|
46
|
+
if (node == null) return false;
|
|
47
|
+
const pReturn = AST.findParentNode(node, AST.is(AST_NODE_TYPES$1.ReturnStatement));
|
|
48
|
+
const pFunction = AST.findParentNode(node, AST.isFunction);
|
|
49
|
+
const pFunctionOfReturn = AST.findParentNode(pReturn, AST.isFunction);
|
|
50
|
+
if (pFunction !== pFunctionOfReturn) return false;
|
|
51
|
+
return isFunctionOfUseEffectSetup(pFunction);
|
|
52
|
+
}
|
|
53
|
+
function isFunctionOfComponentDidMount(node) {
|
|
54
|
+
return AST.isFunction(node) && ER4.isComponentDidMount(node.parent) && node.parent.value === node;
|
|
55
|
+
}
|
|
56
|
+
function isFunctionOfComponentWillUnmount(node) {
|
|
57
|
+
return AST.isFunction(node) && ER4.isComponentWillUnmount(node.parent) && node.parent.value === node;
|
|
39
58
|
}
|
|
40
59
|
|
|
41
60
|
// src/rules/no-leaked-event-listener.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"@typescript-eslint/utils": "^8.30.1",
|
|
49
49
|
"string-ts": "^2.2.1",
|
|
50
50
|
"ts-pattern": "^5.7.0",
|
|
51
|
-
"@eslint-react/ast": "
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
51
|
+
"@eslint-react/ast": "2.0.0-next.0",
|
|
52
|
+
"@eslint-react/eff": "2.0.0-next.0",
|
|
53
|
+
"@eslint-react/kit": "2.0.0-next.0",
|
|
54
|
+
"@eslint-react/core": "2.0.0-next.0",
|
|
55
|
+
"@eslint-react/var": "2.0.0-next.0",
|
|
56
|
+
"@eslint-react/shared": "2.0.0-next.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/react": "^19.1.2",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"@local/configs": "0.0.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"eslint": "^
|
|
66
|
-
"typescript": "^4.9.5 || ^5.
|
|
65
|
+
"eslint": "^9.24.0",
|
|
66
|
+
"typescript": "^4.9.5 || ^5.4.5"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"eslint": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"engines": {
|
|
77
77
|
"bun": ">=1.0.15",
|
|
78
|
-
"node": ">=
|
|
78
|
+
"node": ">=20.19.0"
|
|
79
79
|
},
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|