Registry / testing / eslint-plugin-sql-formatter

eslint-plugin-sql-formatter

JSON →
library1.0.5jsnpmunverified

ESLint plugin for formatting SQL queries in .sql files and tagged template literals (sql`...`) in .js/.ts files. Integrates with sql-formatter-org/sql-formatter for consistent SQL formatting. Version 1.0.5 is stable but has low release cadence. Key differentiator: it formats inline SQL in JavaScript/TypeScript template strings, not just standalone .sql files. Alternatives like prettier-plugin-sql or eslint-plugin-sql only handle file-level formatting.

npm install eslint-plugin-sql-formatter
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-SQL-
E
eslint-plugin-sql-formatter
testingjavascriptv1.0.5
harness data pending
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.

plugin
plugins: ['sql'] in .eslintrc
plugins: ['sql-formatter']
The plugin name in ESLint config is 'sql', not 'sql-formatter'. This is because the package name is converted: eslint-plugin-sql-formatter -> 'sql-formatter' in plugins, but the rule prefix is 'sql'.
rule sql/format
rules: { 'sql/format': ['error', {...}] }
rules: { 'sql-formatter/format': ['error', {...}] }
Rule names are prefixed with 'sql/', not 'sql-formatter/'.
sql tagged template
const query = sql`SELECT * FROM users WHERE id = ${id}`;
const query = sql(`SELECT * FROM users WHERE id = ${id}`);
The plugin detects sql tagged template literals, not function calls. Ensure you use backtick syntax with sql prefix.

Shows ESLint configuration with the sql-formatter plugin, enabling the format rule for PostgreSQL with 2-space indentation. Also shows a sql tagged template literal that the plugin will format.

// .eslintrc.json { "plugins": ["sql"], "rules": { "sql/format": ["error", { "ignoreSingleLine": true, "sqlFormatterConfig": { "language": "postgresql", "indent": " " } }] } } // example.js import { sql } from 'slonik'; const query = sql`SELECT id, name FROM users WHERE id = ${userId}`;
Debug
Known issues
gotchaPlugin name in plugins array is 'sql', not 'sql-formatter'. Misconfiguration leads to rule not being applied.
fix
Use 'plugins': ['sql'] in ESLint config.
affects: all
gotchaThe sql-formatter npm package (v1.0.x) uses a different API than v2+. Ensure compatibility with the installed sql-formatter version.
fix
Pin sql-formatter to v1.x or check plugin compatibility with sql-formatter v2+.
affects: >=1.0.0
gotchaRule is called 'sql/format', not 'sql-formatter/format' or 'format'. Wrong rule name causes silent failure.
fix
Use 'sql/format' as the rule key.
affects: all
deprecatedThe 'ignoreSingleLine' option defaults to true. In future versions this default may change or the option may be removed.
fix
Set explicitly to avoid future breaking changes.
affects: <=1.0.5
Errors
Common errors & fixes
ESLint couldn't find the plugin "eslint-plugin-sql-formatter".
Plugin not installed or plugin name misspelled in .eslintrc plugins array.
fix
Run `npm install eslint-plugin-sql-formatter --save-dev` and ensure plugins array contains 'sql' (not 'sql-formatter').
Definition for rule 'sql/format' was not found.
Plugin not in plugins array or rule name misspelled.
fix
Add 'plugins': ['sql'] and 'rules': { 'sql/format': [...] }.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
sql-formatterrequiredprovides the actual SQL formatting engine; options passed via sqlFormatterConfig
Agent activity
7 hits · last 30 days
node
6
Resources
eslint-plugin-sql-formatter — npm install eslint-plugin-sql-formatter · libregistry