Formatter
sqlfu includes a SQLite-focused SQL formatter. Use it from the CLI when you want to rewrite files, from ESLint when you want editor feedback, or from TypeScript when you need to format SQL programmatically.
Format files
Section titled “Format files”npx sqlfu format "sql/**/*.sql" definitions.sqlThe command accepts file paths, directories, and simple glob patterns. It rewrites files in place and reports which files changed.
Formatted files: sql/get-posts.sqlAlready formatted: definitions.sqlThe formatter is intentionally opinionated: SQLite-first, lowercase by default, and biased toward keeping simple clause bodies inline when they still read well.
Use ESLint
Section titled “Use ESLint”The lint plugin exposes the same formatter through sqlfu/format-sql.
import sqlfu from 'sqlfu/lint-plugin';
export default [ { files: ['**/*.sql'], plugins: {sqlfu}, processor: 'sqlfu/sql', rules: { 'sqlfu/format-sql': 'error', }, },];Then run:
eslint --fix "sql/**/*.sql"Use this when you want the formatter in the same editor and CI loop as the rest of your lint rules.
Related pages
Section titled “Related pages”- Lint plugin covers all SQL-aware ESLint rules.
- CLI lists the rest of the command surface.