refactor(linter/plugins): debug assert that values passed via NAPI are not undefined#20070
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 6, 2026
Conversation
This was referenced Mar 6, 2026
This was referenced Mar 6, 2026
Member
Author
264f9fc to
7c27819
Compare
c0fdcb3 to
28b7eec
Compare
7c27819 to
d80b305
Compare
28b7eec to
33b8af5
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new debugAssertIsNotUndefined assertion utility and uses it in cli.ts to verify that NAPI-RS never passes undefined for Option-typed Rust values. Since NAPI-RS maps Option::None to null (not undefined), the previous ?? null null-coalescing operators in the callback wrappers were redundant — they are now removed, with the debug assertions serving as a safety net to catch any regression.
Changes:
- Added
debugAssertIsNotUndefined<T>toapps/oxlint/src-js/utils/asserts.ts— a new debug-only assertion that throws if its argument isundefined - Added assertions in
loadPluginWrapperandlintFileWrapperincli.tsto assert that NAPI-RS never passesundefinedforpluginName,buffer, andworkspaceUri - Removed the now-redundant
?? nullnull-coalescing operators from the two call sites in each wrapper function
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
apps/oxlint/src-js/utils/asserts.ts |
Adds new debugAssertIsNotUndefined<T> utility, patterned after existing debugAssertIsNonNull<T> |
apps/oxlint/src-js/cli.ts |
Uses the new assertion in loadPluginWrapper and lintFileWrapper; drops redundant ?? null coalescers |
33b8af5 to
5f8e97f
Compare
d80b305 to
f3aa4cd
Compare
5f8e97f to
35432f7
Compare
f3aa4cd to
2951baf
Compare
This was referenced Mar 6, 2026
camc314
approved these changes
Mar 6, 2026
Contributor
Merge activity
|
35432f7 to
dbd1cb6
Compare
2951baf to
9a6c4b9
Compare
…e not `undefined` (#20070) Follow-on after #19675. The type for `lint` function that NAPI-RS produces is incorrect. `Option::None` on Rust side is translated to `null`, never `undefined`. Check this with a debug assertion, instead of handling `undefined` at runtime (which is pointless, because it never is `undefined`).
dbd1cb6 to
391ab14
Compare
9a6c4b9 to
cfaa754
Compare
Base automatically changed from
om/03-06-refactor_linter_plugins_clarify_types
to
main
March 6, 2026 17:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-on after #19675.
The type for
lintfunction that NAPI-RS produces is incorrect.Option::Noneon Rust side is translated tonull, neverundefined. Check this with a debug assertion, instead of handlingundefinedat runtime (which is pointless, because it never isundefined).