ESLint rules for inline SQL within Template Literals.
Install eslint-plugin-sequel
:
$ npm install eslint-plugin-sequel --save-dev
Add sequel
to the plugins section of your .eslintrc
configuration file.
{
"plugins": ["sequel"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"sequel/function-case": 2,
"sequel/indent": [2, "tab"],
"sequel/max-placeholders": [2, {"max": 3}],
"sequel/no-eol-command": [2, {"allowOnOwnLine": true}],
"sequel/no-shorthand-all": [
2,
{"allowQualified": true, "allowCountAll": true}
],
"sequel/no-unsafe-query": 2,
"sequel/spacing": 2
}
}
-
sequel/function-case
: Makes SQL function names uppercase, e.g. 'SELECT' fixable -
sequel/indent
: Enforces indentation fixable-
'tab'|Number
: Defines the characters to use, where Number is given it uses spaces (default2
).
-
-
sequel/max-placeholders
: Placeholders,?
character, can be hard to read if there are many in the same SQL string.-
max
: Maximum number of placeholders allowed (default3
)
-
-
sequel/no-eol-command
: Avoid ending lines with a SQL command which is always followed by a value.-
allowOnOwnLine
: Permits the command to appear if it is not preceeded by anything, allowing commands to be easily read.
-
-
sequel/no-shorthand-all
: Avoid using the ambiguous shorthand all '*'.-
allowQualified
(Boolean, default:false
): Permits qualified shorthand all e.g.table.*
to get everything from a table. -
allowCountAll
(Boolean, default:false
): Permits withinCOUNT()
e.g.COUNT(*)
.
-
-
sequel/no-unsafe-query
: Checks whether there are potentially any vulnerable SQL'ish template literals, fix by using SQL placeholders or using SQL templating formatter -
sequel/spacing
: Multiple spaces and tabs should only be used for indentation fixable