prettier-plugin-sql
Advanced tools
Comparing version 0.10.2 to 0.11.0
import { type AST, type Option } from 'node-sql-parser'; | ||
import type { Options, ParserOptions, Plugin } from 'prettier'; | ||
import { type FormatFnOptions } from 'sql-formatter'; | ||
import { type FormatOptions } from 'sql-formatter'; | ||
declare const SQL_FORMATTER = "sql-formatter"; | ||
declare const NODE_SQL_PARSER = "node-sql-parser"; | ||
export declare type SqlBaseOptions = Option & Partial<FormatFnOptions> & { | ||
export declare type SqlBaseOptions = Option & Partial<FormatOptions> & { | ||
formatter?: typeof NODE_SQL_PARSER | typeof SQL_FORMATTER; | ||
@@ -8,0 +8,0 @@ }; |
import { __rest } from "tslib"; | ||
import nodeSqlParser from 'node-sql-parser'; | ||
import { format } from 'sql-formatter'; | ||
import { format, Formatter } from 'sql-formatter'; | ||
import { languages } from './languages.js'; | ||
@@ -35,7 +35,4 @@ const parser = new nodeSqlParser.Parser(); | ||
: parser.sqlify(value, { type, database }); | ||
// It can never be `auto` | ||
// @see https://github.com/prettier/prettier/blob/ab72a2c11c806f3a8a5ef42314e291843e1b3e68/src/common/end-of-line.js#L3-L9 | ||
const ending = ENDINGS[endOfLine]; | ||
formatted = formatted.replace(/\r\n?|\n/g, ending); | ||
/* c8 ignore next */ | ||
return formatted.endsWith(ending) ? formatted : formatted + ending; | ||
@@ -103,2 +100,6 @@ }, | ||
{ | ||
value: 'singlestoredb', | ||
description: 'SingleStoreDB: https://docs.singlestore.com/db/v7.8/en/introduction/singlestore-documentation.html', | ||
}, | ||
{ | ||
value: 'spark', | ||
@@ -108,5 +109,14 @@ description: 'Spark: https://spark.apache.org', | ||
{ | ||
value: 'trino', | ||
description: 'Trino: https://trino.io', | ||
}, | ||
{ | ||
value: 'tsql', | ||
description: 'SQL Server Transact-SQL: https://docs.microsoft.com/en-us/sql/sql-server/', | ||
}, | ||
{ | ||
since: '0.11.0', | ||
value: Formatter, | ||
description: 'Custom formatter class (experimental)', | ||
}, | ||
], | ||
@@ -184,27 +194,2 @@ }, | ||
}, | ||
aliasAs: { | ||
since: '0.7.0', | ||
category: 'Format', | ||
type: 'choice', | ||
default: 'preserve', | ||
description: 'Enforces consistent use of `AS` keywords in alias declarations for `sql-formatter`', | ||
choices: [ | ||
{ | ||
value: 'preserve', | ||
description: 'does nothing', | ||
}, | ||
{ | ||
value: 'always', | ||
description: 'enforces `AS` usage for all aliases', | ||
}, | ||
{ | ||
value: 'never', | ||
description: 'forbids `AS` usage for all aliases', | ||
}, | ||
{ | ||
value: 'select', | ||
description: 'enforces `AS` usage in column aliases of `SELECT` and forbids it for table name aliases', | ||
}, | ||
], | ||
}, | ||
tabulateAlias: { | ||
@@ -281,4 +266,2 @@ since: '0.7.0', | ||
], | ||
/* c8 ignore next 11 */ | ||
// @ts-expect-error | ||
exception(value) { | ||
@@ -291,2 +274,14 @@ return (value == null || | ||
}, | ||
paramTypes: { | ||
since: '0.11.0', | ||
category: 'Config', | ||
type: 'choice', | ||
description: 'Specifies parameter types to support when parsing SQL prepared statements for `sql-formatter`.', | ||
choices: [ | ||
{ | ||
value: Object, | ||
description: 'Specifies parameter types to support when parsing SQL prepared statements.', | ||
}, | ||
], | ||
}, | ||
type: { | ||
@@ -293,0 +288,0 @@ since: '0.1.0', |
{ | ||
"name": "prettier-plugin-sql", | ||
"version": "0.10.2", | ||
"version": "0.11.0", | ||
"type": "module", | ||
@@ -79,3 +79,3 @@ "description": "An opinionated sql formatter plugin for Prettier", | ||
"node-sql-parser": "^4.4.0", | ||
"sql-formatter": "^8.2.0", | ||
"sql-formatter": "^9.2.0", | ||
"tslib": "^2.4.0" | ||
@@ -82,0 +82,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
45358
967
+ Addedsql-formatter@9.2.0(transitive)
- Removedsql-formatter@8.2.0(transitive)
Updatedsql-formatter@^9.2.0