Why this matters
Aligns the name, type, and constraint columns of every `ColumnDef` row inside a `CREATE TABLE`. Multi-line column definitions and shared-line layouts are skipped because source surgery is unsafe in those shapes.
Examples
Incorrect
CREATE TABLE t (
a TEXT NOT NULL,
b non_blank_text_64[] NOT NULL,
c INTEGER NOT NULL
);Correct
CREATE TABLE t (
a TEXT NOT NULL,
b non_blank_text_64[] NOT NULL,
c INTEGER NOT NULL
);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/align-column-definitions": [
"warn",
{
gap: 2,
},
],
},
},
]; Options
Edit the SQL — only align-column-definitions 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
align-column-definitions — plus no-syntax-error as a safety net.