All rules

Style

postgresql/plpgsql-keyword-case

Enforce a consistent case for SQL/PL/pgSQL keywords inside PL/pgSQL bodies.

  • Type layout
  • Recommended off
  • Fixable yes

Why this matters

Applies only inside `LANGUAGE plpgsql` bodies (other languages are left alone). String literals, dollar-quoted strings, and comments are skipped.

Examples

Incorrect

Incorrect
CREATE FUNCTION foo() RETURNS void AS $$
declare
  user_count integer;
begin
  if user_count is null then
    raise notice 'hello';
  end if;
end;
$$ LANGUAGE plpgsql;

Correct

Correct
CREATE FUNCTION foo() RETURNS void AS $$
DECLARE
  user_count integer;
BEGIN
  IF user_count IS NULL THEN
    RAISE NOTICE 'hello';
  END IF;
END;
$$ LANGUAGE plpgsql;

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

Options

case "upper" | "lower" default: "upper"
Target case for PL/pgSQL keywords.
Try this rule

Edit the SQL — only plpgsql-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 plpgsql-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