All rules
Schema
postgresql/
Require an explicit precision and scale on `NUMERIC` / `DECIMAL` columns.
Why this matters
Bare `NUMERIC` accepts unbounded magnitude — useful only if you really do mean 'arbitrary precision', which is rarely the case in application schemas. Declare `NUMERIC(precision, scale)` so the column documents its domain.
Examples
Incorrect
CREATE TABLE products (price numeric);CREATE TABLE products (price decimal);Correct
CREATE TABLE products (price numeric(10, 2));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-numeric-without-precision": "warn",
},
},
]; Options
Edit the SQL — only no-numeric-without-precision 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-numeric-without-precision — plus no-syntax-error as a safety net.