From 17c2f795391a45af87512080b5541fa98da3f8af Mon Sep 17 00:00:00 2001 From: Max R Date: Sun, 17 May 2026 07:15:58 -0400 Subject: [PATCH] Rewrite biomejs --- sync_pre_commit_deps.py | 19 +++++++++++++------ tests/sync_pre_commit_deps_test.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sync_pre_commit_deps.py b/sync_pre_commit_deps.py index 569f17c..b9f1408 100644 --- a/sync_pre_commit_deps.py +++ b/sync_pre_commit_deps.py @@ -6,10 +6,17 @@ import ruamel.yaml -SUPPORTED = frozenset({ - 'black', 'flake8', 'mypy', 'eslint', 'csslint', 'fixmyjs', 'jshint', - 'prettier', -}) +SUPPORTED = { + 'black': 'black', + 'flake8': 'flake8', + 'mypy': 'mypy', + 'eslint': 'eslint', + 'csslint': 'csslint', + 'fixmyjs': 'fixmyjs', + 'jshint': 'jshint', + 'prettier': 'prettier', + 'biome-check': '@biomejs/biome', +} _SEPS = ('==', '@') _RE_SEP = re.compile(rf'^(.+)({"|".join(_SEPS)})(.+)$') @@ -61,12 +68,12 @@ def main(argv: Sequence[str] | None = None) -> int: for repo in loaded['repos']: if repo['repo'] not in ('local', 'meta'): for hook in repo['hooks']: - if (hid := hook['id']) in SUPPORTED: + if (dep := SUPPORTED.get(hook['id'])) is not None: # `mirrors-mypy` and various node revs have a 'v' prefix, # so we have to strip that out to get the # additional_dependency version. cleaned_rev = repo['rev'].removeprefix('v') - versions[hid] = cleaned_rev + versions[dep] = cleaned_rev updated = [] for repo in loaded['repos']: diff --git a/tests/sync_pre_commit_deps_test.py b/tests/sync_pre_commit_deps_test.py index 9038628..f435b52 100644 --- a/tests/sync_pre_commit_deps_test.py +++ b/tests/sync_pre_commit_deps_test.py @@ -130,6 +130,14 @@ def test_main_writes_all(tmpdir): ' - id: eslint\n' ' additional_dependencies:\n' ' - eslint@8.38.0\n' + # gives the `@biomejs/biome` version and also has its + # additional_dependencies rewritten + '- repo: https://github.com/biomejs/pre-commit\n' + ' rev: v2.4.15\n' + ' hooks:\n' + ' - id: biome-check\n' + ' additional_dependencies:\n' + ' - "@biomejs/biome@1.8.1"\n' # all repos below should have their additional_dependencies rewritten '- repo: https://github.com/asottile/yesqa\n' ' rev: v1.5.0\n' @@ -185,6 +193,12 @@ def test_main_writes_all(tmpdir): ' - id: eslint\n' ' additional_dependencies:\n' ' - eslint@8.39.0\n' + '- repo: https://github.com/biomejs/pre-commit\n' + ' rev: v2.4.15\n' + ' hooks:\n' + ' - id: biome-check\n' + ' additional_dependencies:\n' + ' - "@biomejs/biome@2.4.15"\n' '- repo: https://github.com/asottile/yesqa\n' ' rev: v1.5.0\n' ' hooks:\n'