eslint-plugin-react-web-api 1.22.2-next.9 → 1.23.0-beta.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 CHANGED
@@ -34,7 +34,7 @@ var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
34
34
 
35
35
  // package.json
36
36
  var name = "eslint-plugin-react-web-api";
37
- var version = "1.22.2-next.9";
37
+ var version = "1.23.0-beta.0";
38
38
  var createRule = shared.createRuleForPlugin("web-api");
39
39
  function getInstanceID(node, prev) {
40
40
  switch (true) {
@@ -171,17 +171,7 @@ var no_leaked_event_listener_default = createRule({
171
171
  const aEntries = [];
172
172
  const rEntries = [];
173
173
  const abortedSignals = [];
174
- function checkInlineFunction(node, callKind, options) {
175
- const [_, listener] = node.arguments;
176
- if (!AST2__namespace.isFunction(listener)) return eff.O.none();
177
- if (eff.O.isSome(options.signal)) return eff.O.none();
178
- return eff.O.some({
179
- messageId: "noLeakedEventListenerOfInlineFunction",
180
- node: listener,
181
- data: { eventMethodKind: callKind }
182
- });
183
- }
184
- const isSameObject = eff.F.dual(2, (a, b) => {
174
+ function isSameObject(a, b) {
185
175
  switch (true) {
186
176
  case (a.type === utils.AST_NODE_TYPES.MemberExpression && b.type === utils.AST_NODE_TYPES.MemberExpression):
187
177
  return AST2__namespace.isNodeEqual(a.object, b.object);
@@ -189,8 +179,8 @@ var no_leaked_event_listener_default = createRule({
189
179
  default:
190
180
  return false;
191
181
  }
192
- });
193
- const isInverseEntry = eff.F.dual(2, (aEntry, rEntry) => {
182
+ }
183
+ function isInverseEntry(aEntry, rEntry) {
194
184
  const { type: aType, callee: aCallee, capture: aCapture, listener: aListener, phase: aPhase } = aEntry;
195
185
  const { type: rType, callee: rCallee, capture: rCapture, listener: rListener, phase: rPhase } = rEntry;
196
186
  if (!core.isInversePhase(aPhase, rPhase)) return false;
@@ -198,7 +188,17 @@ var no_leaked_event_listener_default = createRule({
198
188
  context.sourceCode.getScope(aType),
199
189
  context.sourceCode.getScope(rType)
200
190
  ]) && eff.O.getOrElse(aCapture, eff.F.constFalse) === eff.O.getOrElse(rCapture, eff.F.constFalse);
201
- });
191
+ }
192
+ function checkInlineFunction(node, callKind, options) {
193
+ const [_, listener] = node.arguments;
194
+ if (!AST2__namespace.isFunction(listener)) return eff.O.none();
195
+ if (eff.O.isSome(options.signal)) return eff.O.none();
196
+ return eff.O.some({
197
+ messageId: "noLeakedEventListenerOfInlineFunction",
198
+ node: listener,
199
+ data: { eventMethodKind: callKind }
200
+ });
201
+ }
202
202
  return {
203
203
  [":function"](node) {
204
204
  const functionKind = getFunctionKind(node);
@@ -245,11 +245,11 @@ var no_leaked_event_listener_default = createRule({
245
245
  },
246
246
  ["Program:exit"]() {
247
247
  for (const aEntry of aEntries) {
248
- if (eff.O.exists(aEntry.signal, (signal) => abortedSignals.some(isSameObject(signal)))) continue;
249
- if (rEntries.some(isInverseEntry(aEntry))) continue;
248
+ if (eff.O.exists(aEntry.signal, (signal) => abortedSignals.some((as) => isSameObject(as, signal)))) continue;
249
+ if (rEntries.some((rEntry) => isInverseEntry(aEntry, rEntry))) continue;
250
250
  switch (aEntry.phase) {
251
- case "cleanup":
252
251
  case "setup":
252
+ case "cleanup":
253
253
  context.report({
254
254
  messageId: "noLeakedEventListenerInEffect",
255
255
  node: aEntry.node,
@@ -306,9 +306,9 @@ var no_leaked_interval_default = createRule({
306
306
  const fStack = [];
307
307
  const sEntries = [];
308
308
  const cEntries = [];
309
- const isInverseEntry = eff.F.dual(2, (a, b) => {
309
+ function isInverseEntry(a, b) {
310
310
  return isInstanceIDEqual(a.timerID, b.timerID, context);
311
- });
311
+ }
312
312
  return {
313
313
  [":function"](node) {
314
314
  const fKind = eff.O.getOrElse(getPhaseKindOfFunction(node), () => "other");
@@ -319,13 +319,19 @@ var no_leaked_interval_default = createRule({
319
319
  },
320
320
  ["CallExpression"](node) {
321
321
  switch (getCallKind2(node)) {
322
- case "clearInterval": {
322
+ case "setInterval": {
323
323
  const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
324
324
  if (!fNode || !fKind) break;
325
325
  if (!core.ERPhaseRelevance.has(fKind)) break;
326
- const [intervalIdNode] = node.arguments;
327
- if (!intervalIdNode) break;
328
- cEntries.push({
326
+ const intervalIdNode = eff.O.getOrNull(VAR2__namespace.getVariableDeclaratorID(node));
327
+ if (!intervalIdNode) {
328
+ context.report({
329
+ messageId: "noLeakedIntervalNoIntervalId",
330
+ node
331
+ });
332
+ break;
333
+ }
334
+ sEntries.push({
329
335
  kind: "interval",
330
336
  node,
331
337
  callee: node.callee,
@@ -334,19 +340,13 @@ var no_leaked_interval_default = createRule({
334
340
  });
335
341
  break;
336
342
  }
337
- case "setInterval": {
343
+ case "clearInterval": {
338
344
  const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
339
345
  if (!fNode || !fKind) break;
340
346
  if (!core.ERPhaseRelevance.has(fKind)) break;
341
- const intervalIdNode = eff.O.getOrNull(VAR2__namespace.getVariableDeclaratorID(node));
342
- if (!intervalIdNode) {
343
- context.report({
344
- messageId: "noLeakedIntervalNoIntervalId",
345
- node
346
- });
347
- break;
348
- }
349
- sEntries.push({
347
+ const [intervalIdNode] = node.arguments;
348
+ if (!intervalIdNode) break;
349
+ cEntries.push({
350
350
  kind: "interval",
351
351
  node,
352
352
  callee: node.callee,
@@ -359,10 +359,10 @@ var no_leaked_interval_default = createRule({
359
359
  },
360
360
  ["Program:exit"]() {
361
361
  for (const sEntry of sEntries) {
362
- if (cEntries.some(isInverseEntry(sEntry))) continue;
362
+ if (cEntries.some((cEntry) => isInverseEntry(sEntry, cEntry))) continue;
363
363
  switch (sEntry.phase) {
364
- case "cleanup":
365
364
  case "setup":
365
+ case "cleanup":
366
366
  context.report({
367
367
  messageId: "noLeakedIntervalInEffect",
368
368
  node: sEntry.node,
@@ -565,9 +565,9 @@ var no_leaked_timeout_default = createRule({
565
565
  const fStack = [];
566
566
  const sEntries = [];
567
567
  const rEntries = [];
568
- const isInverseEntry = eff.F.dual(2, (a, b) => {
568
+ function isInverseEntry(a, b) {
569
569
  return isInstanceIDEqual(a.timerID, b.timerID, context);
570
- });
570
+ }
571
571
  return {
572
572
  [":function"](node) {
573
573
  const fKind = eff.O.getOrElse(getPhaseKindOfFunction(node), () => "other");
@@ -581,18 +581,6 @@ var no_leaked_timeout_default = createRule({
581
581
  if (!fNode || !fKind) return;
582
582
  if (!core.ERPhaseRelevance.has(fKind)) return;
583
583
  switch (getCallKind4(node)) {
584
- case "clearTimeout": {
585
- const [timeoutIdNode] = node.arguments;
586
- if (!timeoutIdNode) break;
587
- rEntries.push({
588
- kind: "timeout",
589
- node,
590
- callee: node.callee,
591
- phase: fKind,
592
- timerID: timeoutIdNode
593
- });
594
- break;
595
- }
596
584
  case "setTimeout": {
597
585
  const timeoutIdNode = eff.O.getOrNull(VAR2__namespace.getVariableDeclaratorID(node));
598
586
  if (!timeoutIdNode) {
@@ -611,14 +599,26 @@ var no_leaked_timeout_default = createRule({
611
599
  });
612
600
  break;
613
601
  }
602
+ case "clearTimeout": {
603
+ const [timeoutIdNode] = node.arguments;
604
+ if (!timeoutIdNode) break;
605
+ rEntries.push({
606
+ kind: "timeout",
607
+ node,
608
+ callee: node.callee,
609
+ phase: fKind,
610
+ timerID: timeoutIdNode
611
+ });
612
+ break;
613
+ }
614
614
  }
615
615
  },
616
616
  ["Program:exit"]() {
617
617
  for (const sEntry of sEntries) {
618
- if (rEntries.some(isInverseEntry(sEntry))) continue;
618
+ if (rEntries.some((rEntry) => isInverseEntry(sEntry, rEntry))) continue;
619
619
  switch (sEntry.phase) {
620
- case "cleanup":
621
620
  case "setup":
621
+ case "cleanup":
622
622
  context.report({
623
623
  messageId: "noLeakedTimeoutInEffect",
624
624
  node: sEntry.node,
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as AST2 from '@eslint-react/ast';
2
- import { isInversePhase, ERPhaseRelevance, isSetupFunction, isCleanupFunction, isComponentDidMountFunction, isComponentWillUnmountFunction } from '@eslint-react/core';
2
+ import { ERPhaseRelevance, isSetupFunction, isCleanupFunction, isComponentDidMountFunction, isComponentWillUnmountFunction, isInversePhase } from '@eslint-react/core';
3
3
  import { Data, O, F, or, not, isBoolean } from '@eslint-react/eff';
4
4
  import * as JSX from '@eslint-react/jsx';
5
5
  import * as VAR2 from '@eslint-react/var';
@@ -10,7 +10,7 @@ import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/types';
10
10
 
11
11
  // package.json
12
12
  var name = "eslint-plugin-react-web-api";
13
- var version = "1.22.2-next.9";
13
+ var version = "1.23.0-beta.0";
14
14
  var createRule = createRuleForPlugin("web-api");
15
15
  function getInstanceID(node, prev) {
16
16
  switch (true) {
@@ -147,17 +147,7 @@ var no_leaked_event_listener_default = createRule({
147
147
  const aEntries = [];
148
148
  const rEntries = [];
149
149
  const abortedSignals = [];
150
- function checkInlineFunction(node, callKind, options) {
151
- const [_, listener] = node.arguments;
152
- if (!AST2.isFunction(listener)) return O.none();
153
- if (O.isSome(options.signal)) return O.none();
154
- return O.some({
155
- messageId: "noLeakedEventListenerOfInlineFunction",
156
- node: listener,
157
- data: { eventMethodKind: callKind }
158
- });
159
- }
160
- const isSameObject = F.dual(2, (a, b) => {
150
+ function isSameObject(a, b) {
161
151
  switch (true) {
162
152
  case (a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression):
163
153
  return AST2.isNodeEqual(a.object, b.object);
@@ -165,8 +155,8 @@ var no_leaked_event_listener_default = createRule({
165
155
  default:
166
156
  return false;
167
157
  }
168
- });
169
- const isInverseEntry = F.dual(2, (aEntry, rEntry) => {
158
+ }
159
+ function isInverseEntry(aEntry, rEntry) {
170
160
  const { type: aType, callee: aCallee, capture: aCapture, listener: aListener, phase: aPhase } = aEntry;
171
161
  const { type: rType, callee: rCallee, capture: rCapture, listener: rListener, phase: rPhase } = rEntry;
172
162
  if (!isInversePhase(aPhase, rPhase)) return false;
@@ -174,7 +164,17 @@ var no_leaked_event_listener_default = createRule({
174
164
  context.sourceCode.getScope(aType),
175
165
  context.sourceCode.getScope(rType)
176
166
  ]) && O.getOrElse(aCapture, F.constFalse) === O.getOrElse(rCapture, F.constFalse);
177
- });
167
+ }
168
+ function checkInlineFunction(node, callKind, options) {
169
+ const [_, listener] = node.arguments;
170
+ if (!AST2.isFunction(listener)) return O.none();
171
+ if (O.isSome(options.signal)) return O.none();
172
+ return O.some({
173
+ messageId: "noLeakedEventListenerOfInlineFunction",
174
+ node: listener,
175
+ data: { eventMethodKind: callKind }
176
+ });
177
+ }
178
178
  return {
179
179
  [":function"](node) {
180
180
  const functionKind = getFunctionKind(node);
@@ -221,11 +221,11 @@ var no_leaked_event_listener_default = createRule({
221
221
  },
222
222
  ["Program:exit"]() {
223
223
  for (const aEntry of aEntries) {
224
- if (O.exists(aEntry.signal, (signal) => abortedSignals.some(isSameObject(signal)))) continue;
225
- if (rEntries.some(isInverseEntry(aEntry))) continue;
224
+ if (O.exists(aEntry.signal, (signal) => abortedSignals.some((as) => isSameObject(as, signal)))) continue;
225
+ if (rEntries.some((rEntry) => isInverseEntry(aEntry, rEntry))) continue;
226
226
  switch (aEntry.phase) {
227
- case "cleanup":
228
227
  case "setup":
228
+ case "cleanup":
229
229
  context.report({
230
230
  messageId: "noLeakedEventListenerInEffect",
231
231
  node: aEntry.node,
@@ -282,9 +282,9 @@ var no_leaked_interval_default = createRule({
282
282
  const fStack = [];
283
283
  const sEntries = [];
284
284
  const cEntries = [];
285
- const isInverseEntry = F.dual(2, (a, b) => {
285
+ function isInverseEntry(a, b) {
286
286
  return isInstanceIDEqual(a.timerID, b.timerID, context);
287
- });
287
+ }
288
288
  return {
289
289
  [":function"](node) {
290
290
  const fKind = O.getOrElse(getPhaseKindOfFunction(node), () => "other");
@@ -295,13 +295,19 @@ var no_leaked_interval_default = createRule({
295
295
  },
296
296
  ["CallExpression"](node) {
297
297
  switch (getCallKind2(node)) {
298
- case "clearInterval": {
298
+ case "setInterval": {
299
299
  const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
300
300
  if (!fNode || !fKind) break;
301
301
  if (!ERPhaseRelevance.has(fKind)) break;
302
- const [intervalIdNode] = node.arguments;
303
- if (!intervalIdNode) break;
304
- cEntries.push({
302
+ const intervalIdNode = O.getOrNull(VAR2.getVariableDeclaratorID(node));
303
+ if (!intervalIdNode) {
304
+ context.report({
305
+ messageId: "noLeakedIntervalNoIntervalId",
306
+ node
307
+ });
308
+ break;
309
+ }
310
+ sEntries.push({
305
311
  kind: "interval",
306
312
  node,
307
313
  callee: node.callee,
@@ -310,19 +316,13 @@ var no_leaked_interval_default = createRule({
310
316
  });
311
317
  break;
312
318
  }
313
- case "setInterval": {
319
+ case "clearInterval": {
314
320
  const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
315
321
  if (!fNode || !fKind) break;
316
322
  if (!ERPhaseRelevance.has(fKind)) break;
317
- const intervalIdNode = O.getOrNull(VAR2.getVariableDeclaratorID(node));
318
- if (!intervalIdNode) {
319
- context.report({
320
- messageId: "noLeakedIntervalNoIntervalId",
321
- node
322
- });
323
- break;
324
- }
325
- sEntries.push({
323
+ const [intervalIdNode] = node.arguments;
324
+ if (!intervalIdNode) break;
325
+ cEntries.push({
326
326
  kind: "interval",
327
327
  node,
328
328
  callee: node.callee,
@@ -335,10 +335,10 @@ var no_leaked_interval_default = createRule({
335
335
  },
336
336
  ["Program:exit"]() {
337
337
  for (const sEntry of sEntries) {
338
- if (cEntries.some(isInverseEntry(sEntry))) continue;
338
+ if (cEntries.some((cEntry) => isInverseEntry(sEntry, cEntry))) continue;
339
339
  switch (sEntry.phase) {
340
- case "cleanup":
341
340
  case "setup":
341
+ case "cleanup":
342
342
  context.report({
343
343
  messageId: "noLeakedIntervalInEffect",
344
344
  node: sEntry.node,
@@ -541,9 +541,9 @@ var no_leaked_timeout_default = createRule({
541
541
  const fStack = [];
542
542
  const sEntries = [];
543
543
  const rEntries = [];
544
- const isInverseEntry = F.dual(2, (a, b) => {
544
+ function isInverseEntry(a, b) {
545
545
  return isInstanceIDEqual(a.timerID, b.timerID, context);
546
- });
546
+ }
547
547
  return {
548
548
  [":function"](node) {
549
549
  const fKind = O.getOrElse(getPhaseKindOfFunction(node), () => "other");
@@ -557,18 +557,6 @@ var no_leaked_timeout_default = createRule({
557
557
  if (!fNode || !fKind) return;
558
558
  if (!ERPhaseRelevance.has(fKind)) return;
559
559
  switch (getCallKind4(node)) {
560
- case "clearTimeout": {
561
- const [timeoutIdNode] = node.arguments;
562
- if (!timeoutIdNode) break;
563
- rEntries.push({
564
- kind: "timeout",
565
- node,
566
- callee: node.callee,
567
- phase: fKind,
568
- timerID: timeoutIdNode
569
- });
570
- break;
571
- }
572
560
  case "setTimeout": {
573
561
  const timeoutIdNode = O.getOrNull(VAR2.getVariableDeclaratorID(node));
574
562
  if (!timeoutIdNode) {
@@ -587,14 +575,26 @@ var no_leaked_timeout_default = createRule({
587
575
  });
588
576
  break;
589
577
  }
578
+ case "clearTimeout": {
579
+ const [timeoutIdNode] = node.arguments;
580
+ if (!timeoutIdNode) break;
581
+ rEntries.push({
582
+ kind: "timeout",
583
+ node,
584
+ callee: node.callee,
585
+ phase: fKind,
586
+ timerID: timeoutIdNode
587
+ });
588
+ break;
589
+ }
590
590
  }
591
591
  },
592
592
  ["Program:exit"]() {
593
593
  for (const sEntry of sEntries) {
594
- if (rEntries.some(isInverseEntry(sEntry))) continue;
594
+ if (rEntries.some((rEntry) => isInverseEntry(sEntry, rEntry))) continue;
595
595
  switch (sEntry.phase) {
596
- case "cleanup":
597
596
  case "setup":
597
+ case "cleanup":
598
598
  context.report({
599
599
  messageId: "noLeakedTimeoutInEffect",
600
600
  node: sEntry.node,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "1.22.2-next.9",
3
+ "version": "1.23.0-beta.0",
4
4
  "description": "ESLint React's ESLint plugin for interacting with Web APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -46,13 +46,13 @@
46
46
  "@typescript-eslint/utils": "^8.18.2",
47
47
  "string-ts": "^2.2.0",
48
48
  "ts-pattern": "^5.6.0",
49
- "@eslint-react/ast": "1.22.2-next.9",
50
- "@eslint-react/core": "1.22.2-next.9",
51
- "@eslint-react/shared": "1.22.2-next.9",
52
- "@eslint-react/eff": "1.22.2-next.9",
53
- "@eslint-react/jsx": "1.22.2-next.9",
54
- "@eslint-react/types": "1.22.2-next.9",
55
- "@eslint-react/var": "1.22.2-next.9"
49
+ "@eslint-react/ast": "1.23.0-beta.0",
50
+ "@eslint-react/core": "1.23.0-beta.0",
51
+ "@eslint-react/jsx": "1.23.0-beta.0",
52
+ "@eslint-react/eff": "1.23.0-beta.0",
53
+ "@eslint-react/shared": "1.23.0-beta.0",
54
+ "@eslint-react/types": "1.23.0-beta.0",
55
+ "@eslint-react/var": "1.23.0-beta.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/react": "^19.0.2",