eslint/one-var Style
What it does
Enforces variables to be declared either together or separately.
Why is this bad?
Consistent declaration grouping makes variable lifetimes and initialization patterns easier to scan. This rule can require one declaration per scope, one declarator per statement, or grouping only consecutive declarations.
Examples
Examples of incorrect code for this rule:
js
var foo = 1;
var bar = 2;Examples of correct code for this rule:
js
var foo = 1,
bar = 2;Configuration
Enforces consistent grouping of variable declarations.
type: object
How to use
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"one-var": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"one-var": "error",
},
});bash
oxlint --deny one-varVersion
This rule was added in vnext.
