Why this matters
`CASCADE` silently removes dependent objects — foreign keys, views, sequences. The fix is to list dependents explicitly. The rule is scoped to `DROP TABLE`; other `DROP ... CASCADE` variants are out of scope.
Examples
Incorrect
DROP TABLE users CASCADE;Correct
DROP TABLE users;DROP TABLE users RESTRICT;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-drop-table-cascade": "warn",
},
},
]; Options
Edit the SQL — only no-drop-table-cascade 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-drop-table-cascade — plus no-syntax-error as a safety net.