Skip to content

Comments

refactor(linter/plugins): rename assertion functions#15968

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-22-refactor_linter_plugins_rename_assertion_functions
Nov 22, 2025
Merged

refactor(linter/plugins): rename assertion functions#15968
graphite-app[bot] merged 1 commit intomainfrom
11-22-refactor_linter_plugins_rename_assertion_functions

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Nov 22, 2025

Rename assertion functions to clarify that they're not "real" assertions which we can rely on for validating input, and are only for compile-time testing or debug assertions.

typeAssertIs is not a great name, but I couldn't come up with anything better. debugAssertIs would be not be accurate, as it'd imply that in debug builds it performs an actual runtime assertion, which it doesn't.

In any case, we should replace typeAssertIs with specialized assertion functions which do actually perform runtime assertions in debug builds (e.g. typeAssertIs<Fix>(fix) -> debugAssertIsFix(fix)).

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Nov 22, 2025
Copy link
Member Author


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.

Copy link
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 refactors assertion functions to clarify their intended usage and limitations. The functions are renamed from assertIs to typeAssertIs and assertIsNonNull to debugAssertIsNonNull, making it explicit that these are not traditional runtime assertions suitable for input validation. The typeAssertIs function is purely for compile-time type checking with zero runtime cost, while debugAssertIsNonNull performs runtime checks only in debug builds.

Key changes:

  • Renamed assertIs to typeAssertIs to clarify it's a compile-time type assertion
  • Renamed assertIsNonNull to debugAssertIsNonNull to indicate debug-only runtime behavior
  • Updated all import statements and call sites consistently across 12 files

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
apps/oxlint/src-js/utils/asserts.ts Function definitions renamed: assertIstypeAssertIs, assertIsNonNulldebugAssertIsNonNull
apps/oxlint/src-js/plugins/visitor.ts Updated imports and 4 call sites to use new function names
apps/oxlint/src-js/plugins/tokens.ts Updated imports and 4 call sites to use debugAssertIsNonNull
apps/oxlint/src-js/plugins/source_code.ts Updated imports and 5 call sites to use debugAssertIsNonNull
apps/oxlint/src-js/plugins/settings.ts Updated imports and 1 call site to use debugAssertIsNonNull
apps/oxlint/src-js/plugins/scope.ts Updated imports and 5 call sites to use new function names
apps/oxlint/src-js/plugins/location.ts Updated imports and 3 call sites to use debugAssertIsNonNull
apps/oxlint/src-js/plugins/lint.ts Updated imports and 3 call sites to use new function names
apps/oxlint/src-js/plugins/fix.ts Updated imports and 1 call site to use typeAssertIs
apps/oxlint/src-js/plugins/context.ts Updated imports and 3 call sites to use debugAssertIsNonNull
apps/oxlint/src-js/plugins/comments.ts Updated imports and 6 call sites to use debugAssertIsNonNull
apps/oxlint/src-js/index.ts Updated imports and 1 call site to use debugAssertIsNonNull
apps/oxlint/src-js/cli.ts Updated imports and 2 call sites to use debugAssertIsNonNull

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel self-assigned this Nov 22, 2025
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Nov 22, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 22, 2025

Merge activity

Rename assertion functions to clarify that they're not "real" assertions which we can rely on for validating input, and are only for compile-time testing or debug assertions.

`typeAssertIs` is not a great name, but I couldn't come up with anything better. `debugAssertIs` would be not be accurate, as it'd imply that in debug builds in performs an actual assertion, which it doesn't.

In any case, we should replace `typeAssertIs` with specialized assertion functions which do actually perform runtime assertions in debug builds (e.g. `typeAssertIs<Fix>()` -> `debugAssertIsFix()`).
@graphite-app graphite-app bot force-pushed the 11-22-refactor_linter_plugins_rename_assertion_functions branch from fa9143e to ae13704 Compare November 22, 2025 15:54
@graphite-app graphite-app bot merged commit ae13704 into main Nov 22, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 11-22-refactor_linter_plugins_rename_assertion_functions branch November 22, 2025 16:00
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 22, 2025
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
Rename assertion functions to clarify that they're not "real" assertions which we can rely on for validating input, and are only for compile-time testing or debug assertions.

`typeAssertIs` is not a great name, but I couldn't come up with anything better. `debugAssertIs` would be not be accurate, as it'd imply that in debug builds in performs an actual assertion, which it doesn't.

In any case, we should replace `typeAssertIs` with specialized assertion functions which do actually perform runtime assertions in debug builds (e.g. `typeAssertIs<Fix>()` -> `debugAssertIsFix()`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant