
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
sql-lint will do sanity checks on your queries as well as bring errors back from the DB.
If you worry about forgetting WHEREs on a DELETE or borking your data with unexpected characters, then sql-lint is for you.
Read the documentation for a complete walkthrough


npm i -g sql-lint
# or
yarn global add sql-lint
Or download a binary
sql-lint works on files, directories and stdin.
# Will lint all .sql files recursively from the current directory
sql-lint .
# Lints the create-person.sql file
sql-lint create-person.sql
# Lints stdin
echo 'DELETE FROM person;' | sql-lint
sql-lint can also be used within your js/ts files (though admittedly it's stronger as a cli command).
npm i sql-lint
# or
yarn add sql-lint
import sqlLint from 'sql-lint'
// using async/await
const errors = await sqlLint({
sql: 'SELECT my_column FROM my_table',
})
// or using promise
sqlLint({ sql: 'SELECT my_column FROM my_table' }).then(errors => {
for (const error of errors) {
// do something
}
})
If your editor supports external tools, then it supports sql-lint.
Below is the list that have direct support for sql-lint either through plugins or configuration.
| Editor | Plugin |
|---|---|
| Neovim | Ale |
| Vim | Ale |
| VS Code | Inline SQL |
A quick rundown of the checks is below but you should read the documentation for an exhaustive list.
sql-lint comes with its own suite of checks. It
also returns any errors from the SQL server you have connected to. Generally
you'll find that the errors from sql-lint are more informative than those from
the server. That said, you will still want errors from the server as it covers
more cases and will catch things that sql-lint does not.
Shown when a query has an unbalanced amount of parentheses.
test/test-files//test.sql:16 [sql-lint: unmatched-parentheses] Unmatched parentheses.
Shown when a DELETE statement is missing a WHERE clause.
test/test-files/test.sql:20 [sql-lint: missing-where] DELETE statement missing WHERE clause.
Shown when an invalid option is given to the DROP statement.
test/test-files/test.sql:22 [sql-lint: invalid-drop-option] Option 'thing' is not a valid option, must be one of '["database","event","function","index","logfile","procedure","schema","server","table","view","tablespace","trigger"]'.
Shown when an invalid option is given to the CREATE statement.
:24 [sql-lint: invalid-create-option] Option 'test' is not a valid option, must be one of '["algorithm","database","definer","event","function","index","or","procedure","server","table","tablespace","temporary","trigger","user","unique","view"]'.
Shown when an invalid option is given to the TRUNCATE statement.
test/test-files/test.sql:26 [sql-lint: invalid-truncate-option] Option 'something' is not a valid option, must be one of '["table"]'.
Shown when an invalid option is given to the ALTER statement.
test/test-files/test.sql:28 [sql-lint: invalid-alter-option] Option 'mlady' is not a valid option, must be one of '["column","online","offline","ignore","database","event","function","procedure","server","table","tablespace","view"]'.
Shown when there are unsupported/unusual* code points in your code.
*This check came about whilst working Microsoft Excel. Microsoft likes to add a lot of zany characters which can subtly break your data without you realising.
test/test-files//test.sql:30 [sql-lint: odd-code-point] Unexpected code point.
Shown when you specify something other than a number to the LIMIT statement.
test/test-files//test.sql:32 [sql-lint: invalid-limit-quantifier] Argument 'test' is not a valid quantifier for LIMIT clause.
Shown when the string sp_ or tbl_ is present in the query.
test/test-files/test.sql:34 [sql-lint: hungarian-notation] Hungarian notation present in query
Shown when a query has trailing whitespace.
test/test-files/test.sql:34 [sql-lint: trailing-whitespace] Trailing whitespace
To find out more, read the documentation
FAQs
An intelligent SQL linter and checker
The npm package sql-lint receives a total of 1,276 weekly downloads. As such, sql-lint popularity was classified as popular.
We found that sql-lint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.