
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
eslint-plugin-format-sql
Advanced tools
ESLint plugin to format SQL queries inside any SQL template tag. It works on top of the sql-formatter with some improvements and post-formations.
Install the plugin first:
npm install --save-dev eslint-plugin-format-sql
Then add this plugin to eslint config in extends
section and configure rule for your need:
// .eslintrc
{
"extends": [
// ...
"plugin:format-sql/format"
],
"rules": {
"format-sql/format": ["warn", {
"tags": ["SQL", "sql"], // names of SQL template tags to parse their literals
"language": "postgresql", // language name
"startSpaces": 0, // extra spaces to indent for each query line in first column of a query
"spaces": 2, // amount of indentation to use in statements
}],
// ...
},
}
Available options for language: sql
, postgresql
, db2
, hive
, mariadb
, mysql
, n1ql
, plsql
, bigquery
, redshift
, singlestoredb
, spark
, sqlite
, snowflake
, transactsql
, trino
,
In case no options is provided for the rule then default params will be used:
{
language: 'postgresql',
tags: ['SQL', 'sql'],
startSpaces: 2,
spaces: 2,
}
Example of formation with default options.
Before:
import { SQLFactory } from 'pg-sql-template'; // or another sql template library
import { client } from './client';
const SQL = SQLFactory({ client });
class PostsController {
async getPosts(userId: number) {
const posts = await SQL`
SELECT posts.id, posts.text, posts.created_at AS created, users.name AS author
FROM posts LEFT JOIN users ON users.id = posts.author_id
WHERE posts.author_id = ${userId}
ORDER BY posts.created_at`.many();
// ...
}
}
After --fix
:
import { SQLFactory } from 'pg-sql-template'; // or another sql template library
import { client } from './client';
const SQL = SQLFactory({ client });
class PostsController {
async getPosts(userId: number) {
const posts = await SQL`
SELECT posts.id,
posts.text,
posts.created_at AS created,
users.name AS author
FROM posts
LEFT JOIN users ON users.id = posts.author_id
WHERE posts.author_id = ${userId}
ORDER BY posts.created_at
`.many();
// ...
}
}
FAQs
ESLint plugin to format SQL query in template literals
The npm package eslint-plugin-format-sql receives a total of 245 weekly downloads. As such, eslint-plugin-format-sql popularity was classified as not popular.
We found that eslint-plugin-format-sql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.