-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
133 lines (123 loc) · 4.72 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
repos:
- repo: https://github.com/zakstucke/zetch
rev: v0.0.16
hooks:
- id: zetch
# Formats, lints, organises imports, handles tailwindcss classes in ts|tsx|js|jsx|cjs|json|jsonc etc.
# Formatting same as vscode extension: https://marketplace.visualstudio.com/items?itemName=biomejs.biome
# Configure from ./biome.json
- repo: https://github.com/biomejs/pre-commit
rev: "v0.1.0" # For now biome doesn't update this, biome version specified in additional_dependencies
hooks:
- id: biome-check
# Note when updating version, update the biome version in initial_setup.sh too for the local version
additional_dependencies: ["@biomejs/[email protected]"]
# Toml formatting,
# same as vscode extension: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml
# Configure from ./taplo.toml
# NOTE: temporary source whilst taplo sort out their internal packaging, should switch to proper in the end, see:
# https://github.com/tamasfe/taplo/pull/549
# https://github.com/tamasfe/taplo/issues/535
- repo: https://github.com/redeboer/taplo-pre-commit
rev: v0.9.1rc1
hooks:
- id: taplo
args: ["format", "--config", "./taplo.toml"]
# Yaml formatting,
# same as vscode extension: https://marketplace.visualstudio.com/items?itemName=bluebrown.yamlfmt
# Configure from ./.yamlfmt
- repo: https://github.com/google/yamlfmt
# Note: if updating version, make sure to update your installed version,
# plus the installer in initial_setup.sh, which is needed for vscode extension.
rev: v0.10.0
hooks:
- id: yamlfmt
# Spelling mistakes:
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
# The codespell native exclude doesn't work,
# have to do it from pre-commit instead (https://github.com/codespell-project/codespell/issues/1498)
exclude: "(?x)^(\n .*\\.lock|\n .*\\.pyc|\n .*lock\\.json|\n .*rustfmt\\.toml|\n)$
\ \n"
args:
# Ignore don't error on specific words that always fail: (foo,bar,baz...)
- -L=crate
- -L=numer
- -L=anull
# Ruff: linting and formatting for python code:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
# Run the formatter.
- id: ruff-format
types_or: [python, pyi, jupyter]
args: [--config=./py/ruff.toml]
# Run the linter.
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix, --config=./py/ruff.toml]
# Bandit: finds security vulnerabilities in python code:
- repo: https://github.com/PyCQA/bandit
rev: '1.7.5'
hooks:
- id: bandit
args: ["-c", "./py/bandit.yml", "./py"]
# Cargo/clippy: linting and formatting for rust code:
- repo: local
hooks:
- id: cargo-fmt
name: cargo-fmt
description: "Format files with cargo fmt."
language: system
types: [rust]
entry: cargo fmt
args: [--manifest-path=./rust/Cargo.toml, --]
- id: cargo-rust-check
name: cargo-rust-check
description: Check the rust package for errors using cargo check on needed targets and features.
entry: ./dev_scripts/test.sh cargo_rust_check
language: system
types: [rust]
pass_filenames: false
- id: cargo-clippy
name: cargo-clippy
description: Lint rust sources
entry: cargo clippy
language: system
args: ["--manifest-path", "./rust/Cargo.toml", "--all-features", "--", "-D", "warnings"]
types: [rust]
pass_filenames: false
# Cargo/clippy: linting and formatting for rust-backed python code:
- repo: local
hooks:
- id: cargo-fmt
name: cargo-fmt
description: "Format files with cargo fmt."
entry: cargo fmt
language: system
types: [rust]
args: [--manifest-path=./py_rust/Cargo.toml, --]
- id: cargo-py-rust-check
name: cargo-py-rust-check
description: Check the rust-backed python package for errors using cargo check on needed targets
and features.
entry: ./dev_scripts/test.sh cargo_py_rust_check
language: system
types: [rust]
pass_filenames: false
- id: cargo-clippy
name: cargo-clippy
description: Lint rust sources
entry: cargo clippy
language: system
args: ["--manifest-path", "./py_rust/Cargo.toml", "--all-features", "--", "-D", "warnings"]
types: [rust]
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: trailing-whitespace