All rules
Style
postgresql/
Prefer SQL-standard `CURRENT_TIMESTAMP` over `now()` / `LOCALTIMESTAMP`.
Why this matters
`CURRENT_TIMESTAMP` is portable across SQL engines, while `now()` is PostgreSQL-only. The rule also flags `LOCALTIMESTAMP` / `LOCALTIME` and rewrites them to `CURRENT_TIMESTAMP` / `CURRENT_TIME` — the `LOCAL*` variants return the timezone-naive `timestamp` / `time` types, which is rarely what application code actually wants.
Examples
Incorrect
INSERT INTO events (created_at) VALUES (now());SELECT LOCALTIMESTAMP, LOCALTIME FROM t;Correct
INSERT INTO events (created_at) VALUES (CURRENT_TIMESTAMP);SELECT CURRENT_TIMESTAMP, CURRENT_TIME FROM t;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-current-timestamp-over-now": "warn",
},
},
]; Options
Edit the SQL — only prefer-current-timestamp-over-now 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
prefer-current-timestamp-over-now — plus no-syntax-error as a safety net.