eslint-plugin-no-mistakes 0.60.0 → 0.61.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-no-mistakes",
3
- "version": "0.60.0",
3
+ "version": "0.61.0",
4
4
  "description": "ESLint and Oxlint rules that keep code static enough for no-mistakes analyzers and coding agents",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -25,7 +25,6 @@ const rules = {
25
25
  "playwright-no-empty": require("./rules/playwright-no-empty"),
26
26
  "playwright-no-hoisted-unique-token": require("./rules/playwright-no-hoisted-unique-token"),
27
27
  "playwright-no-raw-scroll-pagination": require("./rules/playwright-no-raw-scroll-pagination"),
28
- "playwright-no-set-timeout": require("./rules/playwright-no-set-timeout"),
29
28
  "playwright-prefer-get-by-test-id": require("./rules/playwright-prefer-get-by-test-id"),
30
29
  "playwright-require-exported-component-attribute": require("./rules/playwright-require-exported-component-attribute"),
31
30
  "playwright-require-interactive-test-id": require("./rules/playwright-require-interactive-test-id"),
@@ -92,7 +91,6 @@ plugin.configs.strict = {
92
91
  "no-mistakes/playwright-assertion-timeout-cap": "error",
93
92
  "no-mistakes/playwright-consistent-attribute": ["error", { canonicalAttribute: "data-pw" }],
94
93
  "no-mistakes/playwright-naming-convention": "error",
95
- "no-mistakes/playwright-no-set-timeout": "error",
96
94
  "no-mistakes/playwright-prefer-get-by-test-id": "warn",
97
95
  "no-mistakes/playwright-require-interactive-test-id": "warn",
98
96
  "no-mistakes/playwright-selector-priority": "error",
@@ -33,8 +33,8 @@ function propertyName(node) {
33
33
  }
34
34
 
35
35
  // `page.waitForRequest(...)` / `page.waitForResponse(...)`, matched by property name only — the
36
- // object (page, frame, a locator, ...) doesn't matter, mirroring how `playwright-no-set-timeout`
37
- // matches `.waitForTimeout` regardless of receiver. A statically computed access
36
+ // object (page, frame, a locator, ...) does not affect the cursor relationship.
37
+ // A statically computed access
38
38
  // (`page["waitForRequest"]`) is just as unambiguous as dot access and is matched the same way.
39
39
  function isCursorWaitCall(node) {
40
40
  return (
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- const { rule } = require("../helpers");
4
-
5
- const PLAYWRIGHT_PATH_PATTERN =
6
- /(?:^|[/\\])(?:e2e|playwright)(?:[/\\]|$)|(?:^|[/\\])e2e\.(?:spec|test)\.[cm]?[jt]sx?$|\.pw\.(?:spec|test)\.[cm]?[jt]sx?$/;
7
-
8
- function isPlaywrightPath(filename) {
9
- return PLAYWRIGHT_PATH_PATTERN.test(filename.replace(/\\/g, "/"));
10
- }
11
-
12
- function isWaitForTimeout(node) {
13
- return (
14
- node.callee.type === "MemberExpression" &&
15
- propertyName(node.callee.property, node.callee.computed) === "waitForTimeout"
16
- );
17
- }
18
-
19
- function propertyName(node, computed = false) {
20
- if (node.type === "Literal") return String(node.value);
21
- if (computed) return null;
22
- return node.name;
23
- }
24
-
25
- function isGlobalSetTimeout(node, context) {
26
- let scope = context.sourceCode.getScope(node);
27
- while (scope) {
28
- const get = scope.set?.get;
29
- const variable =
30
- typeof get === "function"
31
- ? get.call(scope.set, "setTimeout")
32
- : scope.variables.find((candidate) => candidate.name === "setTimeout");
33
- if (variable) return variable.defs.length === 0;
34
- scope = scope.upper;
35
- }
36
- return true;
37
- }
38
-
39
- module.exports = rule(
40
- {
41
- type: "problem",
42
- docs: { description: "disallow fixed sleeps in Playwright tests", recommended: false },
43
- schema: [],
44
- messages: {
45
- timeout:
46
- "Do not use fixed sleeps (setTimeout()/waitForTimeout()) in Playwright tests. Wait for an observable condition instead.",
47
- },
48
- },
49
- (context) => {
50
- let isPlaywrightFile = isPlaywrightPath(context.filename);
51
- return {
52
- ImportDeclaration(node) {
53
- if (node.source.value === "@playwright/test") isPlaywrightFile = true;
54
- },
55
- CallExpression(node) {
56
- if (!isPlaywrightFile) return;
57
- if (
58
- (node.callee.type === "Identifier" &&
59
- node.callee.name === "setTimeout" &&
60
- isGlobalSetTimeout(node.callee, context)) ||
61
- isWaitForTimeout(node)
62
- ) {
63
- context.report({ node, messageId: "timeout" });
64
- }
65
- },
66
- };
67
- },
68
- );