Skip to content

feat: add shfmt pre-commit hooks for bash script formatting - #311

Open
Patrick-Ehimen wants to merge 1 commit into
sablier-labs:mainfrom
Patrick-Ehimen:feat/add-shfmt-pre-commit-hooks
Open

feat: add shfmt pre-commit hooks for bash script formatting#311
Patrick-Ehimen wants to merge 1 commit into
sablier-labs:mainfrom
Patrick-Ehimen:feat/add-shfmt-pre-commit-hooks

Conversation

@Patrick-Ehimen

Copy link
Copy Markdown

Summary

Implements automatic bash script formatting using shfmt to maintain consistency across the codebase. This PR adds pre-commit hooks that automatically format bash scripts on commit, and provides justfile recipes for manual formatting.

Changes

  • Added shfmt to lint-staged configuration (.lintstagedrc.js)

    • Automatically formats *.sh files on commit with 2-space indentation
    • Uses -s flag to simplify code structure
  • Added justfile recipes (justfile)

    • bash-check (alias: bashc) - Check bash script formatting without modifying
    • bash-write (alias: bashw) - Format bash scripts
    • Integrated both into full-check and full-write recipes
  • Updated documentation (CONTRIBUTING.md)

    • Added shfmt to prerequisites with installation instructions for macOS, Ubuntu, and manual download
    • Documented what just full-check verifies
  • Formatted existing bash scripts with 2-space indentation

    • scripts/bash/deploy-programs.sh - Reformatted with consistent 2-space indentation
    • scripts/bash/prepare-artifacts.sh - Added final newline

Test Plan

  • Installed shfmt v3.12.0 and verified it works
  • Ran bash -n syntax check on both scripts - both valid
  • Tested lint-staged with staged bash files - works correctly
  • Tested justfile recipes (bash-check, bash-write) - work correctly
  • Verified pre-commit hook runs automatically on commit

Resolves

Closes #246

Implements automatic bash script formatting using shfmt with 2-space indentation to maintain consistency across the codebase. Bash scripts are now formatted on commit via lint-staged and can be manually formatted using justfile recipes (bash-check, bash-write).

Resolves sablier-labs#246

@andreivladbrg andreivladbrg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR @Patrick-Ehimen

currently, the implementation does not add the pre-commit hook that the issue is referring to

please see here what we are referring to: https://github.com/sablier-labs/lockup/blob/main/.husky/pre-commit

@Patrick-Ehimen

Copy link
Copy Markdown
Author

thanks for the PR @Patrick-Ehimen

currently, the implementation does not add the pre-commit hook that the issue is referring to

please see here what we are referring to: https://github.com/sablier-labs/lockup/blob/main/.husky/pre-commit

i will take a look at it before eod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement pre-commit hooks

2 participants