eslint-plugin-react-web-api 3.0.0-next.63 → 3.0.0-next.64

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -30
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, defineRuleListener } from "@eslint-react/shared";
2
2
  import * as ast from "@eslint-react/ast";
3
3
  import * as core from "@eslint-react/core";
4
- import { dual, or, unit } from "@eslint-react/eff";
5
- import { findEnclosingAssignmentTarget, isAssignmentTargetEqual, isValueEqual } from "@eslint-react/var";
4
+ import { findEnclosingAssignmentTarget, isAssignmentTargetEqual, isValueEqual, resolve } from "@eslint-react/var";
6
5
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
7
- import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
6
+ import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
8
7
  import { P, isMatching, match } from "ts-pattern";
8
+ import { dual, or } from "@eslint-react/eff";
9
9
  import birecord from "birecord";
10
10
 
11
11
  //#region \0rolldown/runtime.js
@@ -27,7 +27,7 @@ var __exportAll = (all, no_symbols) => {
27
27
  //#endregion
28
28
  //#region package.json
29
29
  var name$1 = "eslint-plugin-react-web-api";
30
- var version = "3.0.0-next.63";
30
+ var version = "3.0.0-next.64";
31
31
 
32
32
  //#endregion
33
33
  //#region src/types/component-phase.ts
@@ -52,7 +52,7 @@ const createRule = ESLintUtils.RuleCreator(getDocsUrl);
52
52
  const RULE_NAME$3 = "no-leaked-event-listener";
53
53
  const defaultOptions = {
54
54
  capture: false,
55
- signal: unit
55
+ signal: null
56
56
  };
57
57
  function getCallKind$3(node) {
58
58
  switch (true) {
@@ -64,20 +64,21 @@ function getCallKind$3(node) {
64
64
  function getFunctionKind$1(node) {
65
65
  return getPhaseKindOfFunction(node) ?? "other";
66
66
  }
67
- function getSignalValueExpression(node, initialScope) {
68
- if (node == null) return unit;
67
+ function getSignalValueExpression(context, node) {
68
+ if (node == null) return null;
69
69
  switch (node.type) {
70
- case AST_NODE_TYPES.Identifier: return getSignalValueExpression(resolve$1(findVariable(initialScope, node)), initialScope);
70
+ case AST_NODE_TYPES.Identifier: return getSignalValueExpression(context, resolve(context, node));
71
71
  case AST_NODE_TYPES.MemberExpression: return node;
72
- default: return unit;
72
+ default: return null;
73
73
  }
74
74
  }
75
- function getOptions(node, initialScope) {
75
+ function getOptions(context, node) {
76
+ const initialScope = context.sourceCode.getScope(node);
76
77
  function getOpts(node) {
77
78
  switch (node.type) {
78
79
  case AST_NODE_TYPES.Identifier: {
79
- const variableNode = resolve$1(findVariable(initialScope, node));
80
- if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return getOpts(variableNode);
80
+ const initNode = resolve(context, node);
81
+ if (initNode?.type === AST_NODE_TYPES.ObjectExpression) return getOpts(initNode);
81
82
  return defaultOptions;
82
83
  }
83
84
  case AST_NODE_TYPES.Literal: return {
@@ -95,7 +96,7 @@ function getOptions(node, initialScope) {
95
96
  const pSignal = ast.findProperty(node.properties, "signal");
96
97
  return {
97
98
  capture: vCapture,
98
- signal: pSignal?.type === AST_NODE_TYPES.Property ? getSignalValueExpression(pSignal.value, initialScope) : unit
99
+ signal: pSignal?.type === AST_NODE_TYPES.Property ? getSignalValueExpression(context, pSignal.value) : null
99
100
  };
100
101
  }
101
102
  default: return defaultOptions;
@@ -166,7 +167,7 @@ function create$3(context) {
166
167
  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;
167
168
  const [type, listener, options] = node.arguments;
168
169
  if (type == null || listener == null) return;
169
- const opts = options == null ? defaultOptions : getOptions(options, context.sourceCode.getScope(options));
170
+ const opts = options == null ? defaultOptions : getOptions(context, options);
170
171
  const { callee } = node;
171
172
  checkInlineFunction(node, callKind, opts);
172
173
  aEntries.push({
@@ -181,7 +182,7 @@ function create$3(context) {
181
182
  }).with("removeEventListener", (callKind) => {
182
183
  const [type, listener, options] = node.arguments;
183
184
  if (type == null || listener == null) return;
184
- const opts = options == null ? defaultOptions : getOptions(options, context.sourceCode.getScope(options));
185
+ const opts = options == null ? defaultOptions : getOptions(context, options);
185
186
  const { callee } = node;
186
187
  checkInlineFunction(node, callKind, opts);
187
188
  rEntries.push({
@@ -222,13 +223,6 @@ function create$3(context) {
222
223
  }
223
224
  });
224
225
  }
225
- function resolve$1(v) {
226
- if (v == null) return unit;
227
- const def = v.defs.at(0);
228
- if (def == null) return unit;
229
- if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
230
- return unit;
231
- }
232
226
 
233
227
  //#endregion
234
228
  //#region src/rules/no-leaked-interval/no-leaked-interval.ts
@@ -348,7 +342,7 @@ function isNewResizeObserver(node) {
348
342
  }
349
343
  function isFromObserver(context, node) {
350
344
  switch (true) {
351
- case node.type === AST_NODE_TYPES.Identifier: return isNewResizeObserver(resolve(findVariable(context.sourceCode.getScope(node), node)));
345
+ case node.type === AST_NODE_TYPES.Identifier: return isNewResizeObserver(resolve(context, node));
352
346
  case node.type === AST_NODE_TYPES.MemberExpression: return isFromObserver(context, node.object);
353
347
  default: return false;
354
348
  }
@@ -481,13 +475,6 @@ function create$1(context) {
481
475
  }
482
476
  });
483
477
  }
484
- function resolve(v) {
485
- if (v == null) return unit;
486
- const def = v.defs.at(0);
487
- if (def == null) return unit;
488
- if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
489
- return unit;
490
- }
491
478
 
492
479
  //#endregion
493
480
  //#region src/rules/no-leaked-timeout/no-leaked-timeout.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "3.0.0-next.63",
3
+ "version": "3.0.0-next.64",
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": "canary",
44
44
  "birecord": "^0.1.1",
45
45
  "ts-pattern": "^5.9.0",
46
- "@eslint-react/ast": "3.0.0-next.63",
47
- "@eslint-react/core": "3.0.0-next.63",
48
- "@eslint-react/eff": "3.0.0-next.63",
49
- "@eslint-react/var": "3.0.0-next.63",
50
- "@eslint-react/shared": "3.0.0-next.63"
46
+ "@eslint-react/ast": "3.0.0-next.64",
47
+ "@eslint-react/core": "3.0.0-next.64",
48
+ "@eslint-react/shared": "3.0.0-next.64",
49
+ "@eslint-react/eff": "3.0.0-next.64",
50
+ "@eslint-react/var": "3.0.0-next.64"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.2.14",