-
Notifications
You must be signed in to change notification settings - Fork 7
fix: remove unexpected space in output format string #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rslint canceled.
|
There was a problem hiding this 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 fixes a formatting issue in the autofix functionality of the no-unnecessary-type-assertion rule where extra spaces were being left in the output after removing unnecessary type assertions. The fix ensures that when removing type assertions like foo() as number
, the result is properly formatted as foo();
instead of foo() ;
.
Key changes:
- Improved whitespace handling in the autofix logic to include preceding spaces when removing 'as' keyword
- Simplified the fix generation to use a single removal range instead of multiple separate fixes
- Updated test expectations to reflect the corrected output format
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
no_unnecessary_type_assertion.go | Enhanced autofix logic to properly handle whitespace removal before 'as' keyword and simplified fix generation |
no_unnecessary_type_assertion_test.go | Updated test case expectation to reflect the corrected output format without extra spaces |
...rnal/plugins/typescript/rules/no_unnecessary_type_assertion/no_unnecessary_type_assertion.go
Outdated
Show resolved
Hide resolved
Improves the autofix for no-unnecessary-type-assertion rule to properly remove whitespace before 'as' keyword, preventing extra spaces in output. Before: foo() as number -> foo() ; After: foo() as number -> foo(); refactor: remove redundant comments from no_unnecessary_type_assertion Remove duplicate explanatory comments that were repeating the obvious functionality of the code below them.
e0e5af3
to
9a5f9f4
Compare
Add bounds check before accessing sourceText[startPos-2] to prevent potential panic when startPos-2 < 0.
Updated: I tested the original issue (#280) locally with the fixed build bin and it was verified to be resolved: Before![]() After![]() |
Summary
Improves the autofix for
no-unnecessary-type-assertion
rule to properly remove whitespace before 'as' keyword, preventing extra spaces in output.Close: #280
foo() as number -> foo() ;
foo() as number -> foo();
Edge Case
This Pull Request does not solve an edge case: