A collection of pre-commit hooks used across ParisNeo projects.
For JavaScript hooks:
npm install -g eslint prettier
For Python hooks:
pip install pre-commit
## Installation
1. Install pre-commit:
```bash
pip install pre-commit
- Add to your
.pre-commit-config.yaml
:
repos:
- repo: https://github.com/ParisNeo/parisneo-precommit-hooks
rev: v0.1.0
hooks:
- id: parisneo-python-check # For Python projects
- id: parisneo-js-check # For JavaScript projects
- Install the pre-commit hooks:
pre-commit install
- Runs black for code formatting
- Runs isort for import sorting
- Runs flake8 for style checking
- Runs prettier for code formatting
- Runs eslint for style checking
Create a setup.cfg
in your project root:
[flake8]
max-line-length = 100
extend-ignore = E203
exclude = .git,__pycache__,build,dist
[isort]
profile = black
multi_line_output = 3
line_length = 100
- Create GitHub workflow file
.github/workflows/test.yml
:
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest
npm install -g eslint prettier
- name: Run tests
run: pytest
- name: Run hooks
run: |
pip install pre-commit
pre-commit run --all-files
To use in your projects:
- Add to your project's
.pre-commit-config.yaml
:
repos:
- repo: https://github.com/ParisNeo/parisneo-precommit-hooks
rev: v0.1.0 # Use the latest version
hooks:
- id: parisneo-python-check
- id: parisneo-js-check
- Initialize:
pre-commit install
- Add to your project's
.pre-commit-config.yaml
:
repos:
- repo: https://github.com/ParisNeo/parisneo-precommit-hooks
rev: v0.1.0 # Use the latest version
hooks:
- id: parisneo-python-check
- id: parisneo-js-check
- make sure pre-commit is installed
pre-commit run --all-files
pre-commit run parisneo-python-check
pre-commit run parisneo-js-check
pre-commit run --files path/to/file.py