Skip to content

theenadayalank/lint-prepush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

212 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

lint-prepush: Automate Code Quality Before Every Push πŸš€

lint-prepush ensures that linters are automatically run on committed files before you push to a remote, maintaining code quality and consistency within teams.

βš™οΈ Prerequisites

Make sure you have:

  • Node.js >=18.18.0 – Download Node.js
  • Git Hook Manager – Husky is recommended to integrate with your Git hooks

πŸš€ Installation

Using npm:

npm install --save-dev lint-prepush

Using yarn:

yarn add --dev lint-prepush

πŸ› οΈ Configuration

Once installed, configure lint-prepush in your package.json to lint specific file types before pushing.

Basic Example: Lint JavaScript Files with ESLint

"lint-prepush": {
  "base": "main",
  "tasks": {
    "*.js": [
      "eslint"
    ]
  }
}

This ensures that eslint runs on all .js files in your commit, blocking pushes if any errors are found.

⚑ Concurrent Task Execution

You can run multiple tasks simultaneously on the same file type for faster processing:

"lint-prepush": {
  "tasks": {
    "*.js": {
      "concurrent": ["eslint", "jest"]
    }
  }
}

πŸ“’ Verbose Logging

Want more details during the lint process? Enable verbose mode:

"lint-prepush": {
  "verbose": true,
  "tasks": { ... }
}

This will log every step in the process, even when there are no errors.

🎯 How It Works

  • Hooks into Git's Pre-Push: By using Husky, lint-prepush leverages Git hooks to automatically run specified tasks on your code before it leaves your local environment.
  • Ensures Code Quality: Stop bad code from being pushed by enforcing linting standards.
  • Faster Feedback: Concurrent task execution helps you catch problems quickly, reducing the time spent in code review.

🀝 Acknowledgments

This project draws inspiration from:

  • Husky for handling Git hooks
  • Lint-staged for ideas on managing tasks effectively

We appreciate the efforts of these projects!

πŸ”‘ Keywords

  • git pre-push hook
  • linting automation
  • code quality
  • eslint
  • concurrent tasks
  • git hooks
  • husky

πŸ“œ License

This project is licensed under the MIT License.

Sponsor this project

Packages

 
 
 

Contributors