eslint-plugin-react-web-api 3.0.0-next.60 → 3.0.0-next.61

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 +31 -5
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, defineRuleListener } from "
2
2
  import * as ast from "@eslint-react/ast";
3
3
  import * as core from "@eslint-react/core";
4
4
  import { dual, or, unit } from "@eslint-react/eff";
5
- import { findEnclosingAssignmentTarget, findVariable, getVariableInitializer, isAssignmentTargetEqual, isValueEqual } from "@eslint-react/var";
5
+ import { findEnclosingAssignmentTarget, findVariable, isAssignmentTargetEqual, isValueEqual } from "@eslint-react/var";
6
6
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
7
7
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
8
8
  import { P, isMatching, match } from "ts-pattern";
@@ -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.60";
30
+ var version = "3.0.0-next.61";
31
31
 
32
32
  //#endregion
33
33
  //#region src/types/component-phase.ts
@@ -67,7 +67,16 @@ function getFunctionKind$1(node) {
67
67
  function getSignalValueExpression(node, initialScope) {
68
68
  if (node == null) return unit;
69
69
  switch (node.type) {
70
- case AST_NODE_TYPES.Identifier: return getSignalValueExpression(getVariableInitializer(findVariable(node, initialScope), 0), initialScope);
70
+ case AST_NODE_TYPES.Identifier: {
71
+ function resolve(v) {
72
+ if (v == null) return unit;
73
+ const def = v.defs.at(0);
74
+ if (def == null) return unit;
75
+ if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
76
+ return unit;
77
+ }
78
+ return getSignalValueExpression(resolve(findVariable(node, initialScope)), initialScope);
79
+ }
71
80
  case AST_NODE_TYPES.MemberExpression: return node;
72
81
  default: return unit;
73
82
  }
@@ -76,7 +85,14 @@ function getOptions(node, initialScope) {
76
85
  function getOpts(node) {
77
86
  switch (node.type) {
78
87
  case AST_NODE_TYPES.Identifier: {
79
- const variableNode = getVariableInitializer(findVariable(node, initialScope), 0);
88
+ function resolve(v) {
89
+ if (v == null) return unit;
90
+ const def = v.defs.at(0);
91
+ if (def == null) return unit;
92
+ if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
93
+ return unit;
94
+ }
95
+ const variableNode = resolve(findVariable(node, initialScope));
80
96
  if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return getOpts(variableNode);
81
97
  return defaultOptions;
82
98
  }
@@ -341,7 +357,17 @@ function isNewResizeObserver(node) {
341
357
  }
342
358
  function isFromObserver(context, node) {
343
359
  switch (true) {
344
- case node.type === AST_NODE_TYPES.Identifier: return isNewResizeObserver(getVariableInitializer(findVariable(node, context.sourceCode.getScope(node)), 0));
360
+ case node.type === AST_NODE_TYPES.Identifier: {
361
+ const variable = findVariable(node, context.sourceCode.getScope(node));
362
+ function resolve(v) {
363
+ if (v == null) return unit;
364
+ const def = v.defs.at(0);
365
+ if (def == null) return unit;
366
+ if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
367
+ return unit;
368
+ }
369
+ return isNewResizeObserver(resolve(variable));
370
+ }
345
371
  case node.type === AST_NODE_TYPES.MemberExpression: return isFromObserver(context, node.object);
346
372
  default: return false;
347
373
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "3.0.0-next.60",
3
+ "version": "3.0.0-next.61",
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.60",
47
- "@eslint-react/shared": "3.0.0-next.60",
48
- "@eslint-react/eff": "3.0.0-next.60",
49
- "@eslint-react/var": "3.0.0-next.60",
50
- "@eslint-react/core": "3.0.0-next.60"
46
+ "@eslint-react/ast": "3.0.0-next.61",
47
+ "@eslint-react/core": "3.0.0-next.61",
48
+ "@eslint-react/shared": "3.0.0-next.61",
49
+ "@eslint-react/eff": "3.0.0-next.61",
50
+ "@eslint-react/var": "3.0.0-next.61"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.2.14",