one-var-declaration-per-line

要求或禁止在变量声明周围换行

一些该规则报告的问题可以通过 --fix 命令行选项 自动修复

一些开发人员在同一行声明多个 var 语句:

var foo, bar, baz;

其他人更喜欢每行声明一个 var。

var foo,
    bar,
    baz;

在项目的代码库中保持其中一种风格有助于保持代码的一致性。

规则详情

83zYKxK3rJGKdNnmyJ0gSBeInXNHut43CjSYeorSaS2GGPuidkbntbOnhqCXX1QFhZPok1z2Yr4hbrNxV8wrtICCAOBhV42jm7tQU7/JHET6Ic2vx3NpMXBnUAEIS03AgIbODl6r4fJ9wRh5Et+R+8mjq7nWpCGn57muXE4vu4Zt4B4IjI+wE1iKS/gIUje0

选项

zohwWkHql7+d6FhyU+yJZFjZ++1UOUWq0e20BbEG68/347+2cYWYk9U7aV5g9YcV

    Z8GoqN+Rx5PXG2UZyYkQq4Y6lu/vgQbDm78tsyBVHIuB4LcWpBKnKizs4x3J65yDmuW2IiHDeRLey8MuWfz9sZpyvsBhWsTc1+XsWLWEH/sONCnfmDWBs3swCVzlnq25VNZMO1e8nnzMmZ7J6gsSxpf+vEBaEfHs/gZW+/cKyN3NYtr47WtDLELU3X1WjYldAJQB9RgWTcMWedyomw8V2A==

initializations

EKtVsMjWQsWIsgwyRUkFIyl1UPjygEAg5aOshMVw4dqbZdIha7eQuL7wNdoqoHy21RceT9BhUTTYFFMQwr4nZfPOpQxsHRYI4tSeooWjlELYJeq4jmzokt0y3EKfqrY8

/*eslint one-var-declaration-per-line: ["error", "initializations"]*/
/*eslint-env es6*/

var a, b, c = 0;

let a,
    b = 0, c;

EKtVsMjWQsWIsgwyRUkFIyl1UPjygEAg5aOshMVw4dqbZdIha7eQuL7wNdoqoHy2ww9ji06j/hJnondZ7ykVkxPvNiMAg15Ftg+V7UWhgOOd0oE134gCi99YRAb1IIv8

/*eslint one-var-declaration-per-line: ["error", "initializations"]*/
/*eslint-env es6*/

var a, b;

let a,
    b;

let a,
    b = 0;

always

CDruO8STtfiPEOKFpJL7OJJox+YddusmGf38HTs7jv84liY8fZPjgYsWkSsR4eofqkCNd0jzn2/u1YnKfR33v1etN1UTVC1qjaAUfs7ace0=

/*eslint one-var-declaration-per-line: ["error", "always"]*/
/*eslint-env es6*/

var a, b;

let a, b = 0;

const a = 0, b = 0;

CDruO8STtfiPEOKFpJL7OJJox+YddusmGf38HTs7jv8CQ6YIqBDR+swYdZEov+R3B7bs+CA+MhXWc/Fz0lyxCfiwup7FBzB/XOGknATlzdA=

/*eslint one-var-declaration-per-line: ["error", "always"]*/
/*eslint-env es6*/

var a,
    b;

let a,
    b = 0;