key-spacing
currently: "key-spacing": "off"
- beforeColon
Examples of incorrect code for this rule with the default { "beforeColon": false }
option:
/*eslint key-spacing: ["error", { "beforeColon": false }]*/ var obj = { "foo" : 42 };
Examples of correct code for this rule with the default { "beforeColon": false }
option:
/*eslint key-spacing: ["error", { "beforeColon": false }]*/ var obj = { "foo": 42 };
afterColon
Examples of incorrect code for this rule with the default { "afterColon": true }
option:
/*eslint key-spacing: ["error", { "afterColon": true }]*/ var obj = { "foo":42 };
Examples of correct code for this rule with the default { "afterColon": true }
option:
/*eslint key-spacing: ["error", { "afterColon": true }]*/ var obj = { "foo": 42 };
padding-line-between-statements
one or more blank lines are required between a variable declaration and a
return
statement.
Examples of incorrect code for the [{ blankLine: "always", prev: "*", next: "return" }]
configuration:
/*eslint padding-line-between-statements: [ "error", { blankLine: "always", prev: "*", next: "return" } ]*/ function foo() { bar(); return; }
Examples of correct code for the [{ blankLine: "always", prev: "*", next: "return" }]
configuration:
/*eslint padding-line-between-statements: [ "error", { blankLine: "always", prev: "*", next: "return" } ]*/ function foo() { bar(); return; } function foo() { return; }
This configuration would require blank lines after every sequence of variable declarations, like the newline-after-var rule.
Examples of incorrect code for the [{ blankLine: "always", prev: ["const", "let", "var"], next: "*"}, { blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]}]
configuration:
/*eslint padding-line-between-statements: [ "error", { blankLine: "always", prev: ["const", "let", "var"], next: "*"}, { blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]} ]*/ function foo() { var a = 0; var b = 0; bar(); } function foo() { let a = 0; const b = 0; bar(); } function foo() { const a = 0; const b = 0; bar(); }
Examples of correct code for the [{ blankLine: "always", prev: ["const", "let", "var"], next: "*"}, { blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]}]
configuration:
/*eslint padding-line-between-statements: [ "error", { blankLine: "always", prev: ["const", "let", "var"], next: "*"}, { blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]} ]*/ function foo() { var a = 0; var b = 0; bar(); } function foo() { let a = 0; const b = 0; bar(); } function foo() { const a = 0; const b = 0; bar(); }
comma-dangle
always-multiline
Examples of incorrect code for this rule with the "always-multiline"
option:
/*eslint comma-dangle: ["error", "always-multiline"]*/ var foo = { bar: "baz", qux: "quux" }; var foo = { bar: "baz", qux: "quux", }; var arr = [1,2,]; var arr = [1, 2,]; var arr = [ 1, 2 ]; foo({ bar: "baz", qux: "quux" });
Examples of correct code for this rule with the "always-multiline"
option:
/*eslint comma-dangle: ["error", "always-multiline"]*/ var foo = { bar: "baz", qux: "quux", }; var foo = {bar: "baz", qux: "quux"}; var arr = [1,2]; var arr = [1, 2]; var arr = [ 1, 2, ]; foo({ bar: "baz", qux: "quux", });
react/jsx-one-expression-per-line
Examples of incorrect code for this rule with ["error", { "allow": "literal" }] option:
/* "react/jsx-one-expression-per-line": ["error", { "allow": "literal" }] */ <App><Hello /></App> <App><Hello /> </App> <App> <Hello> </Hello></App> <App> <Hello /> World </App>
Examples of correct code for this rule with the default { "beforeColon": false }
option:
<App>Hello</App>