eslint-plugin-react-web-api 2.8.1 → 2.8.2-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 +10 -10
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, getConfigAdapters } from "@eslint-react/shared";
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as ast from "@eslint-react/ast";
|
|
3
|
+
import * as core from "@eslint-react/core";
|
|
4
4
|
import { dual, or, unit } from "@eslint-react/eff";
|
|
5
5
|
import { findEnclosingAssignmentTarget, findProperty, findVariable, getVariableDefinitionNode, isAssignmentTargetEqual, isNodeValueEqual } from "@eslint-react/var";
|
|
6
6
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
@@ -43,7 +43,7 @@ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region package.json
|
|
45
45
|
var name = "eslint-plugin-react-web-api";
|
|
46
|
-
var version = "2.8.
|
|
46
|
+
var version = "2.8.2-next.0";
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/types/component-phase.ts
|
|
@@ -53,7 +53,7 @@ const ComponentPhaseRelevance = birecord({
|
|
|
53
53
|
});
|
|
54
54
|
const isInversePhase = dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
|
|
55
55
|
function getPhaseKindOfFunction(node) {
|
|
56
|
-
return match(node).when(isUseEffectSetupCallback, () => "setup").when(isUseEffectCleanupCallback, () => "cleanup").when(isComponentDidMountCallback, () => "mount").when(isComponentWillUnmountCallback, () => "unmount").otherwise(() => null);
|
|
56
|
+
return match(node).when(core.isUseEffectSetupCallback, () => "setup").when(core.isUseEffectCleanupCallback, () => "cleanup").when(core.isComponentDidMountCallback, () => "mount").when(core.isComponentWillUnmountCallback, () => "unmount").otherwise(() => null);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
@@ -154,7 +154,7 @@ function create$3(context) {
|
|
|
154
154
|
const abortedSignals = [];
|
|
155
155
|
function isSameObject(a, b) {
|
|
156
156
|
switch (true) {
|
|
157
|
-
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return
|
|
157
|
+
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return ast.isNodeEqual(a.object, b.object);
|
|
158
158
|
default: return false;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -162,11 +162,11 @@ function create$3(context) {
|
|
|
162
162
|
const { type: aType, callee: aCallee, capture: aCapture, listener: aListener, phase: aPhase } = aEntry;
|
|
163
163
|
const { type: rType, callee: rCallee, capture: rCapture, listener: rListener, phase: rPhase } = rEntry;
|
|
164
164
|
if (!isInversePhase(aPhase, rPhase)) return false;
|
|
165
|
-
return isSameObject(aCallee, rCallee) &&
|
|
165
|
+
return isSameObject(aCallee, rCallee) && ast.isNodeEqual(aListener, rListener) && isNodeValueEqual(aType, rType, [context.sourceCode.getScope(aType), context.sourceCode.getScope(rType)]) && aCapture === rCapture;
|
|
166
166
|
}
|
|
167
167
|
function checkInlineFunction(node, callKind, options) {
|
|
168
168
|
const listener = node.arguments.at(1);
|
|
169
|
-
if (!
|
|
169
|
+
if (!ast.isFunction(listener)) return;
|
|
170
170
|
if (options.signal != null) return;
|
|
171
171
|
context.report({
|
|
172
172
|
messageId: "unexpectedInlineFunction",
|
|
@@ -190,7 +190,7 @@ function create$3(context) {
|
|
|
190
190
|
if (fKind == null) return;
|
|
191
191
|
if (!ComponentPhaseRelevance.has(fKind)) return;
|
|
192
192
|
match(getCallKind$3(node)).with("addEventListener", (callKind) => {
|
|
193
|
-
if (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && isInitializedFromReactNative(node.callee.object.name, context.sourceCode.getScope(node))) return;
|
|
193
|
+
if (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && core.isInitializedFromReactNative(node.callee.object.name, context.sourceCode.getScope(node))) return;
|
|
194
194
|
const [type, listener, options] = node.arguments;
|
|
195
195
|
if (type == null || listener == null) return;
|
|
196
196
|
const opts = options == null ? defaultOptions : getOptions(options, context.sourceCode.getScope(options));
|
|
@@ -481,9 +481,9 @@ function create$1(context) {
|
|
|
481
481
|
if (dEntries.some((e) => isAssignmentTargetEqual(context, e.observer, id))) continue;
|
|
482
482
|
const oentries = oEntries.filter((e) => isAssignmentTargetEqual(context, e.observer, id));
|
|
483
483
|
const uentries = uEntries.filter((e) => isAssignmentTargetEqual(context, e.observer, id));
|
|
484
|
-
const isDynamic = (node) => node?.type === AST_NODE_TYPES.CallExpression ||
|
|
484
|
+
const isDynamic = (node) => node?.type === AST_NODE_TYPES.CallExpression || ast.isConditional(node);
|
|
485
485
|
const isPhaseNode = (node) => node === phaseNode;
|
|
486
|
-
if (oentries.some((e) => !isPhaseNode(
|
|
486
|
+
if (oentries.some((e) => !isPhaseNode(ast.findParentNode(e.node, or(isDynamic, isPhaseNode))))) {
|
|
487
487
|
context.report({
|
|
488
488
|
messageId: "expectedDisconnectInControlFlow",
|
|
489
489
|
node
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2-next.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"birecord": "^0.1.1",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-pattern": "^5.9.0",
|
|
47
|
-
"@eslint-react/ast": "2.8.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
47
|
+
"@eslint-react/ast": "2.8.2-next.0",
|
|
48
|
+
"@eslint-react/core": "2.8.2-next.0",
|
|
49
|
+
"@eslint-react/var": "2.8.2-next.0",
|
|
50
|
+
"@eslint-react/eff": "2.8.2-next.0",
|
|
51
|
+
"@eslint-react/shared": "2.8.2-next.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.10",
|