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.
npm install eslint-plugin-format-sqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Install the plugin and configure it in ESLint to format SQL template literals with --fix.
Ensure your SQL template literal has a tag (e.g., SQL`...`) and include that tag name in the 'tags' array.
Adjust 'startSpaces' to match your coding style; typically 0 or 2.
Use only simple ${variable} placeholders; avoid complex expressions inside the template literal.Test with your specific library; if issues, configure 'tags' to match the exact tag name used.
Run `npm install --save-dev eslint-plugin-format-sql` and verify node_modules.
Add 'format-sql' to the 'plugins' array in your ESLint configuration.
Use 'mysql' instead of 'mysql2' or check the documentation for supported dialects.