eslint-plugin-react-web-api 5.28.0 → 5.28.1

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 +24 -6
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var __exportAll = (all, no_symbols) => {
21
21
  //#endregion
22
22
  //#region package.json
23
23
  var name$1 = "eslint-plugin-react-web-api";
24
- var version = "5.28.0";
24
+ var version = "5.28.1";
25
25
  //#endregion
26
26
  //#region src/utils/create-rule.ts
27
27
  function getDocsUrl(ruleName) {
@@ -353,8 +353,10 @@ function create$5(context) {
353
353
  for (const aEntry of aEntries) {
354
354
  if (aEntry.signal != null) continue;
355
355
  if (rEntries.some((rEntry) => isInverseEntry(aEntry, rEntry))) continue;
356
+ const effect = aEntry.effect;
357
+ const effectMethodKind = effect != null && effect.type === AST_NODE_TYPES.CallExpression ? Extract.getCalleeName(effect) ?? "useEffect" : "useEffect";
356
358
  context.report({
357
- data: { effectMethodKind: "useEffect" },
359
+ data: { effectMethodKind },
358
360
  messageId: "expected-remove-event-listener-in-cleanup",
359
361
  node: aEntry.node
360
362
  });
@@ -693,6 +695,11 @@ function getCallKind$2(node) {
693
695
  if (name != null && isMatching(P.union("setInterval", "clearInterval"))(name)) return name;
694
696
  return "other";
695
697
  }
698
+ function getEffectKind$1(fn) {
699
+ const call = Traverse.findParent(Extract.unwrap(fn), (n) => !Check.isTypeOrChainExpression(n));
700
+ if (call?.type !== AST_NODE_TYPES.CallExpression) return "useEffect";
701
+ return Extract.getCalleeName(call) ?? "useEffect";
702
+ }
696
703
  var no_leaked_interval_default = createRule({
697
704
  meta: {
698
705
  type: "problem",
@@ -715,7 +722,8 @@ function create$2(context) {
715
722
  }
716
723
  return {
717
724
  ["CallExpression"](node) {
718
- if (Traverse.findParent(node, isUseEffectCallback$2) == null) return;
725
+ const fn = Traverse.findParent(node, isUseEffectCallback$2);
726
+ if (fn == null) return;
719
727
  match(getCallKind$2(node)).with("setInterval", () => {
720
728
  const intervalIdNode = resolveEnclosingAssignmentTarget(node);
721
729
  if (intervalIdNode == null) {
@@ -726,6 +734,7 @@ function create$2(context) {
726
734
  return;
727
735
  }
728
736
  sEntries.push({
737
+ effectKind: getEffectKind$1(fn),
729
738
  node,
730
739
  timerId: intervalIdNode
731
740
  });
@@ -733,6 +742,7 @@ function create$2(context) {
733
742
  const [intervalIdNode] = node.arguments;
734
743
  if (intervalIdNode == null) return;
735
744
  cEntries.push({
745
+ effectKind: getEffectKind$1(fn),
736
746
  node,
737
747
  timerId: intervalIdNode
738
748
  });
@@ -742,7 +752,7 @@ function create$2(context) {
742
752
  for (const sEntry of sEntries) {
743
753
  if (cEntries.some((cEntry) => isInverseEntry(sEntry, cEntry))) continue;
744
754
  context.report({
745
- data: { kind: "useEffect" },
755
+ data: { kind: sEntry.effectKind },
746
756
  messageId: "expected-clear-interval-in-cleanup",
747
757
  node: sEntry.node
748
758
  });
@@ -940,6 +950,11 @@ function getCallKind(node) {
940
950
  if (name != null && isMatching(P.union("setTimeout", "clearTimeout"))(name)) return name;
941
951
  return "other";
942
952
  }
953
+ function getEffectKind(fn) {
954
+ const call = Traverse.findParent(Extract.unwrap(fn), (n) => !Check.isTypeOrChainExpression(n));
955
+ if (call?.type !== AST_NODE_TYPES.CallExpression) return "useEffect";
956
+ return Extract.getCalleeName(call) ?? "useEffect";
957
+ }
943
958
  var no_leaked_timeout_default = createRule({
944
959
  meta: {
945
960
  type: "problem",
@@ -962,7 +977,8 @@ function create(context) {
962
977
  }
963
978
  return {
964
979
  ["CallExpression"](node) {
965
- if (Traverse.findParent(node, isUseEffectCallback) == null) return;
980
+ const fn = Traverse.findParent(node, isUseEffectCallback);
981
+ if (fn == null) return;
966
982
  match(getCallKind(node)).with("setTimeout", () => {
967
983
  const timeoutIdNode = resolveEnclosingAssignmentTarget(node);
968
984
  if (timeoutIdNode == null) {
@@ -973,6 +989,7 @@ function create(context) {
973
989
  return;
974
990
  }
975
991
  sEntries.push({
992
+ effectKind: getEffectKind(fn),
976
993
  node,
977
994
  timerId: timeoutIdNode
978
995
  });
@@ -980,6 +997,7 @@ function create(context) {
980
997
  const [timeoutIdNode] = node.arguments;
981
998
  if (timeoutIdNode == null) return;
982
999
  cEntries.push({
1000
+ effectKind: getEffectKind(fn),
983
1001
  node,
984
1002
  timerId: timeoutIdNode
985
1003
  });
@@ -989,7 +1007,7 @@ function create(context) {
989
1007
  for (const sEntry of sEntries) {
990
1008
  if (cEntries.some((cEntry) => isInverseEntry(sEntry, cEntry))) continue;
991
1009
  context.report({
992
- data: { kind: "useEffect" },
1010
+ data: { kind: sEntry.effectKind },
993
1011
  messageId: "expected-clear-timeout-in-cleanup",
994
1012
  node: sEntry.node
995
1013
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "5.28.0",
3
+ "version": "5.28.1",
4
4
  "description": "ESLint React's ESLint plugin for interacting with Web APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -37,11 +37,11 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@eslint-react/ast": "5.28.0",
41
- "@eslint-react/core": "5.28.0",
42
- "@eslint-react/eslint": "5.28.0",
43
- "@eslint-react/shared": "5.28.0",
44
- "@eslint-react/var": "5.28.0",
40
+ "@eslint-react/ast": "5.28.1",
41
+ "@eslint-react/core": "5.28.1",
42
+ "@eslint-react/eslint": "5.28.1",
43
+ "@eslint-react/shared": "5.28.1",
44
+ "@eslint-react/var": "5.28.1",
45
45
  "@typescript-eslint/types": "^8.71.2",
46
46
  "@typescript-eslint/utils": "^8.71.2",
47
47
  "ts-pattern": "^5.9.2"
@@ -55,7 +55,7 @@
55
55
  "@types/react": "^19.3.0",
56
56
  "@types/react-dom": "^19.3.0",
57
57
  "dedent": "^1.7.2",
58
- "eslint": "^10.12.0",
58
+ "eslint": "^10.13.0",
59
59
  "tsdown": "^0.23.1",
60
60
  "typescript": "6.0.3"
61
61
  },