Skip to content

Replace prettier hook with separate formatters for YAML and JSON #53

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

Merged
merged 5 commits into from
Aug 5, 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
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
- package-ecosystem: pip
directory: /
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: "weekly"
interval: weekly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still work fine? Slightly annoying it's changing Dependabot's defaults / recommended format.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! It's equivalent.

I'd probs rather have the double quotes too, but I can't be bothered to fight the formatter over it. Couldn't see an option for changing the quote type 😞

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should strive for a state of zen that allows us to accept whatever the formatter says is best.

6 changes: 3 additions & 3 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check links in Markdown files
on:
schedule:
- cron: "0 0 * * 1" # midnight every Monday
- cron: 0 0 * * 1 # midnight every Monday
push:
branches: [main]
pull_request:
Expand All @@ -14,5 +14,5 @@ jobs:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: "yes"
use-verbose-mode: "yes"
use-quiet-mode: yes
use-verbose-mode: yes
2 changes: 1 addition & 1 deletion .github/workflows/ci-pip-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.12"]
python-version: ['3.12']

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.12"]
python-version: ['3.12']

steps:
- uses: actions/checkout@v4
Expand Down
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ repos:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: pretty-format-json
args: [--autofix, --indent, '4', --no-sort]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', --offset, '2']
exclude: '{{ cookiecutter.project_slug }}/.+'
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.29.1"
rev: 0.29.1
hooks:
- id: check-github-workflows
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
# Prettier supports many other file formats (e.g., JavaScript, HTML; see
# https://prettier.io for list). Add other types here.
types_or: [yaml, json]
exclude: "{{ cookiecutter.project_slug }}/.+"
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: markdownlint-fix
exclude: "{{ cookiecutter.project_slug }}"
exclude: '{{ cookiecutter.project_slug }}'
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
5 changes: 4 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"project_description": "[Description for project.]",
"author": "Jane Doe",
"author_email": "jane_doe@imperial.ac.uk",
"packaging": ["poetry", "pip-tools"],
"packaging": [
"poetry",
"pip-tools"
],
"use_bsd3_licence": false,
"add_precommit_workflows": true,
"automerge_bot_prs": false,
Expand Down
12 changes: 6 additions & 6 deletions {{ cookiecutter.project_slug }}/.github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
- package-ecosystem: pip
directory: /
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: "weekly"
interval: weekly
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check links in Markdown files
on:
schedule:
- cron: "0 0 * * 1" # midnight every Monday
- cron: 0 0 * * 1 # midnight every Monday
push:
branches: [main]
pull_request:
Expand All @@ -14,5 +14,5 @@ jobs:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: "yes"
use-verbose-mode: "yes"
use-quiet-mode: yes
use-verbose-mode: yes
2 changes: 1 addition & 1 deletion {{ cookiecutter.project_slug }}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
{%- endif %}
{%- if cookiecutter.use_macos_ci_runner %}
- macos-latest{% endif %}
python-version: ["3.12"]
python-version: ['3.12']

steps:
- uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Pre-commit auto-update

on:
schedule:
- cron: "0 0 * * 1" # midnight every Monday
- cron: 0 0 * * 1 # midnight every Monday

jobs:
auto-update:
Expand All @@ -16,5 +16,5 @@ jobs:
token: ${{ "{{" }} secrets.GITHUB_TOKEN {{ "}}" }}
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "chore: update pre-commit hooks"
commit-message: 'chore: update pre-commit hooks'
body: Update versions of pre-commit hooks to latest version.
1 change: 0 additions & 1 deletion {{ cookiecutter.project_slug }}/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
---
# Disable checks here
MD013: false
20 changes: 10 additions & 10 deletions {{ cookiecutter.project_slug }}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ repos:
- id: debug-statements
- id: trailing-whitespace
- id: end-of-file-fixer
- id: pretty-format-json
args: [--autofix, --indent, '4', --no-sort]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', --offset, '2']
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.28.3"
rev: 0.28.3
hooks:
- id: check-github-workflows
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
# Prettier supports many other file formats (e.g., JavaScript, HTML; see
# https://prettier.io for list). Add other types here.
types_or: [yaml, json]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.4"
rev: v0.4.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.10.0"
rev: v1.10.0
hooks:
- id: mypy
- repo: https://github.com/igorshubovych/markdownlint-cli
Expand Down
1 change: 0 additions & 1 deletion {{ cookiecutter.project_slug }}/.vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"ms-python.mypy-type-checker",
"ms-python.python",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"davidanson.vscode-markdownlint",
"charliermarsh.ruff"
]
Expand Down
5 changes: 3 additions & 2 deletions {{ cookiecutter.project_slug }}/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
},
"editor.rulers": [88],

"editor.rulers": [
88
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}