Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upIgnore some rules? #802
Comments
This comment has been minimized.
This comment has been minimized.
|
I cannot google some document about these, maybe there is some configuration in like
|
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Mar 1, 2017
|
Or using eslint ignore comments like /* eslint-disable prefer-template */
db.none(
'UPDATE users SET "Col1" = ${col1}, ' +
' "Col2" = ${col2}, ' +
' "col3" = ${col3}, ' +
'WHERE col3 = ${col3}', goodTable)
/* eslint-enable prefer-template */ |
This comment has been minimized.
This comment has been minimized.
|
Thanks @tunnckoCore, but that's a lots of lines of these query in my codes, |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Mar 1, 2017
|
Why lots of lines? If you have more than 2-3-4 rules to ignore for the whole file maybe Standard isn't your thing, don't know. You can define the comment at the top of the file to globally disable these specific rules that you want and it's not needed to re-enable them later. |
This comment has been minimized.
This comment has been minimized.
|
Thanks @tunnckoCore, I think I can disable them at the top of file. |
Asoul
closed this
Mar 1, 2017
This comment has been minimized.
This comment has been minimized.
|
Might I add it might be a good idea not to ignore import dedent from 'dedent'
db.none(dedent `
UPDATE users SET
"Col1" = \${col1},
"Col2" = \${col2},
"col3" = \${col3},
WHERE col3 = \${col3}
`, goodTable)
// dedent is optional, of course |
This comment has been minimized.
This comment has been minimized.
|
Thanks @rstacruz, that's more clean and without commented line, I like it |
This comment has been minimized.
This comment has been minimized.
vitaly-t
commented
Mar 2, 2017
•
|
Hi guys, I am the author of pg-promise, and just wanted to point out once again at the flexibility of the formatting syntax when it comes to the use of Named Parameters. If the ES6 template strings is your preferred way to declare queries, then as per the documentation, you can instead use But the best way to organize all your SQL is via external SQL files, via Query Files, where you can also use Also see pg-promise-demo for a comprehensive example ;) |
This comment has been minimized.
This comment has been minimized.
|
Thanks @vitaly-t, |
This comment has been minimized.
This comment has been minimized.
nicholaswmin
commented
Aug 28, 2017
•
|
@rstacruz Unrelated but doesn't your proposed template literal syntax introduce a huge SQL injection risk? |
This comment has been minimized.
This comment has been minimized.
vitaly-t
commented
Aug 28, 2017
•
|
@nicholaswmin it doesn't, because all literals are escaped correctly, preventing the injection. For example, every string goes through pgp.as.text for that, and so on, according to the type. |
Asoul commentedMar 1, 2017
Hi,
I use pg-promise, and some SQL rules looks like:
The function need to pass the string with
${}, and I cannot use `` to quote the string, because these variable is not local variables, they aregoodTable's attributes. Therefore, I got prefer-template error from this, can I ignore this warning?Thanks!