ImageLint


ImageLint is a VS Code extension that acts like a linter for image assets. It scans your workspace, flags unoptimized images inline, and provides one-click fixes.
Features
- Fast workspace scan for oversized and legacy-format images
- Inline diagnostics in code files that reference flagged images
- Quick fixes to compress, convert format, resize, or ignore images
- Audit report panel with estimated savings and batch Fix All
- Background watch mode with debounced re-scan behavior
- Configurable thresholds and diagnostics severity
| Format |
Behavior |
| PNG |
Scanned and optimizable |
| JPEG/JPG |
Scanned and optimizable |
| WebP |
Recognized as modern (no conversion suggestion) |
| AVIF |
Recognized as modern (no conversion suggestion) |
| GIF |
Skipped for conversion to preserve animation |
| SVG |
Skipped by raster optimization pipeline |
Commands
- ImageLint: Scan Workspace (
imagelint.scanWorkspace)
- ImageLint: Optimize Active Image (
imagelint.optimizeFile)
- ImageLint: Optimize All Flagged Images (
imagelint.optimizeAll)
- ImageLint: Show Audit Report (
imagelint.showReport)
- ImageLint: Clear Diagnostics (
imagelint.clearDiagnostics)
- ImageLint: Toggle Enabled (
imagelint.toggleEnabled)
Settings
All settings are namespaced under imagelint.*:
imagelint.enabled
imagelint.sizeThreshold
imagelint.autoConvertToWebP
imagelint.preferAVIF
imagelint.scanOnSave
imagelint.excludePatterns
imagelint.showStatusBar
imagelint.compressionQuality
imagelint.diagnostics.enabled
imagelint.diagnostics.severity
imagelint.diagnostics.fileTypes
Local Setup and Run
Prerequisites:
- Node.js 20+
- npm 10+
- VS Code 1.75+
Install and build:
npm ci
npm run build
Run extension in development:
- Open this repository in VS Code.
- Press
F5 to launch the Extension Development Host.
- Open the command palette and run
ImageLint: Scan Workspace.
Useful development commands:
npm run watch
npm run lint
npm run compile-tests
npm run smoke-test
npm test
CI and Automation
- Node CI workflow runs lint, build, compile-tests, and smoke-test on pushes and pull requests to main.
- CodeQL workflow scans JavaScript/TypeScript for security and quality issues.
- Dependency review workflow blocks pull requests that introduce high-severity vulnerable dependencies.
- Dependabot groups GitHub Actions and npm dependency updates to reduce PR noise.
Troubleshooting
Sharp install issues on local machine
Run a clean install:
rm -rf node_modules package-lock.json
npm install
If required, install all prebuilt sharp targets:
npm run install:sharp-all
gifsicle not found
ImageLint uses gifsicle from PATH for GIF optimization scenarios. Install it with your OS package manager and retry.
Diagnostics are not appearing
- Ensure
imagelint.enabled is true.
- Ensure
imagelint.diagnostics.enabled is true.
- Confirm the active file extension exists in
imagelint.diagnostics.fileTypes.
Documentation and Governance
License
This project is licensed under the MIT License. See LICENSE.