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

Format SQL #24

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ RUN apk add --no-cache --virtual .build-deps \
autoflake==1.4 \
black==22.3.0 \
isort==5.10.1 \
sqlfluff==1.4.5 \
&& python3 -m venv /black21-venv \
&& source /black21-venv/bin/activate \
&& pip3 install black==21.12b0 click==8.0.4 \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook
- [ktfmt](https://github.com/facebookincubator/ktfmt) v0.35 for Kotlin
- [scalafmt](https://scalameta.org/scalafmt/) v3.5.1 for Scala
- [shfmt](https://github.com/mvdan/sh) v3.4.3 for Shell
- [SQLFluff](https://github.com/sqlfluff/sqlfluff) v1.4.5 for SQL
- [xsltproc](http://www.xmlsoft.org/xslt/xsltproc.html) from libxslt v10135 for XML
- [terraform fmt](https://github.com/hashicorp/terraform) v1.1.8 for Terraform
- [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v13.0.1 for Protobuf
Expand Down
15 changes: 15 additions & 0 deletions entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const enum HookName {
Scalafmt = "scalafmt",
Sed = "sed",
Shfmt = "shfmt",
SqlFluff = "SQLFluff",
Svgo = "SVGO",
TerraformFmt = "terraform fmt",
Xsltproc = "xsltproc",
Expand Down Expand Up @@ -340,6 +341,20 @@ const HOOKS: Record<HookName, LockableHook> = {
include: /./,
runAfter: [HookName.Sed],
}),
[HookName.SqlFluff]: createLockableHook({
action: sources =>
run(
"sqlfluff",
"fix",
"--dialect",
"bigquery",
"--force",
"--ignore-local-config",
...sources,
),
include: /\.sql$/,
runAfter: [HookName.Sed],
}),
[HookName.Svgo]: createLockableHook({
action: sources => run("svgo", "--config", "/svgo.config.js", ...sources),
include: /\.svg$/,
Expand Down