Skip to content

Commit 3b76a1e

Browse files
authored
npm audit fix, replace eslint-plugin-playwright with our own rule (#3441)
### npm audit fix The first commit clears everything `npm audit` reported, all of it in dev tooling or the mock API. Two things went beyond a plain `npm audit fix`: - vitest and `@vitest/browser-playwright` are bumped to 5.1.0 in `package.json`. The vitest packages pin each other as exact peer dependencies, so npm couldn't update them in place and they had to be reinstalled together. - The lockfile entry for `proxy-addr` said 2.0.7 but had the tarball URL and integrity hash of 2.0.8, so the fixed version was already installed and only the version field was wrong. ### Our own Playwright lint rule One of the audit findings was in eslint, which we never run: [eslint-plugin-playwright](https://github.com/mskelton/eslint-plugin-playwright) requires it as a peer dependency. The plugin is maintained, but we only used one rule from it, `expect-expect`, which is about 30 lines of logic upstream. The second commit replaces it with a local oxlint plugin in `tools/oxlint-plugin-playwright.ts`, which lets us drop eslint entirely: 66 packages and about 850 lines come out of the lockfile. To check it's as good as before, I ran the old and new rule over `test/e2e` and they flagged the same tests: none, plus the five in `disks.e2e.ts` that were behind a disable comment. We also checked with temporary specs that a test with no assertions is flagged and that tests using only `expect.poll` or a helper like `expectRowVisible` are not. It's better than before in a few ways, and easy to keep customizing: - Assertions in `beforeEach`/`afterEach` count, so the disable comment in `disks.e2e.ts` is gone. - Any call starting with `expect` counts as an assertion, so we no longer keep a list of helper names in `.oxlintrc.json`. - The rule is an error now. It was a warning, which didn't fail lint. - Two new rules for conventions we already had: `no-focused-test` (`test.only`) and `no-page-route` (use a sentinel in the mock API, not `page.route`). A comment in the plugin lists four more rules we plan to add once existing violations are cleaned up. This PR also deletes 13 disable comments for playwright rules that were never enabled.
1 parent 47477f2 commit 3b76a1e

12 files changed

Lines changed: 478 additions & 948 deletions

‎.oxlintrc.json‎

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"$schema": "./node_modules/oxlint/configuration_schema.json",
33
"jsPlugins": [
4-
{
5-
"name": "playwright",
6-
"specifier": "eslint-plugin-playwright"
7-
},
4+
"./tools/oxlint-plugin-playwright.ts",
85
{
96
"name": "react-hook-form",
107
"specifier": "eslint-plugin-react-hook-form"
@@ -120,7 +117,8 @@
120117
"app/entry.server.tsx",
121118
"*.config.ts",
122119
"*.config.mjs",
123-
"test/e2e/compact-reporter.ts"
120+
"test/e2e/compact-reporter.ts",
121+
"tools/oxlint-plugin-playwright.ts"
124122
],
125123
"rules": {
126124
"import/no-default-export": "off"
@@ -140,22 +138,13 @@
140138
}
141139
},
142140
{
143-
// catch unawaited Playwright calls in e2e tests
144-
"files": ["test/e2e/**/*.ts"],
141+
"files": ["test/e2e/**/*.ts", "test/**/*.e2e.ts"],
145142
"rules": {
143+
// catch unawaited Playwright calls
146144
"@typescript-eslint/no-floating-promises": "error",
147-
"playwright/expect-expect": [
148-
"warn",
149-
{
150-
"assertFunctionNames": [
151-
"expectVisible",
152-
"expectRowVisible",
153-
"expectOptions",
154-
"expectRowMenuStaysOpen"
155-
]
156-
}
157-
],
158-
"playwright/no-force-option": "off"
145+
"playwright/expect-expect": "error",
146+
"playwright/no-focused-test": "error",
147+
"playwright/no-page-route": "error"
159148
}
160149
}
161150
],

0 commit comments

Comments
 (0)