Registry / devops / imagemin-lint-staged

imagemin-lint-staged

JSON →
library0.5.1jsnpmunverified

A CLI wrapper around imagemin designed specifically for use with lint-staged (git pre-commit hooks). Version 0.5.1 is the latest stable release. It compresses PNG, JPEG, GIF, and SVG images automatically during staged file checks, with sensible default plugins (mozjpeg, optipng, svgo, gifsicle). Unlike using imagemin directly, it integrates seamlessly into lint-staged configurations without any configuration overhead. The package is lightweight (no peer dependencies) and runs synchronously to fit lint-staged's workflow.

npm install imagemin-lint-staged
INSTALL
IMPORT
SIG · IMAGEMIN-LINT-STAG
I
imagemin-lint-staged
devopsjavascriptv0.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import imageminLintStaged from 'imagemin-lint-staged'
const imageminLintStaged = require('imagemin-lint-staged')
Package exports a default function. ESM is not natively supported; use dynamic import if needed.

Shows how to integrate imagemin-lint-staged with lint-staged to automatically compress images on commit.

// package.json snippet for lint-staged { "lint-staged": { "*.{png,jpeg,jpg,gif,svg}": ["imagemin-lint-staged"] } } // Additionally, ensure imagemin-lint-staged is installed npm install --save-dev imagemin-lint-staged lint-staged husky
imagemin-lint-staged --version
Debug
Known issues
gotchaimagemin-lint-staged will fail if any image file cannot be processed (e.g., corrupted file) and blocks the commit.
fix
Ensure image files are valid before committing, or add a fallback to skip compression on error.
affects: >=0.0.0
gotchaThe CLI does not accept custom imagemin options; it uses hardcoded default plugins (mozjpeg, optipng, svgo, gifsicle).
fix
If custom options are needed, use imagemin directly instead of this package.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'imagemin-lint-staged'
imagemin-lint-staged is not installed or not in the same directory as the lint-staged config.
fix
Run 'npm install --save-dev imagemin-lint-staged' from the project root.
imagemin-lint-staged: command not found
imagemin-lint-staged is not in PATH; lint-staged runs scripts from node_modules/.bin, but if configured incorrectly, it may not find the binary.
fix
Ensure lint-staged is configured to run 'imagemin-lint-staged' as a string (not a function). The binary is provided via the package's bin field.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
imagemin-lint-staged — npm install imagemin-lint-staged · libregistry