You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .README/rules/format.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,21 +4,27 @@ _The `--fix` option on the command line automatically fixes problems reported by
4
4
5
5
Matches queries in template literals. Warns when query formatting does not match the configured format (see Options).
6
6
7
-
This rule is used to format the queries using [pg-formatter](https://github.com/gajus/pg-formatter).
7
+
This rule is used to format the queries using [sql-formatter](https://github.com/sql-formatter-org/sql-formatter).
8
8
9
9
#### Options
10
10
11
11
The first option is an object with the following configuration.
12
12
13
13
|configuration|format|default|description|
14
14
|---|---|---|---|
15
-
|`ignoreBaseIndent`|boolean|`false`|Does not leave base indent before linting.|
16
15
|`ignoreExpressions`|boolean|`false`|Does not format template literals that contain expressions.|
17
16
|`ignoreInline`|boolean|`true`|Does not format queries that are written on a single line.|
18
17
|`ignoreStartWithNewLine`|boolean|`true`|Does not remove `\n` at the beginning of queries.|
19
18
|`ignoreTagless`|boolean|`true`|Does not format queries that are written without using `sql` tag.|
19
+
|`retainBaseIndent`|boolean|`true`|Uses the first line of the query as the base indent.|
20
20
|`sqlTag`|string|`sql`|Template tag name for SQL.|
21
21
22
-
The second option is an object with the [`pg-formatter` configuration](https://github.com/gajus/pg-formatter#configuration).
22
+
The second option is an object with the [`sql-formatter` configuration](https://github.com/sql-formatter-org/sql-formatter?tab=readme-ov-file#configuration-options).
23
+
24
+
|configuration|default|description|
25
+
|---|---|---|
26
+
|`useTabs`|boolean|`false`|Use tabs for indentation.|
@@ -106,14 +105,176 @@ The first option is an object with the following configuration.
106
105
107
106
|configuration|format|default|description|
108
107
|---|---|---|---|
109
-
|`ignoreBaseIndent`|boolean|`false`|Does not leave base indent before linting.|
110
108
|`ignoreExpressions`|boolean|`false`|Does not format template literals that contain expressions.|
111
109
|`ignoreInline`|boolean|`true`|Does not format queries that are written on a single line.|
112
110
|`ignoreStartWithNewLine`|boolean|`true`|Does not remove `\n` at the beginning of queries.|
113
111
|`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.|
114
113
|`sqlTag`|string|`sql`|Template tag name for SQL.|
115
114
116
-
The second option is an object with the [`pg-formatter` configuration](https://github.com/gajus/pg-formatter#configuration).
115
+
The second option is an object with the [`sql-formatter` configuration](https://github.com/sql-formatter-org/sql-formatter?tab=readme-ov-file#configuration-options).
116
+
117
+
|configuration|default|description|
118
+
|---|---|---|
119
+
|`useTabs`|boolean|`false`|Use tabs for indentation.|
@@ -139,5 +300,41 @@ The first option is an object with the following configuration.
139
300
|`allowLiteral`|boolean|`false`|Controls whether `sql` tag is required for template literals containing literal queries, i.e. template literals without expressions.|
140
301
|`sqlTag`|string|`sql`|Template tag name for SQL.|
141
302
303
+
The following patterns are considered problems:
304
+
305
+
```js
306
+
`SELECT 1`
307
+
// Message: undefined
308
+
309
+
`SELECT ${'foo'}`
310
+
// Message: undefined
311
+
312
+
foo`SELECT ${'bar'}`
313
+
// Message: undefined
314
+
315
+
`SELECT ?`
316
+
// Message: undefined
317
+
318
+
foo`SELECT ${'bar'}`
319
+
// Options: [{"sqlTag":"SQL"}]
320
+
// Message: undefined
321
+
```
322
+
323
+
The following patterns are not considered problems:
0 commit comments