All rules

Style

postgresql/require-trailing-semicolon

Require a trailing `;` after every top-level SQL statement.

  • Type layout
  • Recommended off
  • Fixable yes

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.

Examples

Incorrect

Incorrect
SELECT id FROM users

Correct

Correct
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

This rule has no options.

Try this rule

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.

0 errors 0 warnings parse 0ms · rules 0ms
Diagnostics

No issues found.

2 rules enabled.

Rule under test require-trailing-semicolon — plus no-syntax-error as a safety net.
eslint-plugin-postgresql

An ESLint plugin that lints .sql files with real PostgreSQL grammar and a curated set of best-practice rules.

© 2026 eslint-plugin-postgresql contributors Built on libpg-query · PostgreSQL 17