All rules
Style
postgresql/
Enforce a consistent case for SQL/PL/pgSQL keywords inside PL/pgSQL bodies.
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
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
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
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.
Diagnostics
No issues found.
2 rules enabled.
Rule under test
plpgsql-keyword-case — plus no-syntax-error as a safety net.