feat: add 'Fix All Auto-fixable Problems' command#1572
Conversation
Adds a new command 'tailwindCSS.fixAll' that automatically fixes all auto-fixable Tailwind CSS diagnostics in the active document. This feature is inspired by the ESLint extension's 'Fix all auto-fixable Problems' command. Changes: - Added 'tailwindCSS.fixAll' command to package.json - Implemented client-side command handler in extension.ts - Added server-side request handler in tw.ts - Implemented fixAllProblems method in projects.ts that: - Collects all diagnostics for the document - Gathers all available code actions with fixes - Applies all fixes in a single workspace edit - Handles overlapping ranges to avoid conflicts This allows users to fix all Tailwind CSS warnings/errors at once instead of fixing them individually.
- Add 'Fix All Auto-fixable Problems (Current File)' command with auto-save - Add 'Fix All Auto-fixable Problems (Workspace)' command for workspace-wide fixes - Implement file scanning based on Tailwind content config patterns - Add configurable batch processing with cancellable progress notifications - Return fix statistics (fixed count, remaining count) for both modes - Add getContentFiles server request to discover workspace files - Add comprehensive test suite (10 tests) covering v3 and v4 Tailwind - Add workspace/applyEdit handler to test infrastructure Configuration settings: - tailwindCSS.codeActions.autoSave (default: true) - tailwindCSS.codeActions.fixAll.batchSize (default: 10) Fixes tailwindlabs#1572
🚀 Enhanced ImplementationI've significantly enhanced this PR to address the original issues and add powerful new capabilities: ✅ What Was FixedOriginal Issues:
Now Fixed:
🎯 New Features1. Local File Fix (Enhanced)
2. Global Workspace Fix (New)
⚙️ Configuration{
"tailwindCSS.codeActions.autoSave": true,
"tailwindCSS.codeActions.fixAll.batchSize": 10
}🧪 TestingAdded comprehensive test suite following project conventions:
📦 Implementation DetailsFiles Modified:
Key Technical Features:
🔄 Build Status✅ TypeScript compilation: PASSED 💡 Usage ExamplesQuick fix current file:
Fix entire workspace:
This implementation is production-ready and follows all Tailwind CSS IntelliSense conventions! 🎉 |
🔍 Technical Implementation ReviewArchitectureClient → Server Communication: Key Methods
Design DecisionsWhy two modes (local/global)?
Why batch processing?
Why auto-save?
Why use Tailwind content patterns?
Testing StrategyTests cover:
Added Performance Considerations
Ready for review! 🚀 |
|
Its okay if you guys don't have time to review this, thanks for the open source work! Because it was open source, I was able to implement my own feature and install the extension locally to solve my problem! |
Summary
This PR adds a new command "Tailwind CSS: Fix All Auto-fixable Problems" that automatically fixes all auto-fixable Tailwind CSS diagnostics in the active document, similar to the ESLint extension's functionality.
Its okay if you guys don't have time to review this, thanks for the open source work! Because it was open source, I was able to implement my own feature and install the extension locally to solve my problem!
Motivation
Currently, Tailwind CSS IntelliSense provides auto-fixable code actions for individual diagnostics (CSS conflicts, invalid @apply directives, variant ordering, canonical class suggestions, etc.), but users need to trigger each fix individually through the Problems panel or quick fix menu. This can be tedious when there are multiple fixable issues in a file.
The ESLint extension already provides an excellent "Fix all auto-fixable Problems" command that applies all available fixes at once. This PR brings similar functionality to the Tailwind CSS extension.
Changes
1. Command Registration (
package.json)tailwindCSS.fixAllwith title "Tailwind CSS: Fix All Auto-fixable Problems"2. Client-Side Handler (
packages/vscode-tailwindcss/src/extension.ts)fixAllProblems()function that sends a request to the language server3. Server-Side Request Handler (
packages/tailwindcss-language-server/src/tw.ts)@/tailwindCSS/fixAllrequest handlerfixAllProblemsmethod4. Fix All Logic (
packages/tailwindcss-language-server/src/projects.ts)fixAllProblemsmethod that:doValidatedoCodeActionsImplementation Details
The implementation follows the same architecture as ESLint's fix-all feature:
The code handles edge cases like:
Usage
Users can invoke this command via:
Tailwind CSS: Fix All Auto-fixable ProblemsTesting
Related
This feature complements the existing individual quick fixes and makes bulk fixing more convenient, improving developer workflow.