Skip to content

Conversation

@vladlearns
Copy link

Hello @mskelton!

I've created a new rule that addresses the real production issue my team discovered where incorrect annotation format was breaking test reports.

image

P.S + excluded .history folder

…nnotation format

This rule addresses a critical production issue where incorrect annotation format
(annotation: "bug" instead of annotation: { type: "bug" }) was causing test
reports to break and not show up.

The rule validates that:
- Annotations are objects or arrays of objects (not strings)
- Each annotation has a required 'type' property
- Optional 'description' property is a string
- Only 'type' and 'description' properties are allowed
- Detects when 'tag' is incorrectly placed inside 'annotation'

This will catch these issues at lint time, preventing broken test reports
before they reach CI/CD.

Fixes the issue discovered in test @XRAY-13376 where annotation: "bug"
caused the test report to not show up.
@mskelton
Copy link
Owner

mskelton commented Oct 7, 2025

A cryptic stack trace is not helpful, what code did you have that was causing breakage?

@vladlearns
Copy link
Author

vladlearns commented Oct 7, 2025

A cryptic stack trace is not helpful, what code did you have that was causing breakage?

@mskelton, the code was annotation: "bug" and the first time it was an obj, but with a missing type property
I've added a bunch cases here https://github.com/mskelton/eslint-plugin-playwright/pull/397/files#diff-ff3b8de5f58db65c040c889db687dcb5343de932252de7e1d024721e125a4fff

here is the code from the pw:
image

it is in the screenshot above also :)
image

@mskelton
Copy link
Owner

mskelton commented Oct 8, 2025

This should already be handled by Playwright's TypeScript types. Why do we need a linter to implement types?

@vladlearns
Copy link
Author

vladlearns commented Oct 8, 2025

This should already be handled by Playwright's TypeScript types. Why do we need a linter to implement types?

For js files.

Even for ts - runtime validation does not check the structure of annotation obj and always thinks that is valid

https://playwright.dev/docs/test-typescript
image

@vladlearns
Copy link
Author

fixed here: microsoft/playwright#37761

@mskelton
Copy link
Owner

mskelton commented Oct 8, 2025

For js files.

Just use // @ts-check.

@mskelton
Copy link
Owner

mskelton commented Oct 8, 2025

I'm declining this, this plugin is not for the purpose of doing what TypeScript can already do. Seriously, just use TypeScript.

@mskelton mskelton closed this Oct 8, 2025
@vladlearns vladlearns deleted the feat/valid-test-annotations branch October 9, 2025 09:20
@vladlearns
Copy link
Author

I'm declining this, this plugin is not for the purpose of doing what TypeScript can already do. Seriously, just use TypeScript.

This is not something I can control at this place of work. I tried to enforce it.
Either way, fixed in the pw repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants