chore(lint): enable ban-ts-comment rule and fix ts-ignore usages#16799
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR enables the typescript/ban-ts-comment ESLint rule with the allow-with-description configuration, requiring all @ts-expect-error comments to include descriptions. The changes update existing @ts-ignore comments to @ts-expect-error with descriptions and fixes one test case to use proper null handling instead of suppressing type errors.
Key Changes:
- Enables
typescript/ban-ts-commentrule in oxlintrc.json withallow-with-descriptionconfiguration - Replaces
@ts-ignorewith@ts-expect-errorcomments that include descriptions - Refactors test code to use type assertions and null assertion operators instead of suppressing errors
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| oxlintrc.json | Adds the typescript/ban-ts-comment rule with allow-with-description configuration |
| tasks/e2e/test/utils.ts | Replaces type suppression with type assertion for mockedWindow and adds description to @ts-expect-error comment |
| napi/parser/test/visit.test.ts | Refactors to use null! assertion instead of @ts-ignore |
| napi/parser/test/parse.test.ts | Converts @ts-ignore to @ts-expect-error with descriptions; removes outdated TODO comments for range property |
| napi/parser/test/lazy-deserialization.test.ts | Adds oxlint disable comment for the @ts-nocheck directive |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2d12515 to
8ae37f1
Compare
There was a problem hiding this comment.
Enabling typescript/ban-ts-comment is a good step, but a few new suppressions are either too broad (@ts-nocheck) or not consistently/meaningfully described (@ts-expect-error ignore). Some removed @ts-ignore comments (notably around .range) may reintroduce “accidentally untyped” access unless typings were actually corrected elsewhere. A couple of test changes (null!, Window mock typing) reduce lint violations but could be clearer/safer in intent and runtime behavior.
Additional notes (3)
- Maintainability |
napi/parser/test/parse.test.ts:704-717
Theserangetests removed the@ts-ignorebut still access.rangeon AST nodes. That’s fine if the underlying types were fixed, but the deleted TODO explicitly said the TS definitions weren’t corrected yet. If the type definitions were not updated in this PR, the only reason this compiles is likely that the node is typed loosely (orany) somewhere, which can hide real typing regressions.
At minimum, consider reintroducing a targeted @ts-expect-error with a specific reason if the types are still known-incomplete, or ensure the tests assert range via a well-defined narrowing/type guard to keep this from being “accidentally untyped”.
- Readability |
napi/parser/test/visit.test.ts:14-18
Usingnull!here avoids@ts-ignore, but it introduces a non-null assertion to force a runtime error path. For tests that intentionally pass invalid inputs, prefer an explicit unsafe cast (null as unknown as VisitorObject) or a helper likeasAny(null)if your codebase has one, so the intent is clearly “invalid type” rather than “I assert this isn’t null”.
null! can also read as accidental rather than deliberate invalid-input testing.
- Maintainability |
tasks/e2e/test/utils.ts:61-70
AssigningmockedWindowvia{} as (typeof globalThis)["window"]makes the mock look like a realWindow, but it’s still an empty object at runtime. That can mask missing properties and lead to false confidence in tests: code under test might accesswindow.document(etc.) and crash, but this typing suggests it’s present.
If the goal is just to satisfy globalThis.window assignment typing, it’s better to type it as Window | undefined on the global, or assign globalThis.window = mockedWindow as unknown as Window with an explicit comment that it’s a minimal stub. Also, the delete globalThis.window suppression should explain why delete is needed (e.g., window is non-optional in lib DOM typings).
Summary of changes
Summary of changes
- Enabled
typescript/ban-ts-commentinoxlintrc.jsonwithts-expect-errorallowed only when accompanied by a description. - Updated several tests to replace
// @ts-ignorewith// @ts-expect-error(and added brief descriptions in some places). - Added an
oxlint-disable-next-lineto keep// @ts-nocheckinlazy-deserialization.test.ts. - Removed several
@ts-ignorelines inparse.test.tsaroundrangeassertions. - Replaced an unsafe
new Visitor()call invisit.test.tswithnew Visitor(null!)to exercise runtime validation. - Tightened the mocked
windowtyping intasks/e2e/test/utils.tsand made thedelete globalThis.windowsuppression an explicit@ts-expect-error.
overlookmotel
left a comment
There was a problem hiding this comment.
Great. Thank you.
"Charlie Helps" isn't very helpful is he?
Merge activity
|
8ae37f1 to
af0f2af
Compare
I think it's helpful 🫣 |

follow on from #16796