Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same ruff command on CI and in pre-commit #617

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ repos:
name: "don't commit to master"
args: [--branch, master]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.7
hooks:
# Run the linter.
- id: ruff
args: [ --select, I, --fix, --exit-non-zero-on-fix ]
# Run the formatter.
- id: ruff-format

- repo: local
hooks:
- id: app-prettier
Expand All @@ -29,3 +20,19 @@ repos:
types_or: [javascript, json]
entry: |
bash -c 'npm --prefix . run fix:prettier --write "${@}"' --

- id: app-ruff-check
name: run ruff check
language: system
files: ^.*$
types_or: [python]
entry: |
bash -c 'npm --prefix . run fix:ruff:check "${@}"' --

- id: app-ruff-format
name: run ruff format
language: system
files: ^.*$
types_or: [python]
entry: |
bash -c 'npm --prefix . run fix:ruff:format "${@}"' --
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
"db:build": "./bin/build-db",
"lint:prettier": "prettier --config .prettierrc --check",
"lint:prettier:all": "npm run lint:prettier -- .",
"lint:ruff:all": "pipenv run ruff check --extend-select I && pipenv run ruff format --check",
"lint:ruff:all": "npm run lint:ruff:check && npm run lint:ruff:format",
"lint:ruff:check": "pipenv run ruff check --force-exclude --extend-select I",
"lint:ruff:format": "npm run fix:ruff:format -- --check",
"lint:all": "npm run lint:prettier:all && npm run lint:ruff:all",
"fix:prettier": "npm run lint:prettier -- --write",
"fix:prettier:all": "npm run lint:prettier -- --write .",
"fix:ruff:all": "pipenv run ruff check --extend-select I --fix && pipenv run ruff format",
"fix:ruff:all": "npm run fix:ruff:check && npm run fix:ruff:format",
"fix:ruff:check": "npm run lint:ruff:check -- --fix",
"fix:ruff:format": "pipenv run ruff format --force-exclude",
"fix:all": "npm run fix:ruff:all && npm run fix:prettier:all",
"format:json": "npx prettier@3.0.3 --write . && pipenv run ruff check --select I --fix && pipenv run ruff format",
"prepare": "husky",
Expand Down