eslint-plugin-react-web-api 5.2.1-beta.1 → 5.2.1-beta.3

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 +38 -6
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared";
2
2
  import * as ast from "@eslint-react/ast";
3
+ import { isOneOf } from "@eslint-react/ast";
3
4
  import * as core from "@eslint-react/core";
4
5
  import { merge } from "@eslint-react/eslint";
5
- import { findEnclosingAssignmentTarget, isAssignmentTargetEqual, isValueEqual, resolve } from "@eslint-react/var";
6
+ import { isAssignmentTargetEqual, isValueEqual, resolve, resolveEnclosingAssignmentTarget } from "@eslint-react/var";
6
7
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
7
8
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
8
9
  import { P, isMatching, match } from "ts-pattern";
@@ -27,7 +28,7 @@ var __exportAll = (all, no_symbols) => {
27
28
  //#endregion
28
29
  //#region package.json
29
30
  var name$1 = "eslint-plugin-react-web-api";
30
- var version = "5.2.1-beta.1";
31
+ var version = "5.2.1-beta.3";
31
32
 
32
33
  //#endregion
33
34
  //#region src/types/component-phase.ts
@@ -265,7 +266,7 @@ function create$2(context) {
265
266
  const fEntry = fEntries.findLast((x) => x.kind !== "other");
266
267
  if (fEntry == null) break;
267
268
  if (!ComponentPhaseRelevance.has(fEntry.kind)) break;
268
- const intervalIdNode = findEnclosingAssignmentTarget(node);
269
+ const intervalIdNode = resolveEnclosingAssignmentTarget(node);
269
270
  if (intervalIdNode == null) {
270
271
  context.report({
271
272
  messageId: "expectedIntervalId",
@@ -438,6 +439,37 @@ const dual = function(arity, body) {
438
439
  */
439
440
  const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
440
441
 
442
+ //#endregion
443
+ //#region src/rules/no-leaked-resize-observer/lib.ts
444
+ /**
445
+ * Check if a node is a loop statement
446
+ * @param node The node to check
447
+ * @returns True if the node is a loop
448
+ */
449
+ const isLoop = isOneOf([
450
+ AST_NODE_TYPES.DoWhileStatement,
451
+ AST_NODE_TYPES.ForInStatement,
452
+ AST_NODE_TYPES.ForOfStatement,
453
+ AST_NODE_TYPES.ForStatement,
454
+ AST_NODE_TYPES.WhileStatement
455
+ ]);
456
+ /**
457
+ * Check if a node is a conditional expression or control flow statement
458
+ * @param node The node to check
459
+ * @returns True if the node is conditional
460
+ */
461
+ const isConditional = isOneOf([
462
+ AST_NODE_TYPES.DoWhileStatement,
463
+ AST_NODE_TYPES.ForInStatement,
464
+ AST_NODE_TYPES.ForOfStatement,
465
+ AST_NODE_TYPES.ForStatement,
466
+ AST_NODE_TYPES.WhileStatement,
467
+ AST_NODE_TYPES.IfStatement,
468
+ AST_NODE_TYPES.SwitchStatement,
469
+ AST_NODE_TYPES.LogicalExpression,
470
+ AST_NODE_TYPES.ConditionalExpression
471
+ ]);
472
+
441
473
  //#endregion
442
474
  //#region src/rules/no-leaked-resize-observer/no-leaked-resize-observer.ts
443
475
  const RULE_NAME$1 = "no-leaked-resize-observer";
@@ -539,7 +571,7 @@ function create$1(context) {
539
571
  if (fEntry == null) return;
540
572
  if (!ComponentPhaseRelevance.has(fEntry.kind)) return;
541
573
  if (!isNewResizeObserver(node)) return;
542
- const id = findEnclosingAssignmentTarget(node);
574
+ const id = resolveEnclosingAssignmentTarget(node);
543
575
  if (id == null) {
544
576
  context.report({
545
577
  messageId: "unexpectedFloatingInstance",
@@ -559,7 +591,7 @@ function create$1(context) {
559
591
  if (dEntries.some((e) => isAssignmentTargetEqual(context, e.observer, id))) continue;
560
592
  const oentries = oEntries.filter((e) => isAssignmentTargetEqual(context, e.observer, id));
561
593
  const uentries = uEntries.filter((e) => isAssignmentTargetEqual(context, e.observer, id));
562
- const isDynamic = (node) => node?.type === AST_NODE_TYPES.CallExpression || ast.isConditional(node);
594
+ const isDynamic = (node) => node?.type === AST_NODE_TYPES.CallExpression || isConditional(node);
563
595
  const isPhaseNode = (node) => node === phaseNode;
564
596
  if (oentries.some((e) => !isPhaseNode(ast.findParent(e.node, or(isDynamic, isPhaseNode))))) {
565
597
  context.report({
@@ -628,7 +660,7 @@ function create(context) {
628
660
  if (!ComponentPhaseRelevance.has(fEntry?.kind)) return;
629
661
  switch (getCallKind(node)) {
630
662
  case "setTimeout": {
631
- const timeoutIdNode = findEnclosingAssignmentTarget(node);
663
+ const timeoutIdNode = resolveEnclosingAssignmentTarget(node);
632
664
  if (timeoutIdNode == null) {
633
665
  context.report({
634
666
  messageId: "expectedTimeoutId",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "5.2.1-beta.1",
3
+ "version": "5.2.1-beta.3",
4
4
  "description": "ESLint React's ESLint plugin for interacting with Web APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -43,19 +43,19 @@
43
43
  "@typescript-eslint/utils": "^8.58.1",
44
44
  "birecord": "^0.1.1",
45
45
  "ts-pattern": "^5.9.0",
46
- "@eslint-react/ast": "5.2.1-beta.1",
47
- "@eslint-react/core": "5.2.1-beta.1",
48
- "@eslint-react/eslint": "5.2.1-beta.1",
49
- "@eslint-react/var": "5.2.1-beta.1",
50
- "@eslint-react/shared": "5.2.1-beta.1"
46
+ "@eslint-react/ast": "5.2.1-beta.3",
47
+ "@eslint-react/core": "5.2.1-beta.3",
48
+ "@eslint-react/eslint": "5.2.1-beta.3",
49
+ "@eslint-react/shared": "5.2.1-beta.3",
50
+ "@eslint-react/var": "5.2.1-beta.3"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.2.14",
54
54
  "@types/react-dom": "^19.2.3",
55
55
  "eslint": "^10.2.0",
56
56
  "tsdown": "^0.21.7",
57
- "@local/configs": "0.0.0",
58
- "@local/eff": "3.0.0-beta.72"
57
+ "@local/eff": "3.0.0-beta.72",
58
+ "@local/configs": "0.0.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "eslint": "^10.2.0",