All rules
Safety
postgresql/
Disallow `CREATE RULE`; it is effectively deprecated in favor of triggers and updatable views.
Why this matters
`CREATE RULE` rewrites the query tree at planning time, which interacts poorly with prepared statements, COPY, and partitioning. The PostgreSQL community considers the rule system effectively deprecated; use a trigger or an updatable view instead.
Examples
Incorrect
CREATE RULE noop AS ON UPDATE TO t DO INSTEAD NOTHING;Correct
CREATE TRIGGER t_trg BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION t_trg_fn();CREATE VIEW v AS SELECT * 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/no-rule": "warn",
},
},
]; Options
Edit the SQL — only no-rule 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
no-rule — plus no-syntax-error as a safety net.