Registry / testing / eslint-plugin-format-sql

eslint-plugin-format-sql

JSON →
library1.1.1jsnpmunverified

An ESLint plugin that automatically formats SQL queries inside template literals tagged with configurable identifiers (e.g., SQL, sql). Current version 1.1.1, updated semi-regularly. It leverages the sql-formatter library to support 15+ SQL dialects (PostgreSQL, MySQL, BigQuery, etc.) and adds post-formatting improvements. Unlike generic formatters, it integrates directly into the ESLint workflow with --fix support, allowing codebases to enforce consistent SQL formatting without manual effort. Ships TypeScript type definitions.

testing
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

This is an ESLint plugin, not a regular library. It is loaded via ESLint's configuration, not imported in source code.

// In .eslintrc.{js,json}: "plugins": ["format-sql"]

Flat config is available since v1.1.0; use 'flat/recommended' or 'flat/format'.

// eslint.config.js: export default [ ...require('eslint-plugin-format-sql').configs['flat/recommended'], ];

Rules are referenced by name in ESLint configuration, not imported.

// .eslintrc: "format-sql/format": "warn"

Install the plugin and configure it in ESLint to format SQL template literals with --fix.

npm install --save-dev eslint eslint-plugin-format-sql
Debug
Known footguns
gotchaThe plugin only formats template literals tagged with the names specified in the 'tags' option; untagged strings are ignored.
gotchaThe 'startSpaces' option adds extra indentation to the entire query; setting it too high can produce excessive whitespace.
gotchaThe plugin may not correctly handle nested template expressions or dynamic SQL parts that are not string literals.
gotchaIf the SQL template library (e.g., pg-sql-template) modifies the tag behavior, the plugin might not recognize the tag correctly.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
bytedance
3
Resources