Skip to content

Commit

Permalink
Add editorconfig for shfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxattax97 committed Aug 29, 2024
1 parent 419ff50 commit 1059fd8
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[*.sh]
##### MOCULL AUTOGENERATED ### DO NOT EDIT #####
# Using [[shell]] rather than [*.sh] will capture files with no extension
[[shell]]
# Used by shfmt
indent_style = space
indent_size = 4
shell_variant = posix
;shell_variant = posix
binary_next_line = true
switch_case_indent = true
space_redirects = true
keep_padding = true
function_next_line = true
simplify = true
##### END MOCULL AUTOGENERATED ### DO NOT EDIT #####
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ repos:
hooks:
- id: hadolint-docker

- repo: https://github.com/pecigonzalo/pre-commit-shfmt
rev: v2.2.0
hooks:
- id: shell-fmt-docker
args:
- -w

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
Expand Down
4 changes: 4 additions & 0 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,7 @@ zshrc_setup_repo() {
FILE_PYPROJECT="${templates}/pyproject.toml"
FILE_FLAKE8="${templates}/flake8"
FILE_YAMLLINT="${templates}/yamllint.yml"
FILE_EDITORCONFIG="${templates}/editorconfig"
# Update .gitignore
zshrc_update_or_append "$repo_dir/.gitignore" "$FILE_GITIGNORE"
Expand All @@ -1895,6 +1896,9 @@ zshrc_setup_repo() {
# Update .yamllint.yml since all projects can use YAML
zshrc_update_or_append "$repo_dir/.yamllint.yml" "$FILE_YAMLLINT"
# Every repo gets this.
zshrc_update_or_append "$repo_dir/.editorconfig" "$FILE_EDITORCONFIG"
# Update .pre-commit-config.yaml based on project type
if [ -s "$repo_dir/Cargo.toml" ]; then
zshrc_update_or_append "$repo_dir/.pre-commit-config.yaml" "$FILE_PRE_COMMIT_CONFIG_RUST"
Expand Down
11 changes: 11 additions & 0 deletions templates/editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Using [[shell]] rather than [*.sh] will capture files with no extension
[[shell]]
# Used by shfmt
indent_style = space
indent_size = 4
;shell_variant = posix
binary_next_line = true
switch_case_indent = true
space_redirects = true
keep_padding = true
simplify = true
7 changes: 7 additions & 0 deletions templates/pre-commit-config.general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ repos:
hooks:
- id: hadolint-docker

- repo: https://github.com/pecigonzalo/pre-commit-shfmt
rev: v2.2.0
hooks:
- id: shell-fmt-docker
args:
- -w

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
Expand Down
7 changes: 7 additions & 0 deletions templates/pre-commit-config.helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ repos:
hooks:
- id: hadolint-docker

- repo: https://github.com/pecigonzalo/pre-commit-shfmt
rev: v2.2.0
hooks:
- id: shell-fmt-docker
args:
- -w

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
Expand Down
7 changes: 7 additions & 0 deletions templates/pre-commit-config.python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ repos:
hooks:
- id: hadolint-docker

- repo: https://github.com/pecigonzalo/pre-commit-shfmt
rev: v2.2.0
hooks:
- id: shell-fmt-docker
args:
- -w

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
Expand Down
7 changes: 7 additions & 0 deletions templates/pre-commit-config.rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ repos:
hooks:
- id: hadolint-docker

- repo: https://github.com/pecigonzalo/pre-commit-shfmt
rev: v2.2.0
hooks:
- id: shell-fmt-docker
args:
- -w

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
Expand Down

0 comments on commit 1059fd8

Please sign in to comment.