Skip to content

Commit 56f05df

Browse files
fix(Yarn): Correct regexes for Yarn releases
The `yarn-dedupe` and `yarn-build` hooks both intended to run on Yarn upgrades/downgrades. They both used an asterisk (`*`) to match the Yarn version number as if pre-commit expected a glob pattern rather than a Python regular expression. Replacing `*` with `.*` would correct this mistake but also leave the regular expressions overly broad. Prefer `(\d+\.){2}\d+` to only match version numbers and avoid false positives.
1 parent aac4e11 commit 56f05df

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

.pre-commit-hooks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
name: Deduplicate Yarn dependencies
104104
entry: yarn dedupe
105105
language: system
106-
files: \.tool-versions|package\.json|yarn(-*\.cjs|\.lock)
106+
files: \.tool-versions|package\.json|yarn(-(\d+\.){2}\d+\.cjs|\.lock)
107107
pass_filenames: false
108108
description: >
109109
Remove all but the highest version of any duplicates. More than one version
@@ -124,7 +124,7 @@
124124
name: Build the app
125125
entry: yarn run build
126126
language: system
127-
files: \.tool-versions|package\.json|yarn(-*\.cjs|\.lock)|.*\.ts
127+
files: \.tool-versions|package\.json|yarn(-(\d+\.){2}\d+\.cjs|\.lock)|.*\.ts
128128
pass_filenames: false
129129
description: >
130130
Compile TypeScript files to JavaScript. See https://yarnpkg.com/cli/run for

0 commit comments

Comments
 (0)