Skip to content

Commit 9d15ec8

Browse files
Merge branch 'main' into fix/top-level-bench-duplicate-output
2 parents 5ab201e + faace1f commit 9d15ec8

File tree

47 files changed

+501
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+501
-84
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
name: typo-checker
3+
description: >
4+
Run typos-cli on the codebase, review findings, fix real typos, and update
5+
_typos.toml config to suppress false positives. Use this skill for routine
6+
codebase typo maintenance. Invoke when doing periodic codebase hygiene,
7+
when the user mentions typos or spelling checks, or as a scheduled
8+
maintenance task.
9+
---
10+
11+
# Typo Checker
12+
13+
Scan the codebase with `typos-cli`, classify findings, fix real typos, and maintain `_typos.toml` so false positives don't recur.
14+
15+
## Prerequisites
16+
17+
`typos-cli` must be installed. If not available, install via one of:
18+
19+
| Method | Command |
20+
|---|---|
21+
| cargo | `cargo install typos-cli` |
22+
| brew | `brew install typos-cli` |
23+
| pipx | `pipx install typos` |
24+
| Binary | Download from https://github.com/crate-ci/typos/releases |
25+
26+
## Workflow
27+
28+
### 1. Scan
29+
30+
```bash
31+
typos --format=brief
32+
```
33+
34+
This outputs one finding per line: `file:line:col: \`typo\` -> \`suggestion\``. Compact and easy to parse.
35+
36+
`typos` respects `.gitignore` by default, so `node_modules/`, `dist/`, build outputs are already excluded.
37+
38+
To get an overview first:
39+
40+
```bash
41+
# Count unique typo words by frequency
42+
typos --format=brief 2>&1 | sed "s/.*\`//;s/\`.*//" | sort | uniq -c | sort -rn | head -20
43+
```
44+
45+
If many findings come from minified/generated files, add those paths to `_typos.toml` `extend-exclude` first, then re-scan.
46+
47+
### 2. Classify each finding
48+
49+
For every finding, decide:
50+
51+
- **Real typo** — fix it
52+
- **False positive** — add to `_typos.toml`
53+
54+
Common false positive patterns:
55+
- Short variable names that happen to be words (`ba`, `fo`, `nd`)
56+
- Domain abbreviations (`als` for AsyncLocalStorage, `PnP` for Plug'n'Play)
57+
- File extensions in regexes (`.styl`, `.pcss`)
58+
- Test fixture strings and test data
59+
- Line truncation artifacts in inline snapshots (`afte...`, `wrapp...`)
60+
- Product names and proper nouns
61+
- Lorem ipsum text
62+
63+
When in doubt about whether a misspelled variable name is "intentional" — it's still a typo. Propagated typos are still typos. Fix them.
64+
65+
### 3. Fix real typos
66+
67+
- **Comments, docs, JSDoc**: fix the text directly
68+
- **Variable/property names**: rename all occurrences consistently
69+
- **Test names**: fix the name, update corresponding snapshot files
70+
- **Filenames**: rename the file and update all imports/references — check for references before renaming
71+
72+
### 4. Update `_typos.toml`
73+
74+
Add false positives to `[default.extend-words]` with a comment explaining why:
75+
76+
```toml
77+
[default.extend-words]
78+
# AsyncLocalStorage abbreviation
79+
als = "als"
80+
```
81+
82+
For file-level exclusions, use `[files].extend-exclude`:
83+
84+
```toml
85+
[files]
86+
extend-exclude = [
87+
"*.js.map",
88+
"*.svg",
89+
]
90+
```
91+
92+
If `_typos.toml` doesn't exist yet, create it.
93+
94+
### 5. Commit
95+
96+
Commit fixes and config updates together:
97+
98+
```
99+
chore: fix typos and update _typos.toml
100+
```

_typos.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[files]
2+
extend-exclude = [
3+
"*.js.map",
4+
"*.svg",
5+
"test/cli/test/fixtures/reporters/html/**",
6+
]
7+
8+
[default.extend-words]
9+
# AsyncLocalStorage abbreviation
10+
als = "als"
11+
# Stylus CSS preprocessor extension
12+
styl = "styl"
13+
# Yarn Plug'n'Play
14+
Pn = "Pn"
15+
PnP = "PnP"
16+
# Variable prefix pattern (b-a annotation diff)
17+
ba = "ba"
18+
# Ordinal suffix
19+
nd = "nd"
20+
# Test string with backtick escaping: 'som`e`'
21+
som = "som"
22+
# Line truncation artifacts in test output
23+
afte = "afte"
24+
wrapp = "wrapp"
25+
# Test data string
26+
fo = "fo"
27+
# Latin lorem ipsum
28+
optio = "optio"
29+
# Product name (evalite.dev)
30+
Evalite = "Evalite"
31+
# Typo in upstream tinyhighlight LICENSE (TODO: fix upstream)
32+
Additionaly = "Additionaly"

