ESLint plugin · PostgreSQL 17

Lint your SQL the same way you lint everything else.

eslint-plugin-postgresql ships 89 rules that catch real PostgreSQL pitfalls — syntax errors, timezone-naive timestamps, NOT IN against subqueries, missing WHERE on DELETE. Backed by postgresql-eslint-parser so the AST is the same one Postgres itself uses.

Install npm install --save-dev eslint-plugin-postgresql
89
rules
19
recommended as error
46
recommended as warn
WASM
browser playground

Features

  • Real PostgreSQL grammar

    Built on libpg-query — the Postgres server parser compiled to WebAssembly via postgresql-eslint-parser. CTEs, partial indexes, JSON path expressions all parse the same way they would in your database.

  • 22 curated rules

    Each rule has one concern. require-where-in-delete, no-not-in-subquery, prefer-timestamptz, prefer-text-over-varchar — pitfalls every Postgres reviewer eventually flags, encoded as lint diagnostics.

  • One-line flat config

    Spread configs.recommended into your eslint.config.js. The preset binds the parser, plugin, severities and file glob — no separate languageOptions wiring required.

  • Browser playground

    Open /playground in any browser. Parser and rules run entirely in a Web Worker through libpg-query.wasm — your SQL never leaves the tab.

  • Stable messageIds

    Every diagnostic has a stable messageId you can match in suppressions and severity overrides. Renames count as breaking changes.

  • Errors don't bring down the lint run

    Syntax errors surface as a single no-syntax-error diagnostic instead of crashing the linter, so the rest of your SQL files still get analysed.

Drop it into your ESLint config

Spread postgresql.configs.recommended into a flat-config entry and point ESLint at your .sql files. Your editor and CI will lint SQL the same way they lint TypeScript.

See the rules for what fires by default, or try the playground to feel the diagnostics in your hands.

// eslint.config.js
import postgresql from "eslint-plugin-postgresql";

export default [
  {
    files: ["**/*.sql"],
    ...postgresql.configs.recommended,
  },
];

What it covers

Every rule has a single concern. Together they map onto the categories that come up most often in PostgreSQL code review.

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