Skip to content

Commit d1fb0fb

Browse files
authored
Merge pull request #85 from pre-commit/biome
2 parents 78d0d1e + 17c2f79 commit d1fb0fb

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

sync_pre_commit_deps.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66

77
import ruamel.yaml
88

9-
SUPPORTED = frozenset({
10-
'black', 'flake8', 'mypy', 'eslint', 'csslint', 'fixmyjs', 'jshint',
11-
'prettier',
12-
})
9+
SUPPORTED = {
10+
'black': 'black',
11+
'flake8': 'flake8',
12+
'mypy': 'mypy',
13+
'eslint': 'eslint',
14+
'csslint': 'csslint',
15+
'fixmyjs': 'fixmyjs',
16+
'jshint': 'jshint',
17+
'prettier': 'prettier',
18+
'biome-check': '@biomejs/biome',
19+
}
1320

1421
_SEPS = ('==', '@')
1522
_RE_SEP = re.compile(rf'^(.+)({"|".join(_SEPS)})(.+)$')
@@ -61,12 +68,12 @@ def main(argv: Sequence[str] | None = None) -> int:
6168
for repo in loaded['repos']:
6269
if repo['repo'] not in ('local', 'meta'):
6370
for hook in repo['hooks']:
64-
if (hid := hook['id']) in SUPPORTED:
71+
if (dep := SUPPORTED.get(hook['id'])) is not None:
6572
# `mirrors-mypy` and various node revs have a 'v' prefix,
6673
# so we have to strip that out to get the
6774
# additional_dependency version.
6875
cleaned_rev = repo['rev'].removeprefix('v')
69-
versions[hid] = cleaned_rev
76+
versions[dep] = cleaned_rev
7077

7178
updated = []
7279
for repo in loaded['repos']:

tests/sync_pre_commit_deps_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ def test_main_writes_all(tmpdir):
130130
' - id: eslint\n'
131131
' additional_dependencies:\n'
132132
' - eslint@8.38.0\n'
133+
# gives the `@biomejs/biome` version and also has its
134+
# additional_dependencies rewritten
135+
'- repo: https://github.com/biomejs/pre-commit\n'
136+
' rev: v2.4.15\n'
137+
' hooks:\n'
138+
' - id: biome-check\n'
139+
' additional_dependencies:\n'
140+
' - "@biomejs/biome@1.8.1"\n'
133141
# all repos below should have their additional_dependencies rewritten
134142
'- repo: https://github.com/asottile/yesqa\n'
135143
' rev: v1.5.0\n'
@@ -185,6 +193,12 @@ def test_main_writes_all(tmpdir):
185193
' - id: eslint\n'
186194
' additional_dependencies:\n'
187195
' - eslint@8.39.0\n'
196+
'- repo: https://github.com/biomejs/pre-commit\n'
197+
' rev: v2.4.15\n'
198+
' hooks:\n'
199+
' - id: biome-check\n'
200+
' additional_dependencies:\n'
201+
' - "@biomejs/biome@2.4.15"\n'
188202
'- repo: https://github.com/asottile/yesqa\n'
189203
' rev: v1.5.0\n'
190204
' hooks:\n'

0 commit comments

Comments
 (0)