feat: Add BrighterScript plugin for context param diagnostics#73
Draft
feat: Add BrighterScript plugin for context param diagnostics#73
Conversation
Adds a BrighterScript plugin (shipped as `@rokucommunity/promises/plugin`) that emits diagnostic PRMS1001 when `onThen`, `onCatch`, `onFinally`, or the chain API is called with a context argument but the inline callback has no parameter to receive it. Includes ropm alias auto-detection, 26 unit tests (Mocha + Chai), ESLint config adapted from BrighterScript, and README documentation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Warns when a chain builder (result of .then/.catch/.finally, or chain() itself) is returned from a function without calling .toPromise() first. The chain builder is a plain AA, not a Promise node, so returning it without .toPromise() is almost always a bug. Includes 9 new tests and README documentation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- PRMS1001: "Add missing context parameter" inserts the correct text at the callback's parameter list (value, context / , context / context) - PRMS1002: "Add '.toPromise()'" inserts at the end of the chain expression - Both offer a "fix all in file (N)" action when 2+ fixable instances exist - 8 new code action tests (43 total) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- provideHover: show callback signature when hovering over .then/.catch/.finally in a promises.chain() call, with or without context - provideCompletions: suggest function(value, context) snippets when typing the callback argument of onThen/onCatch/onFinally/chain - PRMS1003 (Error): callback declares extra parameters that will never receive a value because no context was passed — crashes at runtime for non-optional params Quick fix deletes the extra param(s); fix-all covers the whole file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
@rokucommunity/promises/pluginthat catches common promise mistakes at compile timeroku_modules/— no config needed for most projects; supports explicit alias override and multiple aliasesDiagnostics
.toPromise()All three diagnostics include quick-fix code actions, with fix-all variants when multiple instances exist in the same file.
IDE Features
.then,.catch, or.finallyin apromises.chain()call shows the expected callback signature, including the context parameter if one was passed tochain()onThen,onCatch,onFinally, orchainsurfacesfunction(value, context)snippets with tab-stopsChanges
plugin/index.ts— plugin implementation: AST walker, alias detection, three diagnostics, quick-fix actions, hover and completion providersplugin/index.spec.ts— 60 unit tests (Mocha + Chai) covering all diagnostics, code actions, alias detection, and edge cases.eslintrc.js/.mocharc.cjs— ESLint config adapted from BrighterScript; Mocha config forplugin/**/*.spec.tstsconfig.plugin.json— compilesplugin/→dist/plugin/with declarationspackage.json— addsbuild-plugin,lint,test-pluginscripts; exports./pluginsubpath; includesdist/pluginin published filesREADME.md— new BrighterScript Plugin section with setup instructions, examples, and diagnostic code referenceTest plan
npm run lint— no errorsnpm run test-plugin— 60/60 passingnpm run build-plugin— compiles cleanly🤖 Generated with Claude Code