lint-prepush

raw JSON →
3.0.3 verified Fri May 01 auth: no javascript

lint-prepush is a Node.js tool that runs linters on staged files before a git push, enforcing code quality within teams. Current stable version is 3.0.3 (released 2024-11-30), with a slow release cadence. It uses a simple package.json configuration to define tasks per file glob, supports concurrent task execution for speed, and integrates with any git hook manager (e.g., Husky). Unlike lint-staged which operates on pre-commit, lint-prepush operates on pre-push, catching issues after local commits. Requires Node.js >=18.18.0. Dependencies include cosmiconfig for config loading, execa for running commands, and log-symbols for visual feedback. No security issues reported.

error Error: Could not find a configuration file for lint-prepush.
cause No 'lint-prepush' key in package.json and no .lintprepushrc file.
fix
Add configuration: "lint-prepush": { "tasks": { "*.js": "eslint" } }
error Error: The base branch 'main' does not exist locally or has no commits. Please specify a valid base branch.
cause The 'base' option points to a branch that doesn't exist locally.
fix
Set 'base' to an existing branch (e.g., 'main' or 'master') or omit to auto-detect (v3+).
error command not found: eslint
cause Linter not installed or not in PATH.
fix
Install the linter locally (npm install --save-dev eslint) or ensure it's globally accessible.
breaking Node version <18.18.0 is not supported. Upgrade to Node >=18.18.0.
fix Update Node.js to >=18.18.0.
deprecated Drop support for Node.js <10 in v2.0.0 was a breaking change.
fix Use Node >=10 for v2.x. For current versions, use Node >=18.18.0.
gotcha If base branch is not specified and the remote branch doesn't exist locally, lint-prepush may fail or use incorrect diff.
fix Explicitly set the 'base' option in configuration to your default branch (e.g., 'main').
gotcha Multiple tasks on same glob must be wrapped in an object with 'concurrent' key, not array of arrays.
fix Use format: { "concurrent": ["eslint", "jest"] }
deprecated Old configuration format with array of commands without 'concurrent' key is still supported but deprecated.
fix Use the object format with 'concurrent' for multiple tasks.
npm install lint-prepush
yarn add lint-prepush
pnpm add lint-prepush

Install lint-prepush and Husky, create a pre-push hook, and configure lint tasks in package.json.

npm install --save-dev lint-prepush husky
npm install --save-dev eslint  # or your linter
npx husky init  # creates .husky directory
echo 'npx lint-prepush' > .husky/pre-push
chmod +x .husky/pre-push
# Add to package.json:
# "lint-prepush": {
#   "base": "main",
#   "tasks": {
#     "*.js": ["eslint"]
#   }
# }