prettier-plugin-sql
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -8,2 +8,7 @@ import { __rest } from "tslib"; | ||
const NODE_SQL_PARSER = 'node-sql-parser'; | ||
const ENDINGS = { | ||
lf: '\n', | ||
cr: '\r', | ||
crlf: '\r\n', | ||
}; | ||
const SqlPlugin = { | ||
@@ -26,7 +31,12 @@ languages, | ||
print(path, _a) { | ||
var { type, database } = _a, options = __rest(_a, ["type", "database"]); | ||
var { type, database, endOfLine } = _a, options = __rest(_a, ["type", "database", "endOfLine"]); | ||
const value = path.getValue(); | ||
return typeof value === 'string' | ||
let formatted = typeof value === 'string' | ||
? format(value, options) | ||
: 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); | ||
return formatted.endsWith(ending) ? formatted : formatted + ending; | ||
}, | ||
@@ -33,0 +43,0 @@ }, |
{ | ||
"name": "prettier-plugin-sql", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"type": "module", | ||
@@ -79,3 +79,3 @@ "description": "An opinionated sql formatter plugin for Prettier", | ||
"node-sql-parser": "^4.3.0", | ||
"sql-formatter": "^8.0.1" | ||
"sql-formatter": "^8.0.2" | ||
}, | ||
@@ -82,0 +82,0 @@ "publishConfig": { |
@@ -60,4 +60,13 @@ # prettier-plugin-sql ![npm bundle size](https://img.shields.io/bundlephobia/min/prettier-plugin-sql) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/prettier-plugin-sql) | ||
| 'tsql' // default `sql` | ||
uppercase: boolean // default `false` | ||
linesBetweenQueries: number // default `2` | ||
keywordCase: 'preserve' | 'upper' | 'lower' // default `preserve` | ||
indentStyle: 'standard' | 'tabularLeft' | 'tabularRight' // default `standard` | ||
logicalOperatorNewline: 'before' | 'after' // default `before` | ||
aliasAs: 'preserve' | 'always' | 'never' | 'select' // default `preserve` | ||
tabulateAlias: boolean // default `false` | ||
commaPosition: 'after' | 'before' | 'tabular' // default `after` | ||
expressionWidth: number // default `50` | ||
linesBetweenQueries: number // default `1` | ||
denseOperators: boolean // default `false` | ||
newlineBeforeSemicolon: boolean // default `false` | ||
params: Array | Object | ||
@@ -64,0 +73,0 @@ // node-sql-parser |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45355
968
114
Updatedsql-formatter@^8.0.2