Skip to content

Commit 5560863

Browse files
pokeyphillcoAndreasArvidsson
authored
Add shell check pre commit hook (#2574)
## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet --------- Co-authored-by: Phil Cohen <phillip@phillip.io> Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com>
1 parent 0c8fb9c commit 5560863

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# shellcheck shell=bash
12
use flake

.pre-commit-config.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ repos:
77
hooks:
88
- id: check-hooks-apply
99
- id: check-useless-excludes
10+
1011
- repo: local
1112
hooks:
1213
- id: forbid-symlinks
1314
name: Forbid symlinks
1415
entry: Forbid symlinks
1516
language: fail
1617
types: [symlink]
18+
1719
- repo: https://github.com/Lucas-C/pre-commit-hooks
1820
rev: v1.5.6
1921
hooks:
2022
- id: forbid-crlf
23+
2124
- repo: https://github.com/pre-commit/pre-commit-hooks
2225
rev: v6.0.0
2326
hooks:
@@ -41,6 +44,7 @@ repos:
4144
# document contents. For example
4245
# data/fixtures/recorded/languages/ruby/changeCondition.yml
4346
exclude: ^data/fixtures/recorded/.*/[^/]*\.yml$|\.scope$|/generated/|^patches/
47+
4448
- repo: local
4549
hooks:
4650
- id: eslint
@@ -49,6 +53,7 @@ repos:
4953
language: system
5054
entry: pnpm exec eslint
5155
args: [--fix]
56+
5257
- repo: local
5358
hooks:
5459
- id: prettier
@@ -57,31 +62,42 @@ repos:
5762
language: system
5863
entry: pnpm exec prettier
5964
args: [--write, --list-different, --ignore-unknown]
65+
6066
- repo: local
6167
hooks:
6268
- id: format-recorded-tests
6369
name: format-recorded-tests
6470
files: ^data/fixtures/recorded/.*/[^/]*\.yml$
6571
language: system
6672
entry: pnpm exec ./packages/common/scripts/my-ts-node.js packages/cursorless-engine/src/scripts/transformRecordedTests/index.ts
73+
6774
- repo: local
6875
hooks:
6976
- id: check-recorded-test-marks
7077
name: check-recorded-test-marks
7178
files: ^data/fixtures/recorded/.*/[^/]*\.yml$
7279
language: system
7380
entry: pnpm exec ./packages/common/scripts/my-ts-node.js packages/cursorless-engine/src/scripts/transformRecordedTests/index.ts --check-marks
81+
7482
- repo: https://github.com/astral-sh/ruff-pre-commit
75-
rev: v0.15.1
83+
rev: v0.15.5
7684
hooks:
77-
- id: ruff
85+
- id: ruff-check
7886
args: [--fix, --exit-non-zero-on-fix]
7987
- id: ruff-format
88+
8089
- repo: https://github.com/lunarmodules/luacheck
8190
rev: v1.2.0
8291
hooks:
8392
- id: luacheck
93+
8494
- repo: https://github.com/JohnnyMorganz/StyLua
8595
rev: v0.20.0
8696
hooks:
8797
- id: stylua
98+
99+
- repo: https://github.com/koalaman/shellcheck-precommit
100+
rev: v0.11.0
101+
hooks:
102+
- id: shellcheck
103+
name: ShellCheck
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
find .. -name '*.test.ts' | xargs -n 50 pnpm run build:base --outdir=dist --out-extension:.js=.cjs
4+
find .. -name '*.test.ts' -print0 | xargs -0 -n 50 pnpm run build:base --outdir=dist --out-extension:.js=.cjs

scripts/deploy-cursorless-talon.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ set -euo pipefail
88
git switch -c cursorless-talon-staging origin/cursorless-talon-staging
99

1010
# Exit if there were no changes to the cursorless-talon directory
11-
[[ "$(git rev-parse $GITHUB_SHA:cursorless-talon)" == "$(git rev-parse cursorless-talon-staging^{tree})" ]] && exit 0
11+
[[ "$(git rev-parse "${GITHUB_SHA}:cursorless-talon")" == "$(git rev-parse 'cursorless-talon-staging^{tree}')" ]] && exit 0
1212

1313
# Fetch current cursorless-talon main
1414
git remote add cursorless-talon 'https://github.com/cursorless-dev/cursorless-talon.git'
1515
git fetch cursorless-talon
1616

1717
# Sanity check that cursorless-talon/main is identical to cursorless-talon-staging
18-
[[ "$(git rev-parse cursorless-talon/main^{tree})" == "$(git rev-parse cursorless-talon-staging^{tree})" ]]
18+
[[ "$(git rev-parse 'cursorless-talon/main^{tree}')" == "$(git rev-parse 'cursorless-talon-staging^{tree}')" ]]
1919

2020
# Tag previous version of staging branch
2121
git tag cursorless-talon-staging-previous cursorless-talon-staging
2222

2323
# Update the staging branch
24-
git switch -c github-sha $GITHUB_SHA
24+
git switch -c github-sha "$GITHUB_SHA"
2525
git subtree split --prefix=cursorless-talon --branch=cursorless-talon-staging
2626

2727
# Sanity check that the previous staging commit is an ancestor of the new one
@@ -32,11 +32,11 @@ git switch -c cursorless-talon-main cursorless-talon/main
3232
git cherry-pick cursorless-talon-staging-previous..cursorless-talon-staging
3333

3434
# Sanity check that cursorless-talon-main is identical to cursorless-talon-staging
35-
[[ "$(git rev-parse cursorless-talon-main^{tree})" == "$(git rev-parse cursorless-talon-staging^{tree})" ]]
35+
[[ "$(git rev-parse 'cursorless-talon-main^{tree}')" == "$(git rev-parse 'cursorless-talon-staging^{tree}')" ]]
3636

3737
# Sanity check that cursorless-talon-main is identical to cursorless-talon
3838
# subdirectory of cursorless-vscode
39-
[[ "$(git rev-parse cursorless-talon-main^{tree})" == "$(git rev-parse $GITHUB_SHA:cursorless-talon)" ]]
39+
[[ "$(git rev-parse 'cursorless-talon-main^{tree}')" == "$(git rev-parse "${GITHUB_SHA}:cursorless-talon")" ]]
4040

4141
# Push to cursorless-talon
4242
git push cursorless-talon cursorless-talon-main:main

0 commit comments

Comments
 (0)