diff --git a/specs/phoenix/template/.githooks/pre-commit b/specs/phoenix/template/.githooks/pre-commit index 90300f5..1ddbda9 100755 --- a/specs/phoenix/template/.githooks/pre-commit +++ b/specs/phoenix/template/.githooks/pre-commit @@ -1,13 +1,24 @@ #!/usr/bin/env bash set -e -filesToFormat=$( +mixFiles=$( git --no-pager diff --name-status --no-color --cached | \ awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}' ) -for path in $filesToFormat +for path in $mixFiles do mix format "$path" git add "$path" done + +webFiles=$( + git --no-pager diff --name-status --no-color --cached | \ + awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}' +) + +for path in $webFiles +do + prettier --write "$path" + git add "$path" +done diff --git a/specs/phoenix/template/README.md b/specs/phoenix/template/README.md index 2a38fd5..0a606f0 100644 --- a/specs/phoenix/template/README.md +++ b/specs/phoenix/template/README.md @@ -78,12 +78,14 @@ supports lock versions 1 and 2. ## Language Server The [elixir-ls](https://github.com/elixir-lsp/elixir-ls) LSP (version 0.17.10) -is included in this flake. +and [typescript-language-server](https://github.com/typescript-language-server/typescript-language-server) +(version 4.1.2) is included in this flake. ## Formatting -Formatting depends on the `mix format` task. A `pre-commit` hook is included in -`.githooks` that can be used to format all `*.exs?` files prior to commit. +Formatting depends on [prettier](https://prettier.io/) (version 3.1.0) and the +`mix format` task. A `pre-commit` hook is included in `.githooks` that can be +used to format all `*.exs?`, `*.jsx?`, and `*.tsx?` files prior to commit. Install via: ```bash $ git config --local core.hooksPath .githooks/