All rules

Style

postgresql/prefer-keyword-case

Enforce a consistent case (upper or lower) for SQL keywords.

  • Type layout
  • Recommended off
  • Fixable yes

Why this matters

Operates on the SQL keyword tokens emitted by the parser; identifiers, string literals, and comments are left alone. The `types` option separately controls how built-in type names (`int`, `text`, `varchar`) are cased — defaulting to `skip` so user-defined type names like `ulid` (which the rule cannot touch) don't end up case-mismatched against built-ins.

Examples

Incorrect

Incorrect
select id, name from users where active = true limit 10;

Correct

Correct
SELECT id, name FROM users WHERE active = TRUE LIMIT 10;

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/prefer-keyword-case": [
        "warn",
        {
          case: "upper",
          types: "skip",
        },
      ],
    },
  },
];

Options

case "upper" | "lower" default: "upper"
Target case for SQL keywords.
types "upper" | "lower" | "skip" default: "skip"
How to case built-in type names. `skip` leaves them as written so they don't case-mismatch against user-defined types the rule cannot touch.
Try this rule

Edit the SQL — only prefer-keyword-case 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 prefer-keyword-case — 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