feat(lsp,cli): support auto-fix on save and multi-pass fix#559
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the rslint developer experience by integrating a robust auto-fix on save feature within the Language Server Protocol (LSP). It allows for seamless, multi-pass correction of linting issues directly within the editor, ensuring code quality is maintained with minimal manual intervention. The changes extend to the CLI as well, providing a consistent fixing mechanism across different environments. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and valuable feature: auto-fixing on save (source.fixAll.rslint), aligning rslint's LSP capabilities with standard tools like ESLint. The implementation is robust, featuring multi-pass fixing to handle cascading issues, both in the CLI (--fix) and the language server. The cycle detection is a thoughtful addition to prevent infinite loops. The refactoring in internal/lsp/service.go to centralize diagnostic and fix conversions into helper functions like ruleFixToTextEdit and convertRuleDiagnosticToLSP greatly improves code clarity and maintainability. The addition of comprehensive unit and e2e tests is commendable. I've found one high-severity issue in the new computeEndPosition helper function that could lead to file corruption with non-ASCII characters, and I've suggested a fix along with an additional test case.
Deploying rslint with
|
| Latest commit: |
be4559a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3e117561.rslint.pages.dev |
| Branch Preview URL: | https://feat-fixall-on-save-20260321.rslint.pages.dev |
56763d5 to
c58c476
Compare
be4559a to
5d38a36
Compare
Add fixAll code action support so users can auto-fix lint issues on save by configuring `editor.codeActionsOnSave`. Both CLI `--fix` and LSP fixAll support multi-pass fixing (up to 10 passes) to handle cascading issues (e.g. ban-types fix triggers no-inferrable-types). LSP: - Declare source.fixAll / source.fixAll.rslint code action kinds - Add handleFixAllCodeAction with multi-pass loop: lint → apply fixes via ApplyRuleFixes → update session overlay → repeat until stable, with cycle detection - Clear pendingLintURIs in handleDidSave and handleFixAllCodeAction to prevent redundant debounce lints - Use core.UTF16Len for correct UTF-16 position encoding - Extract ruleFixToTextEdit / reuse convertRuleDiagnosticToLSP to reduce duplication across quickfix/suggestion/fixAll paths CLI: - Add multi-pass --fix: after applying fixes, rebuild Program from disk and re-lint to catch cascading issues - Extract applyFixPass helper and createPrograms closure Tests: - Go unit tests (70+) covering isFixAllRequest, mergeFixGroups, handleFixAllCodeAction, computeEndPosition, ApplyRuleFixes edge cases, handleDidSave, routing - E2e tests (18) covering fixAll code actions, on-save integration with real document.save() for both source.fixAll.rslint and generic source.fixAll, cascade fixes, error flows, edge cases Docs: - Update website guide and extension README with codeActionsOnSave config
5d38a36 to
aadbc69
Compare
Summary
Add fixAll code action support so users can auto-fix lint issues on save, matching the standard ESLint workflow. Both CLI
--fixand LSP fixAll support multi-pass fixing (up to 10 passes) to handle cascading issues.User configuration:
{ "editor.codeActionsOnSave": { "source.fixAll.rslint": "explicit" } }Key features:
ban-typesfix (String→string) triggersno-inferrable-types(removes now-inferrable: string), all resolved in a single save / single--fixrun--fixexit code reflects post-fix state: exit 0 when all errors are fixed, exit 1 only when non-fixable errors remain (aligned with ESLint)--fixoutput only shows remaining unfixed diagnostics, not already-fixed ones (aligned with ESLint/oxlint collect-then-print model)linter.ApplyRuleFixesengine for fix applicationhandleDidSaveclearspendingLintURIsto prevent redundant debounce lintscomputeEndPositionusescore.UTF16Lenfor correct UTF-16 position encodingTests:
document.save()for bothsource.fixAll.rslintand genericsource.fixAll, cascade fixes, error flowsRelated Links
editor.codeActionsOnSave+source.fixAll.eslintmechanismChecklist