{"id":26095,"library":"pre-commit-with-lint","title":"pre-commit-with-lint","description":"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.","status":"deprecated","version":"1.2.5","language":"javascript","source_language":"en","source_url":"git://github.com/dyw934854565/pre-commit","tags":["javascript","git","hooks","npm","pre-commit","precommit","run","test","development"],"install":[{"cmd":"npm install pre-commit-with-lint","lang":"bash","label":"npm"},{"cmd":"yarn add pre-commit-with-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add pre-commit-with-lint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires git hooks; installs .git/hooks/pre-commit","package":"git","optional":false},{"reason":"Relies on npm scripts defined in package.json","package":"npm","optional":false}],"imports":[{"note":"No exports; install as devDependency and configure via package.json.","wrong":"npm install -g pre-commit-with-lint","symbol":"pre-commit-with-lint","correct":"npm install pre-commit-with-lint --save-dev"},{"note":"Use 'pre-commit' key (not 'precommit'). Set lint to false to disable all linters. Version 1.2.5.","wrong":"Using \"precommit\" key (deprecated) or \"lint\": true","symbol":"package.json configuration","correct":"{\n  \"pre-commit\": {\n    \"lint\": {\n      \"stylelint\": \"\\\\.(s?css|less)$\",\n      \"eslint\": \"\\\\.jsx?$\"\n    }\n  }\n}"},{"note":"The 'run' key must be an array of npm script names. Without 'run', defaults to 'npm test'.","wrong":"Using \"pre-commit\": [\"test\"] (works but not with lint config)","symbol":"run configuration","correct":"{\n  \"pre-commit\": {\n    \"run\": [\"test\", \"lint\"]\n  }\n}"}],"quickstart":{"code":"mkdir test-repo && cd test-repo && npm init -y && npm install pre-commit-with-lint --save-dev && echo '{\n  \"name\": \"test\",\n  \"version\": \"1.0.0\",\n  \"scripts\": {\n    \"test\": \"echo \\\"tests pass\\\" && exit 0\",\n    \"lint\": \"echo \\\"linting\\\" && exit 0\"\n  },\n  \"pre-commit\": {\n    \"lint\": {\n      \"eslint\": \".js$\"\n    },\n    \"run\": [\"lint\", \"test\"]\n  }\n}' > package.json && git init && git add . && git commit -m \"test commit\"","lang":"javascript","description":"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."},"warnings":[{"fix":"Switch to @commitlint/lint-staged or husky + lint-staged.","message":"Package is a fork of pre-commit from 2017; no updates since then. Use modern alternatives like husky + lint-staged.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure listed linters (eslint, stylelint, tslint, etc.) are installed as devDependencies.","message":"If a linter specified in package.json is not installed, the commit will be prevented with an error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set explicit patterns in package.json: { \"pre-commit\": { \"lint\": { \"eslint\": \".jsx?$\" } } }","message":"The default lint patterns are hardcoded and may not match all file types. Misconfigured patterns can cause no linting or broken commits.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use object syntax with 'lint' and 'run' keys, not an array.","message":"clone: The 'pre-commit' key must be an object for lint config; using an array (original pre-commit style) will be ignored without warning.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Install default linters or disable them via config: { \"pre-commit\": { \"lint\": { \"eslint\": \"false\" } } }","message":"If default linters (stylelint, eslint) are not found in node_modules, a warning is printed but commit proceeds. Non-default linters cause an error.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: npm install eslint --save-dev; or disable eslint in package.json: \"eslint\": \"false\"","cause":"eslint is not installed but default linting pattern requires it.","error":"Cannot find module 'eslint'"},{"fix":"Check package.json pre-commit configuration, ensure scripts are valid, and reinstall the package.","cause":"Git hook script failed due to a configuration error or missing dependencies.","error":"Something bad happened with the pre-commit hook. You can force the commit by using --no-verify."},{"fix":"Initialize a git repo: git init","cause":"Command run outside a git repository.","error":"fatal: could not open '.git/HEAD': No such file or directory"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}