|
2 | 2 | # eslint-plugin-sql |
3 | 3 |
|
4 | 4 | [](https://travis-ci.org/gajus/eslint-plugin-sql) |
5 | | -[](https://coveralls.io/github/gajus/eslint-plugin-sql) |
6 | 5 | [](https://www.npmjs.org/package/eslint-plugin-sql) |
7 | 6 | [](https://github.com/gajus/canonical) |
8 | 7 | [](https://twitter.com/kuizinas) |
@@ -87,6 +86,59 @@ The first option is an object with the following configuration. |
87 | 86 |
|
88 | 87 | The second option is an object with the [`pg-formatter` configuration](https://github.com/gajus/pg-formatter#configuration). |
89 | 88 |
|
| 89 | +The following patterns are considered problems: |
| 90 | + |
| 91 | +```js |
| 92 | +`SELECT 1` |
| 93 | +// Options: [{"ignoreInline":false,"ignoreTagless":false}] |
| 94 | +// Message: Format the query |
| 95 | +// Fixed code: |
| 96 | +// `SELECT |
| 97 | +// 1 |
| 98 | +// ` |
| 99 | + |
| 100 | +`SELECT 2` |
| 101 | +// Options: [{"ignoreInline":false,"ignoreTagless":false},{"spaces":2}] |
| 102 | +// Message: Format the query |
| 103 | +// Fixed code: |
| 104 | +// `SELECT |
| 105 | +// 2 |
| 106 | +// ` |
| 107 | + |
| 108 | +sql`SELECT 3` |
| 109 | +// Options: [{"ignoreInline":false}] |
| 110 | +// Message: Format the query |
| 111 | +// Fixed code: |
| 112 | +// sql`SELECT |
| 113 | +// 3 |
| 114 | +// ` |
| 115 | + |
| 116 | +`SELECT ${'foo'} FROM ${'bar'}` |
| 117 | +// Options: [{"ignoreInline":false,"ignoreTagless":false}] |
| 118 | +// Message: Format the query |
| 119 | +// Fixed code: |
| 120 | +// `SELECT |
| 121 | +// ${'foo'} |
| 122 | +// FROM |
| 123 | +// ${'bar'} |
| 124 | +// ` |
| 125 | +``` |
| 126 | + |
| 127 | +The following patterns are not considered problems: |
| 128 | + |
| 129 | +```js |
| 130 | +sql`SELECT 1` |
| 131 | +// Options: [{"ignoreInline":true}] |
| 132 | + |
| 133 | +`SELECT 2` |
| 134 | +// Options: [{"ignoreTagless":true}] |
| 135 | + |
| 136 | +`SELECT ${'foo'} FROM ${'bar'}` |
| 137 | +// Options: [{"ignoreExpressions":true,"ignoreInline":false,"ignoreTagless":false}] |
| 138 | +``` |
| 139 | + |
| 140 | + |
| 141 | + |
90 | 142 | <a name="eslint-plugin-sql-rules-no-unsafe-query"></a> |
91 | 143 | ### <code>no-unsafe-query</code> |
92 | 144 |
|
@@ -122,8 +174,8 @@ foo`SELECT ${'bar'}` |
122 | 174 | The following patterns are not considered problems: |
123 | 175 |
|
124 | 176 | ```js |
125 | | -// Options: [{"allowLiteral":true}] |
126 | 177 | `SELECT 1` |
| 178 | +// Options: [{"allowLiteral":true}] |
127 | 179 |
|
128 | 180 | sql`SELECT 1` |
129 | 181 |
|
|
0 commit comments