Tailwind Warning Auto-FixAutomatically fix every Tailwind CSS optimization warning in the active file with a single command — no more clicking Quick Fix one class at a time.
The ProblemThe Tailwind CSS IntelliSense extension frequently flags optimization opportunities like:
Fixing these one at a time via the lightbulb Quick Fix menu is tedious in any file with more than a handful of warnings. The SolutionTailwind Warning Auto-Fix reads every optimization warning already produced by Tailwind CSS IntelliSense in the active file and applies all suggested fixes at once, atomically, with full undo support. It does not reimplement Tailwind's optimization logic — it's a thin, safe automation layer over diagnostics that already exist. Features
Optimization vs. Conflicts — why they're handled differently within the same commandTailwind CSS IntelliSense produces two distinct kinds of warnings, and even though one command now handles both, they're resolved very differently internally:
Both categories are still combined into a single atomic edit at the end, so you only ever hit Undo once no matter how many of each type were involved. Requirements
InstallationFrom the Marketplace
From a
|
| Situation | Message |
|---|---|
| No file open | Open a file first. |
| No warnings in the file | No Tailwind warnings found. |
| Optimization warnings found | Found 18 Tailwind optimization warnings. Apply all fixes? |
| A class conflict found | Quick Pick: Keep 'text-left', remove 'text-center' / Keep 'text-center', remove 'text-left' / Skip |
| Everything applied | 18 optimizations fixed, 2 conflicts resolved. |
| Some warnings unparsable | 18 optimizations fixed, 2 conflicts resolved. 3 warnings skipped. |
Commands
| Command | Shortcut | Description |
|---|---|---|
Tailwind: Fix All Warnings |
Ctrl+Alt+G / Cmd+Alt+G |
Scans the active file for both optimization warnings and class conflicts. Applies optimizations automatically (after one confirmation) and walks through conflicts one at a time via Quick Pick — all combined into a single, atomic edit. Also available via the ✨ Fix Tailwind Warnings status bar button. |
Settings
| Setting | Type | Default | Description |
|---|---|---|---|
tailwindAutoOptimizer.confirmBeforeApply |
boolean | true |
Show a confirmation dialog before applying all fixes |
tailwindAutoOptimizer.showSummary |
boolean | true |
Show a summary notification after fixes are applied |
tailwindAutoOptimizer.autoFixOnSave |
boolean | false |
Reserved for a future release — currently has no effect |
How It Works
This extension never re-implements Tailwind's class-optimization logic, parses JSX, or builds an AST. Instead, for each diagnostic in the active file, it:
- Reads existing diagnostics via
vscode.languages.getDiagnostics()— no document scanning. - Filters to those matching Tailwind CSS IntelliSense's optimization-warning format.
- Extracts the original and suggested class names from the diagnostic message text.
- Replaces text using the diagnostic's own
range— never a text search — so the correct occurrence is always targeted, even with duplicate class names elsewhere in the file. - Batches every replacement into one
WorkspaceEditand applies it atomically.
Known Limitations
- Only processes the currently active file — workspace-wide or folder-wide fixing is on the roadmap (see below).
- Relies entirely on Tailwind CSS IntelliSense's diagnostics; if that extension is disabled or hasn't finished analyzing the file yet, no warnings will be found.
- If Tailwind CSS IntelliSense changes its warning message wording in a future release, parsing may need an update (tracked in a single, isolated file — see Contributing).
- Diagnostics with overlapping source ranges (should not normally occur) are conservatively excluded rather than risking a corrupted edit.
Roadmap
Planned for future versions:
- [ ] Auto Fix on Save
- [ ] Workspace-wide "Fix All" command
- [ ] Folder-level fixing
- [ ] Multi-root workspace support
- [ ]
CodeActionProviderintegration (fix warnings via the lightbulb menu directly) - [ ] Fix All Quick Fix action
- [ ] Status bar button
- [ ] Progress notification for large files
- [ ] Marketplace icon and branding polish
- [ ] Optional telemetry
- [ ] Localization
- [ ] Unit and integration test suite
- [ ] CI/CD via GitHub Actions
- [ ] Semantic release automation
Development
Setup
git clone https://github.com/your-publisher-name/tailwind-warning-auto-fix.git
cd tailwind-warning-auto-fix
npm install
Build
npm run compile # one-time build
npm run watch # incremental rebuild on file changes
Debug
- Open the project in VS Code.
- Press
F5to launch the Extension Development Host. - Open a file with Tailwind classes in the new window and run the command.
Lint
npm run lint
Package
npm run package
Produces a .vsix file in the project root.
Publishing
npx vsce login <publisher-name>
npx vsce publish
See VS Code's official publishing guide for full details on creating a publisher and Personal Access Token.
Contributing
Contributions are welcome. Please:
- Open an issue describing the bug or feature before submitting a large PR.
- Keep changes scoped — this project favors small, focused modules (see architecture below).
- Run
npm run lintandnpm run compilebefore submitting. - Match the existing code style (strict TypeScript, no
any, no unused code).
Architecture Overview
src/
├── commands/ # Orchestrates user-triggered flows
├── services/ # Diagnostics reading, replacement building, config access
├── parsers/ # Pure, dependency-free message parsing
├── utils/ # Logging and notification helpers
├── types/ # Shared interfaces
├── constants/ # Messages, regex patterns, command IDs
└── extension.ts # Composition root (activate/deactivate)
License
MIT — see LICENSE.
