
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
prettier-plugin-sql-cst
Advanced tools
A Prettier plugin for SQL that uses sql-parser-cst and the actual Prettier formatting algorithm.
Like Prettier for JavaScript, this plugin formats SQL expressions differently depending on their length. A short SQL query will be formatted on a single line:
SELECT a, b, c FROM tbl WHERE x > 10
A longer query, will get each clause printed on a separate line:
SELECT id, client.name, client.priority
FROM client
WHERE client.id IN (12, 18, 121)
An even longer one gets the contents of each clause indented:
SELECT
client.id,
client.name AS client_name,
organization.name AS org_name,
count(order.id) AS nr_of_orders
FROM
client
LEFT JOIN organization ON client.organization_id = organization.id
LEFT JOIN order ON order.client_id = client.id
WHERE
client.status = 'active'
AND client.id IN (28, 214, 457)
AND order.status IN ('active', 'pending', 'processing')
GROUP BY client.id
ORDER BY client.name
LIMIT 100
Currently this plugin preserves most of the syntax elements and concentrates mainly on the layout of whitespace. For example it does not add/remove paratheses.
There are some opinionated non-whitespace changes though:
AS
keyword to all alias definitions.Install it as any other Prettier plugin:
npm install --save-dev prettier prettier-plugin-sql-cst
Then use it on SQL files though Prettier command line tool or Prettier extension for your editor of choice.
By default the plugin will determine SQL dialect based on file extension:
.sql
or .sqlite
- SQLite.bigquery
- BigQueryYou can override this behavior with a prettier configuration:
{
"overrides": [
{
"files": ["*.sql"],
"options": { "parser": "bigquery" }
}
]
}
The plugin provides the following parsers:
sqlite
bigquery
The standard Prettier options printWidth, tabWidth, useTabs apply. There are also some SQL-specific options:
API Option | Default | Description |
---|---|---|
sqlKeywordCase | upper | Converts SQL keywords to upper or lower case, or preserve existing. |
Currently this plugin supports most of SQLite syntax. (It also supports some BigQuery, but only the syntax that's subset of SQLite.) Formatting of the following SQL statements is fully implemented:
FAQs
Prettier plugin for SQL
The npm package prettier-plugin-sql-cst receives a total of 8,338 weekly downloads. As such, prettier-plugin-sql-cst popularity was classified as popular.
We found that prettier-plugin-sql-cst demonstrated a healthy version release cadence and project activity because the last version was released less than 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.