{"id":13498712,"url":"https://github.com/joereynolds/sql-lint","last_synced_at":"2025-05-14T08:08:24.279Z","repository":{"id":37493054,"uuid":"140703993","full_name":"joereynolds/sql-lint","owner":"joereynolds","description":"An SQL linter","archived":false,"fork":false,"pushed_at":"2025-03-12T15:16:15.000Z","size":8347,"stargazers_count":444,"open_issues_count":58,"forks_count":40,"subscribers_count":8,"default_branch":"typescript","last_synced_at":"2025-05-13T03:49:31.066Z","etag":null,"topics":["lint","linter","mysql","postgres","postgresql","sql","sql-lint"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joereynolds.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-12T11:26:30.000Z","updated_at":"2025-05-13T01:37:43.000Z","dependencies_parsed_at":"2024-06-18T21:32:52.465Z","dependency_job_id":"eda3df3c-d737-4282-9f8f-a1da814b0490","html_url":"https://github.com/joereynolds/sql-lint","commit_stats":{"total_commits":386,"total_committers":14,"mean_commits":"27.571428571428573","dds":0.4585492227979274,"last_synced_commit":"0908c5b19e5275be9de339e2d26d3057526687f1"},"previous_names":["joereynolds/gauxilium"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joereynolds%2Fsql-lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joereynolds%2Fsql-lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joereynolds%2Fsql-lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joereynolds%2Fsql-lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joereynolds","download_url":"https://codeload.github.com/joereynolds/sql-lint/tar.gz/refs/heads/typescript","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253870829,"owners_count":21976612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lint","linter","mysql","postgres","postgresql","sql","sql-lint"],"created_at":"2024-07-31T21:00:41.332Z","updated_at":"2025-05-14T08:08:19.264Z","avatar_url":"https://github.com/joereynolds.png","language":"TypeScript","readme":"# sql-lint\n\n`sql-lint` will do sanity checks on your queries as well as bring errors back from the DB.\nIf you worry about forgetting `WHERE`s on a `DELETE` or borking your data with unexpected characters, then `sql-lint` is for you.\n\n[Read the documentation for a complete walkthrough](https://sql-lint.readthedocs.io/en/latest/files/introduction.html)\n\n![Imgur](https://i.imgur.com/rJ3h34b.png)\n\n![Imgur](https://i.imgur.com/nqi1MnT.gif)\n\n\n## Installation\n\n```\nnpm i -g sql-lint\n# or\nyarn global add sql-lint\n```\n\nOr download a [binary](https://github.com/joereynolds/sql-lint/releases)\n\n## Usage\n\n`sql-lint` works on files, directories and stdin.\n\n```\n# Will lint all .sql files recursively from the current directory\nsql-lint .\n\n# Lints the create-person.sql file\nsql-lint create-person.sql\n\n# Lints stdin\necho 'DELETE FROM person;' | sql-lint\n```\n\n## Programmatically\n\n`sql-lint` can also be used within your js/ts files (though admittedly it's stronger as a cli command).\n\n```\nnpm i sql-lint\n# or\nyarn add sql-lint\n```\n\n```\nimport sqlLint from 'sql-lint'\n\n// using async/await\n\nconst errors = await sqlLint({\n  sql: 'SELECT my_column FROM my_table',\n})\n\n// or using promise\n\nsqlLint({ sql: 'SELECT my_column FROM my_table' }).then(errors =\u003e {\n  for (const error of errors) {\n    // do something\n  }\n})\n```\n\n## Supported Editors\n\nIf your editor supports external tools, then it supports `sql-lint`.\nBelow is the list that have direct support for `sql-lint` either through plugins or configuration.\n\n| Editor      | Plugin |\n| ----------- | ----------- |\n| Neovim      | [Ale](https://github.com/dense-analysis/ale/)       |\n| Vim         | [Ale](https://github.com/dense-analysis/ale/)        |\n| VS Code     | [Inline SQL](https://marketplace.visualstudio.com/items?itemName=qufiwefefwoyn.inline-sql-syntax)        |\n\n## Checks\n\nA quick rundown of the checks is below but you should [read the documentation](https://sql-lint.readthedocs.io/en/latest/files/checks.html) \nfor an exhaustive list.\n\n`sql-lint` comes with its own suite of checks. It\nalso returns any errors from the SQL server you have connected to. Generally\nyou'll find that the errors from `sql-lint` are more informative than those from\nthe server. That said, you will still want errors from the server as it covers\nmore cases and will catch things that `sql-lint` does not.\n\n\u003cdetails\u003e\n  \u003csummary\u003eunmatched-parentheses\u003c/summary\u003e\n\nShown when a query has an unbalanced amount of parentheses.\n\n```\ntest/test-files//test.sql:16 [sql-lint: unmatched-parentheses] Unmatched parentheses.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003emissing-where\u003c/summary\u003e\n\nShown when a `DELETE` statement is missing a `WHERE` clause.\n\n```\ntest/test-files/test.sql:20 [sql-lint: missing-where] DELETE statement missing WHERE clause.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003einvalid-drop-option\u003c/summary\u003e\n\nShown when an invalid option is given to the `DROP` statement.\n\n```\ntest/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\"]'.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003einvalid-create-option\u003c/summary\u003e\n\nShown when an invalid option is given to the `CREATE` statement.\n\n```\n: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\"]'.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003einvalid-truncate-option\u003c/summary\u003e\n\nShown when an invalid option is given to the `TRUNCATE` statement.\n\n```\ntest/test-files/test.sql:26 [sql-lint: invalid-truncate-option] Option 'something' is not a valid option, must be one of '[\"table\"]'.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003einvalid-alter-option\u003c/summary\u003e\n\nShown when an invalid option is given to the `ALTER` statement.\n\n```\ntest/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\"]'.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n  \u003csummary\u003eodd-code-point\u003c/summary\u003e\n\nShown when there are unsupported/unusual* code points in your code.\n\n*\u003csmall\u003eThis check came about whilst working Microsoft Excel. Microsoft likes to\nadd a lot of zany characters which can subtly break your data without you\nrealising.\u003c/small\u003e\n\n```\ntest/test-files//test.sql:30 [sql-lint: odd-code-point] Unexpected code point.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n  \u003csummary\u003e\n    invalid-limit-quantifier\n  \u003c/summary\u003e\n\nShown when you specify something other than a number to the `LIMIT` statement.\n\n```\ntest/test-files//test.sql:32 [sql-lint: invalid-limit-quantifier] Argument 'test' is not a valid quantifier for LIMIT clause.\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\nhungarian-notation\n\u003c/summary\u003e\n\nShown when the string `sp_` or `tbl_` is present in the query.\n\n```\ntest/test-files/test.sql:34 [sql-lint: hungarian-notation] Hungarian notation present in query\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\ntrailing-whitespace\n\u003c/summary\u003e\n\nShown when a query has trailing whitespace.\n\n```\ntest/test-files/test.sql:34 [sql-lint: trailing-whitespace] Trailing whitespace\n```\n\u003c/details\u003e\n\n## Documentation\n\nTo find out more, [read the documentation](https://sql-lint.readthedocs.io/)\n","funding_links":[],"categories":["Supported Linters","TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoereynolds%2Fsql-lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoereynolds%2Fsql-lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoereynolds%2Fsql-lint/lists"}