docs/config/experimental.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ vi.mock('node:fs', async (importOriginal) => {
372372
const fs = require('node:fs') // throws an error
373373
```
374374

375-
This limitation exists because factories can be asynchronous. This should not be a problem because Vitest doesn't mock builtin modules inside `node_modules`, which is simillar to how Vitest works by default.
375+
This limitation exists because factories can be asynchronous. This should not be a problem because Vitest doesn't mock builtin modules inside `node_modules`, which is similar to how Vitest works by default.
376376

377377
### TypeScript
378378

examples/opentelemetry/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# and serve Web UI at http://localhost:16686
1010
docker compose up -d
1111

12-
# Run tests (exports with OTLP HTTP by deafult)
12+
# Run tests (exports with OTLP HTTP by default)
1313
pnpm test --experimental.openTelemetry.enabled
1414

1515
# Use console exporter for quick debugging

examples/opentelemetry/otel-browser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const provider = new WebTracerProvider({
1717
provider.register({
1818
// you can customize contextManager but browser support has limitation
1919
// cf. https://github.com/open-telemetry/opentelemetry-js/discussions/2060
20-
// contextManager: new StackContextManager(), // this is the default (avialable in sdk-trace-web)
21-
// contextManager: new ZoneContextManager(), // doesn't seem to help (avialable in @opentelemetry/context-zone)
20+
// contextManager: new StackContextManager(), // this is the default (available in sdk-trace-web)
21+
// contextManager: new ZoneContextManager(), // doesn't seem to help (available in @opentelemetry/context-zone)
2222
})
2323

2424
export default provider

packages/browser/context.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export { CDPSession };
2121

2222
export interface ScreenshotOptions extends SelectorOptions {
2323
/**
24-
* The HTML element to screeshot.
24+
* The HTML element to screenshot.
2525
*/
2626
element?: Element | Locator
2727
/**
@@ -905,7 +905,7 @@ export type PrettyDOMOptions = Omit<StringifyOptions, 'maxLength'>
905905

906906
export const utils: {
907907
/**
908-
* This is simillar to calling `page.elementLocator`, but it returns only
908+
* This is similar to calling `page.elementLocator`, but it returns only
909909
* locator selectors.
910910
*/
911911
getElementLocatorSelectors(element: Element): LocatorSelectors

packages/browser/src/client/public/error-catcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function catchWindowErrors(errorEvent, prop, cb) {
3131
cb(e)
3232
}
3333
else {
34-
// `ErrorEvent` doesn't necessary have `ErrotEvent.error` defined
34+
// `ErrorEvent` doesn't necessary have `ErrorEvent.error` defined
3535
// but some has `ErrorEvent.message` defined, e.g. ResizeObserver error.
3636
// https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent/error
3737
// https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#observation_errors

packages/browser/src/client/tester/expect/toMatchScreenshot.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,8 @@ export default async function toMatchScreenshot(
120120
]
121121
.filter(element => element !== null)
122122
.join('\n'),
123+
meta: {
124+
outcome: result.outcome,
125+
},
123126
}
124127
}

packages/browser/src/client/tester/runner.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,16 @@ export function createBrowserRunner(
156156
}
157157

158158
onTaskFinished = async (task: Task) => {
159+
const lastErrorContext = task.result?.errors?.at(-1)?.context
159160
if (
160161
this.config.browser.screenshotFailures
161162
&& document.body.clientHeight > 0
162163
&& task.result?.state === 'fail'
163164
&& task.type === 'test'
164-
&& task.artifacts.every(
165-
artifact => artifact.type !== 'internal:toMatchScreenshot',
166-
)
165+
&& !(
166+
lastErrorContext
167+
&& Reflect.get(lastErrorContext, 'assertionName') === 'toMatchScreenshot'
168+
&& Reflect.get(lastErrorContext, 'meta')?.outcome !== 'unstable-screenshot')
167169
) {
168170
const screenshot = await page.screenshot({
169171
timeout: this.config.browser.providerOptions?.actionTimeout ?? 5_000,

packages/browser/src/node/commands/screenshotMatcher/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ function buildOutput(
273273
case 'unstable-screenshot':
274274
return {
275275
pass: false,
276+
outcome: outcome.type,
276277
reference: outcome.reference && {
277278
path: outcome.reference.path,
278279
width: outcome.reference.image.metadata.width,
@@ -286,6 +287,7 @@ function buildOutput(
286287
case 'missing-reference': {
287288
return {
288289
pass: false,
290+
outcome: outcome.type,
289291
reference: {
290292
path: outcome.reference.path,
291293
width: outcome.reference.image.metadata.width,
@@ -302,11 +304,12 @@ function buildOutput(
302304
case 'update-reference':
303305
case 'matched-immediately':
304306
case 'matched-after-comparison':
305-
return { pass: true }
307+
return { pass: true, outcome: outcome.type }
306308

307309
case 'mismatch':
308310
return {
309311
pass: false,
312+
outcome: outcome.type,
310313
reference: {
311314
path: outcome.reference.path,
312315
width: outcome.reference.image.metadata.width,
@@ -333,6 +336,7 @@ function buildOutput(
333336

334337
return {
335338
pass: false,
339+
outcome: null as never,
336340
actual: null,
337341
reference: null,
338342
diff: null,

0 commit comments

Comments
 (0)