Skip to content

Commit

Permalink
Run prettier on JavaScript via pre-commit
Browse files Browse the repository at this point in the history
This patch removes the global `djangoproject/static/*` exclude rule in
`.pre-commit-config.yaml` to enable `prettier` to run on this project's
JavaScript files. The `djangoproject/static/js/lib/` directory is now
excluded in the `prettier` hook because there is no value in
reformatting a minified JavaScript file.

I also added a `.prettierrc` file to the root of the project to control
JavaScript formatting.
  • Loading branch information
adamzap committed Dec 20, 2024
1 parent a4bb1d7 commit 091ca2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: '(^djangoproject\/static\/.*$)'
exclude: '^djangoproject\/static\/(css\/|fonts\/|img\/|robots).*$'
default_language_version:
python: python3
repos:
Expand All @@ -19,6 +19,7 @@ repos:
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
exclude: '(^djangoproject\/static\/js\/lib\/.*$)'
exclude_types: [json, sql]
- id: file-contents-sorter
files: ^(requirements/\w*.txt)$
Expand Down Expand Up @@ -46,6 +47,7 @@ repos:
hooks:
- id: prettier
exclude_types: [html, json, scss]
exclude: '(^djangoproject\/static\/js\/lib\/.*$)'
- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
Expand Down
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"overrides": [
{
"files": "*.js",
"options": {
"tabWidth": 2,
"singleQuote": true
}
}
]
}

0 comments on commit 091ca2c

Please sign in to comment.