Why this matters
Every top-level statement must end with `;`. The check is file-level: it inspects the trailing token of the source rather than the per-statement range, which avoids the libpg-query quirk where the last statement's `range[1]` can point mid-token. SQL in a `sql` template (or any other SQL a processor carves out of a non-SQL file, such as a Markdown code block) is not checked: query builders splice templates into each other, where a `;` would end the composed statement early.
Examples
Incorrect
SELECT id FROM usersCorrect
SELECT id FROM users;Configure it
// eslint.config.js
import postgresql from "eslint-plugin-postgresql";
export default [
{
files: ["**/*.sql"],
languageOptions: {
parser: postgresql.configs.recommended.languageOptions.parser,
},
plugins: { postgresql },
rules: {
"postgresql/require-trailing-semicolon": "warn",
},
},
]; Options
Edit the SQL — only require-trailing-semicolon is enabled.
Pre-filled with the first incorrect example. Toggle off in the rule shelf to see how the diagnostic disappears.
Diagnostics
No issues found.
2 rules enabled.
Rule under test
require-trailing-semicolon — plus no-syntax-error as a safety net.