All rules
Style
postgresql/
Enforce a consistent stance on the `AS` keyword before column aliases in `SELECT`.
Why this matters
PostgreSQL allows `SELECT id user_id`, but the optional `AS` is the SQL-standard form and is far easier to read at a glance — without `AS`, an accidental missing comma silently turns a column into an alias of the previous one. Use the `style` option to enforce either direction.
Examples
Incorrect
SELECT id user_id, name full_name FROM users;Correct
SELECT id AS user_id, name AS full_name FROM users;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-as-for-column-alias": [
"warn",
{
style: "always",
},
],
},
},
]; Options
Edit the SQL — only consistent-as-for-column-alias 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-as-for-column-alias — plus no-syntax-error as a safety net.