All rules
Schema
postgresql/
Enforce a consistent stance on `timestamptz` vs `timestamp` for wall-clock columns.
Why this matters
Two valid stances exist: (a) require `timestamptz` so the database anchors everything to UTC at storage time and converts on read (avoiding the timezone-naive trap of `timestamp`), or (b) forbid `timestamptz` so the type is consistent across a project that treats every timestamp as UTC at the application layer and doesn't want implicit per-session `TimeZone` conversions. Pick one with the `style` option.
Examples
Incorrect
CREATE TABLE t (created_at TIMESTAMP);Correct
CREATE TABLE t (created_at TIMESTAMPTZ);CREATE TABLE t (created_at TIMESTAMP WITH TIME ZONE);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/consistent-timestamptz": [
"warn",
{
style: "always",
},
],
},
},
]; Options
Edit the SQL — only consistent-timestamptz 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
consistent-timestamptz — plus no-syntax-error as a safety net.