Registry / devops / pre-commit-with-lint

pre-commit-with-lint

JSON →
library1.2.5jsnpmunverified

A fork of the pre-commit package (v1.2.5) that adds selective linting of only changed files in a commit. It integrates with stylelint and eslint by default, linting CSS/SCSS/Less and JS/JSX files respectively, with configurable patterns. Designed to speed up commits by avoiding full-project linting. Release cadence is low (last update 2017), and it's effectively unmaintained. Key differentiator vs original pre-commit: automatic linting of only staged changes. Alternative better-maintained packages exist.

npm install pre-commit-with-lint
INSTALL
IMPORT
SIG · PRE-COMMIT-WITH-LI
P
pre-commit-with-lint
devopsjavascriptv1.2.5
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.

pre-commit-with-lint
npm install pre-commit-with-lint --save-dev
npm install -g pre-commit-with-lint
No exports; install as devDependency and configure via package.json.
package.json configuration
{ "pre-commit": { "lint": { "stylelint": "\\.(s?css|less)$", "eslint": "\\.jsx?$" } } }
Using "precommit" key (deprecated) or "lint": true
Use 'pre-commit' key (not 'precommit'). Set lint to false to disable all linters. Version 1.2.5.
run configuration
{ "pre-commit": { "run": ["test", "lint"] } }
Using "pre-commit": ["test"] (works but not with lint config)
The 'run' key must be an array of npm script names. Without 'run', defaults to 'npm test'.

Shows full setup: install, configure package.json with selective lint and scripts, then commit. Verifies pre-commit hook runs lint and test before allowing commit.

mkdir test-repo && cd test-repo && npm init -y && npm install pre-commit-with-lint --save-dev && echo '{ "name": "test", "version": "1.0.0", "scripts": { "test": "echo \"tests pass\" && exit 0", "lint": "echo \"linting\" && exit 0" }, "pre-commit": { "lint": { "eslint": ".js$" }, "run": ["lint", "test"] } }' > package.json && git init && git add . && git commit -m "test commit"
pre-commit-with-lint --version
Debug
Known issues
deprecatedPackage is a fork of pre-commit from 2017; no updates since then. Use modern alternatives like husky + lint-staged.
fix
Switch to @commitlint/lint-staged or husky + lint-staged.
affects: >=1.0.0
gotchaIf a linter specified in package.json is not installed, the commit will be prevented with an error.
fix
Ensure listed linters (eslint, stylelint, tslint, etc.) are installed as devDependencies.
affects: >=1.0.0
gotchaThe default lint patterns are hardcoded and may not match all file types. Misconfigured patterns can cause no linting or broken commits.
fix
Set explicit patterns in package.json: { "pre-commit": { "lint": { "eslint": ".jsx?$" } } }
affects: >=1.0.0
breakingclone: The 'pre-commit' key must be an object for lint config; using an array (original pre-commit style) will be ignored without warning.
fix
Use object syntax with 'lint' and 'run' keys, not an array.
affects: >=1.0.0
gotchaIf default linters (stylelint, eslint) are not found in node_modules, a warning is printed but commit proceeds. Non-default linters cause an error.
fix
Install default linters or disable them via config: { "pre-commit": { "lint": { "eslint": "false" } } }
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'eslint'
eslint is not installed but default linting pattern requires it.
fix
Run: npm install eslint --save-dev; or disable eslint in package.json: "eslint": "false"
Something bad happened with the pre-commit hook. You can force the commit by using --no-verify.
Git hook script failed due to a configuration error or missing dependencies.
fix
Check package.json pre-commit configuration, ensure scripts are valid, and reinstall the package.
fatal: could not open '.git/HEAD': No such file or directory
Command run outside a git repository.
fix
Initialize a git repo: git init
Upgrade
Version history
1.2.5latest on npm
Audit
Dependencies
gitrequiredRequires git hooks; installs .git/hooks/pre-commit
npmrequiredRelies on npm scripts defined in package.json
Agent activity
2 hits · last 30 days
node
2
Resources
pre-commit-with-lint — npm install pre-commit-with-lint · libregistry