newline-after-var

此规则在 ESLint v4.0.0 中已弃用,并被 padding-line-between-statements 规则取代。

到今天为止,将变量声明与其余代码分开还没有一致性。一些开发人员在 var 语句和其余代码之间留了一个空行,例如:

var foo;

// do something with foo

而其他人根本不会留下任何空的换行符。

var foo;
// do something with foo

问题是当这些开发人员在一个项目中一起工作时。此规则强制执行编码样式,在 varletconst 语句之后允许或禁止空换行符。它有助于代码在整个项目中看起来一致。

规则详情

此规则强制执行编码风格,其中在 varletconst 语句之后需要或不允许空行,以在整个项目中实现一致的编码风格。

选项

gOiAZnAcPh/ECcp3u5icNMdXUzIbNOaiXIO+Btuf3/uLdKlAq+lBQREzJgxgBi5T

    ZHEo+fyWkqX8M1nCLBPsbNH0uCKyN1dKchjEW8qJJ3BdZxLvY40N8t8gbeq98gqDC46iOW1xozD00iWcHIenFkF3KUX2FAAfUrBPIhUr5loLIA/HUyYnIsjuTqD/XLAQNPPj5I42V+j4z3H0IbvzOv3ppIcGLMB9+dyh/pUh1NHQ1IsHKN4NNMRmSgj+dJkb1FpIgem0qEzNcm8uNeGRyeEtgdR72zjjgGnVX2bOoy6YYqcsfogLQkjGSG/29g+xnuYy6mp9+o8SKpm6tz1s3RNxh7IquIPHIwP8ZrYmnBgz9bZf5yRMod/kXzbF8cuR3aboPua2b/jK9OpCXpZcV7O2G0YBx0TnSny1VgrgIgSckEPCb6KdDdjuFKm7ETWKRFVlTfmpSaO0Llm60cyLd2b+jAil6EpUmCCk0FNyurx8ZY2wWS3TScJ06YiAFFcWJTl8GS+TTOtR+7WA21hm2g==

always

qwlXDFeOGAub+EzAJFeRQR6Fg0FHwA/8XISFanQ7GMamCcDgR2wYFUVl1bBKX+3MtEAwT7kZhfMvS5ghjnpje4J52IjWTge7HerQiGed0Co=

/*eslint newline-after-var: ["error", "always"]*/
/*eslint-env es6*/

var greet = "hello,",
    name = "world";
console.log(greet, name);

let greet = "hello,",
    name = "world";
console.log(greet, name);

var greet = "hello,";
const NAME = "world";
console.log(greet, NAME);

var greet = "hello,";
var name = "world";
// var name = require("world");
console.log(greet, name);

qwlXDFeOGAub+EzAJFeRQR6Fg0FHwA/8XISFanQ7GMamCcDgR2wYFUVl1bBKX+3MMllUwRqZZa2olTzyvYPBeWwkPwV9gCYp5WHl5eS4DjU=

/*eslint newline-after-var: ["error", "always"]*/
/*eslint-env es6*/

var greet = "hello,",
    name = "world";

console.log(greet, name);

let greet = "hello,",
    name = "world";

console.log(greet, name);

var greet = "hello,";
const NAME = "world";

console.log(greet, NAME);

var greet = "hello,";
var name = "world";
// var name = require("world");

console.log(greet, name);

never

yqV+SV60QvsOsYXkYvZsZS7WQXw6pPZQT+2Jc45fpPGJ9XMYDapADCnYMkJcWohUyjYf5OWYbXTB1PtlCuwdgsZ9sLGXfE1+NcyXgciDiuA=

/*eslint newline-after-var: ["error", "never"]*/
/*eslint-env es6*/

var greet = "hello,",
    name = "world";

console.log(greet, name);

let greet = "hello,",
    name = "world";

console.log(greet, name);

var greet = "hello,";
const NAME = "world";

console.log(greet, NAME);

var greet = "hello,";
var name = "world";
// var name = require("world");

console.log(greet, name);

yqV+SV60QvsOsYXkYvZsZS7WQXw6pPZQT+2Jc45fpPESLfOk8X2U4OSBulxe5pgXr9y18oNEJdw5rpbnfWY29skTj6fGWCDUPHL555agv9I=

/*eslint newline-after-var: ["error", "never"]*/
/*eslint-env es6*/

var greet = "hello,",
    name = "world";
console.log(greet, name);

let greet = "hello,",
    name = "world";
console.log(greet, name);

var greet = "hello,";
const NAME = "world";
console.log(greet, NAME);

var greet = "hello,";
var name = "world";
// var name = require("world");
console.log(greet, name);