Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: BATS: unofficial strict mode #2032

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.sh text eol=lf
*.bash text eol=lf
*.bats text eol=lf

# Docs allow trailing whitespaces
*.md whitespace=-blank-at-eol
Expand Down
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ repos:
hooks:
- id: git-check # Configure in .gitattributes
- id: shellcheck
exclude: ".bats$"
- id: shfmt
exclude: ".bats$"
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.7
hooks:
Expand All @@ -38,10 +36,9 @@ repos:
types: [file]
- id: dot-bash
name: Check .bash files against bash-it requirements
exclude: "test/test_helper.bash"
entry: ./hooks/dot-bash.sh
language: system
files: "\\.bash$"
files: "\\.ba[ts][sh]$"
types: [file]
- id: clean-files-txt
name: Check that clean_files.txt is sorted alphabetically.
Expand Down
7 changes: 1 addition & 6 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ aliases/
docs/
hooks/
scripts/
test/

# root files
#
Expand Down Expand Up @@ -134,12 +135,6 @@ plugins/available/todo.plugin.bash
plugins/available/xterm.plugin.bash
plugins/available/zoxide.plugin.bash

# tests
#
test/plugins/alias-completion.plugin.bats
test/run
test/test_helper.bash

# themes
#
themes/90210
Expand Down
3 changes: 2 additions & 1 deletion hooks/dot-bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ for file in "$@"; do
# Confirm expected schellcheck header
#
LINE1="$(head -n 1 "${file}")"
if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then
SCSH="${file##*.}"
if [[ "${LINE1}" != "# shellcheck shell=${SCSH}" ]]; then
echo "Bash include file \`${file}\` has bad/missing shellcheck header"
exit_code=1
fi
Expand Down
Loading