Skip to content

chore(lint): enable ban-ts-comment rule and fix ts-ignore usages#16799

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/12-13-feat_lint_enable_ban-ts-comment_rule_and_fix_ts-ignore_usages
Dec 13, 2025
Merged

chore(lint): enable ban-ts-comment rule and fix ts-ignore usages#16799
graphite-app[bot] merged 1 commit intomainfrom
c/12-13-feat_lint_enable_ban-ts-comment_rule_and_fix_ts-ignore_usages

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Dec 13, 2025

follow on from #16796

@github-actions github-actions bot added A-parser Area - Parser C-enhancement Category - New feature or request labels Dec 13, 2025
Copy link
Copy Markdown
Contributor Author

camc314 commented Dec 13, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@camc314 camc314 marked this pull request as ready for review December 13, 2025 15:24
Copilot AI review requested due to automatic review settings December 13, 2025 15:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-comment rule in oxlintrc.json with allow-with-description configuration
  • Replaces @ts-ignore with @ts-expect-error comments 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.

@camc314 camc314 changed the title feat(lint): enable ban-ts-comment rule and fix ts-ignore usages chore(lint): enable ban-ts-comment rule and fix ts-ignore usages Dec 13, 2025
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Dec 13, 2025
@camc314 camc314 force-pushed the c/12-13-feat_lint_enable_ban-ts-comment_rule_and_fix_ts-ignore_usages branch from 2d12515 to 8ae37f1 Compare December 13, 2025 15:29
Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
    These range tests removed the @ts-ignore but still access .range on 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 (or any) 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
    Using null! 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 like asAny(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
    Assigning mockedWindow via {} as (typeof globalThis)["window"] makes the mock look like a real Window, 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 access window.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-comment in oxlintrc.json with ts-expect-error allowed only when accompanied by a description.
  • Updated several tests to replace // @ts-ignore with // @ts-expect-error (and added brief descriptions in some places).
  • Added an oxlint-disable-next-line to keep // @ts-nocheck in lazy-deserialization.test.ts.
  • Removed several @ts-ignore lines in parse.test.ts around range assertions.
  • Replaced an unsafe new Visitor() call in visit.test.ts with new Visitor(null!) to exercise runtime validation.
  • Tightened the mocked window typing in tasks/e2e/test/utils.ts and made the delete globalThis.window suppression an explicit @ts-expect-error.

@charliecreates charliecreates bot removed the request for review from CharlieHelps December 13, 2025 15:30
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Thank you.

"Charlie Helps" isn't very helpful is he?

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
Copy link
Copy Markdown
Member

overlookmotel commented Dec 13, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the c/12-13-feat_lint_enable_ban-ts-comment_rule_and_fix_ts-ignore_usages branch from 8ae37f1 to af0f2af Compare December 13, 2025 16:19
@graphite-app graphite-app bot merged commit af0f2af into main Dec 13, 2025
18 checks passed
@graphite-app graphite-app bot deleted the c/12-13-feat_lint_enable_ban-ts-comment_rule_and_fix_ts-ignore_usages branch December 13, 2025 16:25
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
@camc314
Copy link
Copy Markdown
Contributor Author

camc314 commented Dec 13, 2025

Great. Thank you.

"Charlie Helps" isn't very helpful is he?

I think it's helpful 🫣

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

Labels

A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants