Why this matters
Same rationale as `consistent-as-for-column-alias`: explicit `AS` makes the alias unmistakable and helps human readers spot stray missing commas in the FROM list. Flip with the `style` option if your project prefers the bare form.
Examples
Incorrect
SELECT u.id FROM users u WHERE u.active = TRUE;Correct
SELECT u.id FROM users AS u WHERE u.active = TRUE;SELECT u.id FROM users WHERE active = TRUE;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-table-alias": [
"warn",
{
style: "always",
},
],
},
},
]; Options
Edit the SQL — only consistent-as-for-table-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-table-alias — plus no-syntax-error as a safety net.