diff --git a/Dockerfile b/Dockerfile index 4fd3c82..f0a427a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ diff --git a/README.md b/README.md index 33abc1e..7f4e573 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/entry.ts b/entry.ts index c6d863a..6894326 100644 --- a/entry.ts +++ b/entry.ts @@ -77,6 +77,7 @@ const enum HookName { Scalafmt = "scalafmt", Sed = "sed", Shfmt = "shfmt", + SqlFluff = "SQLFluff", Svgo = "SVGO", TerraformFmt = "terraform fmt", Xsltproc = "xsltproc", @@ -340,6 +341,20 @@ const HOOKS: Record = { 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$/,