Repository navigation
dataform-sqlx-lint: a pre-commit linter for .sqlx config-block conventions #2404
ihistand
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi all. We run a Dataform project of about 1,500
.sqlxfiles on BigQuery, and the review comments we kept repeating weren't about SQL. They were about theconfig {}block and project conventions. sqlfluff checks the SQL body anddataform compilechecks syntax, but neither catches a hardcoded_prodschema, an undocumented output column, or a backtick table path that bypasses${ref()}. So we wrote a small linter for those and open-sourced it (MIT):https://github.com/acuantia/dataform-sqlx-lint
It's pure Python standard library (3.11+, no dependencies) and is built to run as a pre-commit hook.
Example
config { type: "table", schema: "reporting_prod", columns: { order_date: "Calendar date of the order" } } select date(created_at) as order_date, count(*) as order_count from `my-project.raw.orders` group by 1What it checks
schema:hardcodes an environment suffix that--schema-suffixwill append again (looker_prod_prod).`project.dataset.table`paths instead of${ref()}. These silently drop the dependency from the graph.columns: {}. It followsselect *through a plain${ref()}into the upstream file, and it skips anything it can't parse rather than false-flagging it. This matters becausecolumns: {}becomes the BigQuery column descriptions that catalogs, BI tools and AI agents read.columns: {}block, and no redundantname:that just repeats the filename.definitions/output/looker/must be atableorincrementalprefixedlooker_).FOREIGN KEYwritten by hand inpost_operations, for projects that generate key DDL and assertions from one map.schema:on operations/assertions (E005), andpost_operationsplacement (W008).All rules are configurable from
.sqlx-lint.tomlor[tool.sqlx-lint]inpyproject.toml. You can suppress a finding inline with a reason, e.g.-- sqlx-lint: disable=E006 (...).pre-commit
The repo also ships an Agent Skill, so Claude Code, Antigravity or Codex run the linter on every
.sqlxfile they write.I'd love feedback, especially on conventions other teams enforce that a rule could cover. Issues and PRs are welcome.
All reactions