eslint-plugin-react-web-api 5.2.1-next.3 → 5.2.2-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/dist/index.js +9 -10
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared";
|
|
2
|
-
import
|
|
3
|
-
import { isOneOf } from "@eslint-react/ast";
|
|
2
|
+
import { Check, Compare, Traverse, isOneOf } from "@eslint-react/ast";
|
|
4
3
|
import * as core from "@eslint-react/core";
|
|
5
4
|
import { merge } from "@eslint-react/eslint";
|
|
6
5
|
import { isAssignmentTargetEqual, isValueEqual, resolve, resolveEnclosingAssignmentTarget } from "@eslint-react/var";
|
|
@@ -28,7 +27,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
28
27
|
//#endregion
|
|
29
28
|
//#region package.json
|
|
30
29
|
var name$1 = "eslint-plugin-react-web-api";
|
|
31
|
-
var version = "5.2.
|
|
30
|
+
var version = "5.2.2-beta.0";
|
|
32
31
|
|
|
33
32
|
//#endregion
|
|
34
33
|
//#region src/types/component-phase.ts
|
|
@@ -66,7 +65,7 @@ function getSignalValueExpression(context, node) {
|
|
|
66
65
|
switch (node.type) {
|
|
67
66
|
case AST_NODE_TYPES.Identifier: {
|
|
68
67
|
const resolved = resolve(context, node);
|
|
69
|
-
if (resolved != null &&
|
|
68
|
+
if (resolved != null && Check.isFunction(resolved)) return node;
|
|
70
69
|
return getSignalValueExpression(context, resolved);
|
|
71
70
|
}
|
|
72
71
|
case AST_NODE_TYPES.MemberExpression: return node;
|
|
@@ -87,14 +86,14 @@ function getOptions(context, node) {
|
|
|
87
86
|
capture: Boolean(node.value)
|
|
88
87
|
};
|
|
89
88
|
case AST_NODE_TYPES.ObjectExpression: {
|
|
90
|
-
const vCapture = match(
|
|
89
|
+
const vCapture = match(Traverse.findProperty(node.properties, "capture")).with(P.nullish, () => false).with({ type: AST_NODE_TYPES.Property }, (prop) => {
|
|
91
90
|
const value = prop.value;
|
|
92
91
|
switch (value.type) {
|
|
93
92
|
case AST_NODE_TYPES.Literal: return Boolean(value.value);
|
|
94
93
|
default: return Boolean(getStaticValue(value, initialScope)?.value);
|
|
95
94
|
}
|
|
96
95
|
}).otherwise(() => false);
|
|
97
|
-
const pSignal =
|
|
96
|
+
const pSignal = Traverse.findProperty(node.properties, "signal");
|
|
98
97
|
return {
|
|
99
98
|
capture: vCapture,
|
|
100
99
|
signal: pSignal?.type === AST_NODE_TYPES.Property ? getSignalValueExpression(context, pSignal.value) : null
|
|
@@ -128,7 +127,7 @@ function create$3(context) {
|
|
|
128
127
|
const abortedSignals = [];
|
|
129
128
|
function isSameObject(a, b) {
|
|
130
129
|
switch (true) {
|
|
131
|
-
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return
|
|
130
|
+
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return Compare.areEqual(a.object, b.object);
|
|
132
131
|
default: return false;
|
|
133
132
|
}
|
|
134
133
|
}
|
|
@@ -136,11 +135,11 @@ function create$3(context) {
|
|
|
136
135
|
const { type: aType, callee: aCallee, capture: aCapture, listener: aListener, phase: aPhase } = aEntry;
|
|
137
136
|
const { type: rType, callee: rCallee, capture: rCapture, listener: rListener, phase: rPhase } = rEntry;
|
|
138
137
|
if (ComponentPhaseRelevance.get(aPhase) !== rPhase) return false;
|
|
139
|
-
return isSameObject(aCallee, rCallee) &&
|
|
138
|
+
return isSameObject(aCallee, rCallee) && Compare.areEqual(aListener, rListener) && isValueEqual(context, aType, rType) && aCapture === rCapture;
|
|
140
139
|
}
|
|
141
140
|
function checkInlineFunction(node, callKind, options) {
|
|
142
141
|
const listener = node.arguments.at(1);
|
|
143
|
-
if (!
|
|
142
|
+
if (!Check.isFunction(listener)) return;
|
|
144
143
|
if (options.signal != null) return;
|
|
145
144
|
context.report({
|
|
146
145
|
data: { eventMethodKind: callKind },
|
|
@@ -593,7 +592,7 @@ function create$1(context) {
|
|
|
593
592
|
const uentries = uEntries.filter((e) => isAssignmentTargetEqual(context, e.observer, id));
|
|
594
593
|
const isDynamic = (node) => node?.type === AST_NODE_TYPES.CallExpression || isConditional(node);
|
|
595
594
|
const isPhaseNode = (node) => node === phaseNode;
|
|
596
|
-
if (oentries.some((e) => !isPhaseNode(
|
|
595
|
+
if (oentries.some((e) => !isPhaseNode(Traverse.findParent(e.node, or(isDynamic, isPhaseNode))))) {
|
|
597
596
|
context.report({
|
|
598
597
|
messageId: "expectedDisconnectInControlFlow",
|
|
599
598
|
node
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@typescript-eslint/utils": "^8.58.1",
|
|
44
44
|
"birecord": "^0.1.1",
|
|
45
45
|
"ts-pattern": "^5.9.0",
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/shared": "5.2.
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
46
|
+
"@eslint-react/core": "5.2.2-beta.0",
|
|
47
|
+
"@eslint-react/ast": "5.2.2-beta.0",
|
|
48
|
+
"@eslint-react/shared": "5.2.2-beta.0",
|
|
49
|
+
"@eslint-react/var": "5.2.2-beta.0",
|
|
50
|
+
"@eslint-react/eslint": "5.2.2-beta.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|