All rules
Style
postgresql/
Enforce a consistent stance on `x BETWEEN a AND b` vs `x >= a AND x <= b`.
Why this matters
`BETWEEN` is the SQL-standard inclusive-range form and is shorter to read. The rule only flags inclusive comparisons (`>=` / `<=`) where both bounds reference the same expression — strict inequalities are not equivalent to `BETWEEN` and are out of scope. Flip with the `style` option for projects that prefer explicit comparisons.
Examples
Incorrect
SELECT * FROM t WHERE x >= 1 AND x <= 10;Correct
SELECT * FROM t WHERE x BETWEEN 1 AND 10;SELECT * FROM t WHERE x > 1 AND x < 10; -- strict bounds: out of scopeConfigure 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-between-over-and": [
"warn",
{
style: "always",
},
],
},
},
]; Options
Edit the SQL — only consistent-between-over-and 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-between-over-and — plus no-syntax-error as a safety net.