@@ -105,122 +105,169 @@ The first option is an object with the following configuration.
105105
106106| configuration| format| default| description|
107107| ---| ---| ---| ---|
108- | ` ignoreBaseIndent ` | boolean| ` false ` | Does not leave base indent before linting.|
109108| ` ignoreExpressions ` | boolean| ` false ` | Does not format template literals that contain expressions.|
110109| ` ignoreInline ` | boolean| ` true ` | Does not format queries that are written on a single line.|
111110| ` ignoreStartWithNewLine ` | boolean| ` true ` | Does not remove ` \n ` at the beginning of queries.|
112111| ` ignoreTagless ` | boolean| ` true ` | Does not format queries that are written without using ` sql ` tag.|
112+ | ` retainBaseIndent ` | boolean| ` true ` | Uses the first line of the query as the base indent.|
113113| ` sqlTag ` | string| ` sql ` | Template tag name for SQL.|
114114
115115The second option is an object with the [ ` pg-formatter ` configuration] ( https://github.com/gajus/pg-formatter#configuration ) .
116116
117117The following patterns are considered problems:
118118
119119``` js
120+ sql `
121+ SELECT
122+ 1
123+ `
124+ // Options: [{},{"spaces":4}]
125+ // Message: undefined
126+ // Fixed code:
127+ // sql`
128+ // SELECT
129+ // 1
130+ // `
131+
132+ sql .type ({ id: z .number () })`
133+ SELECT
134+ 1
135+ `
136+ // Options: [{},{"spaces":4}]
137+ // Message: undefined
138+ // Fixed code:
139+ // sql.type({ id: z.number() })`
140+ // SELECT
141+ // 1
142+ // `
143+
144+ sql .typeAlias (' void' )`
145+ SELECT
146+ 1
147+ `
148+ // Options: [{},{"spaces":4}]
149+ // Message: undefined
150+ // Fixed code:
151+ // sql.typeAlias('void')`
152+ // SELECT
153+ // 1
154+ // `
155+
120156` SELECT 1`
121- // Options: [{"ignoreInline":false,"ignoreTagless":false}]
122- // Message: Format the query
157+ // Options: [{"ignoreInline":false,"ignoreTagless":false},{} ]
158+ // Message: undefined
123159// Fixed code:
124160// `
125- // SELECT
161+ // SELECT
126162// 1
127163// `
128164
129165` SELECT 2`
130166// Options: [{"ignoreInline":false,"ignoreTagless":false},{"spaces":2}]
131- // Message: Format the query
167+ // Message: undefined
132168// Fixed code:
133169// `
134- // SELECT
135- // 2
170+ // SELECT
171+ // 2
136172// `
137173
138174sql .unsafe ` SELECT 3`
139- // Options: [{"ignoreInline":false}]
140- // Message: Format the query
175+ // Options: [{"ignoreInline":false},{} ]
176+ // Message: undefined
141177// Fixed code:
142178// sql.unsafe`
143- // SELECT
179+ // SELECT
144180// 3
145181// `
146182
147183sql .type ()` SELECT 3`
148- // Options: [{"ignoreInline":false}]
149- // Message: Format the query
184+ // Options: [{"ignoreInline":false},{} ]
185+ // Message: undefined
150186// Fixed code:
151187// sql.type()`
152- // SELECT
188+ // SELECT
153189// 3
154190// `
155191
156192` SELECT ${ ' foo' } FROM ${ ' bar' } `
157- // Options: [{"ignoreInline":false,"ignoreTagless":false}]
158- // Message: Format the query
193+ // Options: [{"ignoreInline":false,"ignoreTagless":false},{} ]
194+ // Message: undefined
159195// Fixed code:
160196// `
161- // SELECT
197+ // SELECT
162198// ${'foo'}
163- // FROM
199+ // FROM
164200// ${'bar'}
165201// `
166202
167- const code = sql `
168- SELECT
169- ${ ' foo' }
170- FROM
171- ${ ' bar' }
203+ const code = sql `
204+ SELECT
205+ foo
206+ FROM
207+ bar
172208`
173- // Options: [{"ignoreBaseIndent":false }]
174- // Message: Format the query
209+ // Options: [{},{ }]
210+ // Message: undefined
175211// Fixed code:
176- // const code = sql`
177- // SELECT
178- // ${' foo'}
179- // FROM
180- // ${' bar'}
212+ // const code = sql`
213+ // SELECT
214+ // foo
215+ // FROM
216+ // bar
181217// `
182218
183219SQL ` SELECT 1 `
184- // Options: [{"ignoreInline":false,"sqlTag":"SQL"}]
185- // Message: Format the query
220+ // Options: [{"ignoreInline":false,"sqlTag":"SQL"},{} ]
221+ // Message: undefined
186222// Fixed code:
187223// SQL`
188- // SELECT
224+ // SELECT
189225// 1
190226// `
191227```
192228
193229The following patterns are not considered problems:
194230
195231``` js
232+ `
233+ # A
234+ ## B
235+ ### C
236+ `
237+
196238sql ` SELECT 1 `
197- // Options: [{"ignoreInline":true}]
239+ // Options: [{"ignoreInline":true},{} ]
198240
199241` SELECT 2`
200- // Options: [{"ignoreTagless":true}]
242+ // Options: [{"ignoreTagless":true},{} ]
201243
202- ` SELECT ${ ' foo' } FROM ${ ' bar' } `
203- // Options: [{"ignoreExpressions":true,"ignoreInline":false,"ignoreTagless":false}]
204-
205- const code = sql `
206- SELECT
207- ${ ' foo' }
208- FROM
209- ${ ' bar' }
210- `
211- // Options: [{"ignoreBaseIndent":true}]
212-
213- const code = sql `
214- DROP TABLE foo
215- ` ;
216- // Options: [{"ignoreBaseIndent":true}]
217-
218- const code = sql `
219- DROP TABLE foo;
220-
221- DROP TABLE foo;
222- ` ;
223- // Options: [{"ignoreBaseIndent":true}]
244+ const code = sql `
245+ SELECT
246+ ${ ' foo' }
247+ FROM
248+ ${ ' bar' }
249+ `
250+ // Options: [{"ignoreExpressions":true,"ignoreInline":false,"ignoreTagless":false},{}]
251+
252+ const code = sql `
253+ SELECT
254+ ${ ' foo' }
255+ FROM
256+ ${ ' bar' }
257+ `
258+ // Options: [{},{}]
259+
260+ const code = sql `
261+ DROP TABLE foo
262+ `
263+ // Options: [{},{}]
264+
265+ const code = sql `
266+ DROP TABLE foo;
267+
268+ DROP TABLE foo;
269+ `
270+ // Options: [{},{}]
224271```
225272
226273
@@ -251,20 +298,20 @@ The following patterns are considered problems:
251298
252299``` js
253300` SELECT 1`
254- // Message: Use "sql" tag
301+ // Message: undefined
255302
256303` SELECT ${ ' foo' } `
257- // Message: Use "sql" tag
304+ // Message: undefined
258305
259306foo` SELECT ${ ' bar' } `
260- // Message: Use "sql" tag
307+ // Message: undefined
261308
262309` SELECT ?`
263- // Message: Use "sql" tag
310+ // Message: undefined
264311
265312foo` SELECT ${ ' bar' } `
266313// Options: [{"sqlTag":"SQL"}]
267- // Message: Use "SQL" tag
314+ // Message: undefined
268315```
269316
270317The following patterns are not considered problems:
0 commit comments