Showing 1,297 of 1,297 total issues
Expected indentation of 6 spaces but found 8. Open
const descriptor = Object.getOwnPropertyDescriptor(targetObj, key);
- Read upRead up
- Exclude checks
enforce consistent indentation (indent)
There are several common guidelines which require specific indentation of nested blocks and statements, like:
function hello(indentSize, type) {
if (indentSize === 4 && type !== 'tab') {
console.log('Each next indentation will increase on 4 spaces');
}
}
These are the most common scenarios recommended in different style guides:
- Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
- Tabs: jQuery
- Four spaces: Crockford
Rule Details
This rule enforces a consistent indentation style. The default style is 4 spaces
.
Options
This rule has a mixed option:
For example, for 2-space indentation:
{
"indent": ["error", 2]
}
Or for tabbed indentation:
{
"indent": ["error", "tab"]
}
Examples of incorrect code for this rule with the default options:
/*eslint indent: "error"*/
if (a) {
b=c;
function foo(d) {
e=f;
}
}
Examples of correct code for this rule with the default options:
/*eslint indent: "error"*/
if (a) {
b=c;
function foo(d) {
e=f;
}
}
This rule has an object option:
-
"SwitchCase"
(default: 0) enforces indentation level forcase
clauses inswitch
statements -
"VariableDeclarator"
(default: 1) enforces indentation level forvar
declarators; can also take an object to define separate rules forvar
,let
andconst
declarations. -
"outerIIFEBody"
(default: 1) enforces indentation level for file-level IIFEs. -
"MemberExpression"
(off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments) -
"FunctionDeclaration"
takes an object to define rules for function declarations.-
parameters
(off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string"first"
indicating that all parameters of the declaration must be aligned with the first parameter. -
body
(default: 1) enforces indentation level for the body of a function declaration.
-
-
"FunctionExpression"
takes an object to define rules for function expressions.-
parameters
(off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string"first"
indicating that all parameters of the expression must be aligned with the first parameter. -
body
(default: 1) enforces indentation level for the body of a function expression.
-
-
"CallExpression"
takes an object to define rules for function call expressions.-
arguments
(off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string"first"
indicating that all arguments of the expression must be aligned with the first argument.
-
-
"ArrayExpression"
(default: 1) enforces indentation level for elements in arrays. It can also be set to the string"first"
, indicating that all the elements in the array should be aligned with the first element. -
"ObjectExpression"
(default: 1) enforces indentation level for properties in objects. It can be set to the string"first"
, indicating that all properties in the object should be aligned with the first property.
Level of indentation denotes the multiple of the indent specified. Example:
- Indent of 4 spaces with
VariableDeclarator
set to2
will indent the multi-line variable declarations with 8 spaces. - Indent of 2 spaces with
VariableDeclarator
set to2
will indent the multi-line variable declarations with 4 spaces. - Indent of 2 spaces with
VariableDeclarator
set to{"var": 2, "let": 2, "const": 3}
will indent the multi-line variable declarations with 4 spaces forvar
andlet
, 6 spaces forconst
statements. - Indent of tab with
VariableDeclarator
set to2
will indent the multi-line variable declarations with 2 tabs. - Indent of 2 spaces with
SwitchCase
set to0
will not indentcase
clauses with respect toswitch
statements. - Indent of 2 spaces with
SwitchCase
set to1
will indentcase
clauses with 2 spaces with respect toswitch
statements. - Indent of 2 spaces with
SwitchCase
set to2
will indentcase
clauses with 4 spaces with respect toswitch
statements. - Indent of tab with
SwitchCase
set to2
will indentcase
clauses with 2 tabs with respect toswitch
statements. - Indent of 2 spaces with
MemberExpression
set to0
will indent the multi-line property chains with 0 spaces. - Indent of 2 spaces with
MemberExpression
set to1
will indent the multi-line property chains with 2 spaces. - Indent of 2 spaces with
MemberExpression
set to2
will indent the multi-line property chains with 4 spaces. - Indent of 4 spaces with
MemberExpression
set to0
will indent the multi-line property chains with 0 spaces. - Indent of 4 spaces with
MemberExpression
set to1
will indent the multi-line property chains with 4 spaces. - Indent of 4 spaces with
MemberExpression
set to2
will indent the multi-line property chains with 8 spaces.
tab
Examples of incorrect code for this rule with the "tab"
option:
/*eslint indent: ["error", "tab"]*/
if (a) {
b=c;
function foo(d) {
e=f;
}
}
Examples of correct code for this rule with the "tab"
option:
/*eslint indent: ["error", "tab"]*/
if (a) {
/*tab*/b=c;
/*tab*/function foo(d) {
/*tab*//*tab*/e=f;
/*tab*/}
}
SwitchCase
Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 }
options:
/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
switch(a){
case "a":
break;
case "b":
break;
}
Examples of correct code for this rule with the 2, { "SwitchCase": 1 }
option:
/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
switch(a){
case "a":
break;
case "b":
break;
}
VariableDeclarator
Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 }
options:
/*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
/*eslint-env es6*/
var a,
b,
c;
let a,
b,
c;
const a = 1,
b = 2,
c = 3;
Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 }
options:
/*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
/*eslint-env es6*/
var a,
b,
c;
let a,
b,
c;
const a = 1,
b = 2,
c = 3;
Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 }
options:
/*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
/*eslint-env es6*/
var a,
b,
c;
let a,
b,
c;
const a = 1,
b = 2,
c = 3;
Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }
options:
/*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
/*eslint-env es6*/
var a,
b,
c;
let a,
b,
c;
const a = 1,
b = 2,
c = 3;
outerIIFEBody
Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }
:
/*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
(function() {
function foo(x) {
return x + 1;
}
})();
if(y) {
console.log('foo');
}
Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}
:
/*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
(function() {
function foo(x) {
return x + 1;
}
})();
if(y) {
console.log('foo');
}
MemberExpression
Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 }
options:
/*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
foo
.bar
.baz()
Examples of correct code for this rule with the 2, { "MemberExpression": 1 }
option:
/*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
foo
.bar
.baz();
// Any indentation is permitted in variable declarations and assignments.
var bip = aardvark.badger
.coyote;
FunctionDeclaration
Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }
option:
/*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
function foo(bar,
baz,
qux) {
qux();
}
Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }
option:
/*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
function foo(bar,
baz,
qux) {
qux();
}
Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} }
option:
/*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
function foo(bar, baz,
qux, boop) {
qux();
}
Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} }
option:
/*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
function foo(bar, baz,
qux, boop) {
qux();
}
FunctionExpression
Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} }
option:
/*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
var foo = function(bar,
baz,
qux) {
qux();
}
Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} }
option:
/*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
var foo = function(bar,
baz,
qux) {
qux();
}
Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} }
option:
/*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
var foo = function(bar, baz,
qux, boop) {
qux();
}
Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} }
option:
/*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
var foo = function(bar, baz,
qux, boop) {
qux();
}
CallExpression
Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} }
option:
/*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
foo(bar,
baz,
qux
);
Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} }
option:
/*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
foo(bar,
baz,
qux
);
Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} }
option:
/*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
foo(bar, baz,
baz, boop, beep);
Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} }
option:
/*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
foo(bar, baz,
baz, boop, beep);
ArrayExpression
Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 }
option:
/*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
var foo = [
bar,
baz,
qux
];
Examples of correct code for this rule with the 2, { "ArrayExpression": 1 }
option:
/*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
var foo = [
bar,
baz,
qux
];
Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" }
option:
/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
var foo = [bar,
baz,
qux
];
Examples of correct code for this rule with the 2, { "ArrayExpression": "first" }
option:
/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
var foo = [bar,
baz,
qux
];
ObjectExpression
Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 }
option:
/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
var foo = {
bar: 1,
baz: 2,
qux: 3
};
Examples of correct code for this rule with the 2, { "ObjectExpression": 1 }
option:
/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
var foo = {
bar: 1,
baz: 2,
qux: 3
};
Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" }
option:
/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
var foo = { bar: 1,
baz: 2 };
Examples of correct code for this rule with the 2, { "ObjectExpression": "first" }
option:
/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
var foo = { bar: 1,
baz: 2 };
Compatibility
-
JSHint:
indent
- JSCS: validateIndentation Source: http://eslint.org/docs/rules/
'?' should be placed at the end of the line. Open
? target.prototype
- Read upRead up
- Exclude checks
enforce consistent linebreak style for operators (operator-linebreak)
When a statement is too long to fit on a single line, line breaks are generally inserted next to the operators separating expressions. The first style coming to mind would be to place the operator at the end of the line, following the English punctuation rules.
var fullHeight = borderTop +
innerHeight +
borderBottom;
Some developers find that placing operators at the beginning of the line makes the code more readable.
var fullHeight = borderTop
+ innerHeight
+ borderBottom;
Rule Details
This rule enforces a consistent linebreak style for operators.
Options
This rule has one option, which can be a string option or an object option.
String option:
-
"after"
requires linebreaks to be placed after the operator -
"before"
requires linebreaks to be placed before the operator -
"none"
disallows linebreaks on either side of the operator
Object option:
-
"overrides"
overrides the global setting for specified operators
The default configuration is "after", { "overrides": { "?": "before", ":": "before" } }
after
Examples of incorrect code for this rule with the default "after"
option:
/*eslint operator-linebreak: ["error", "after"]*/
foo = 1
+
2;
foo = 1
+ 2;
foo
= 5;
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;
Examples of correct code for this rule with the default "after"
option:
/*eslint operator-linebreak: ["error", "after"]*/
foo = 1 + 2;
foo = 1 +
2;
foo =
5;
if (someCondition ||
otherCondition) {
}
answer = everything ?
42 :
foo;
before
Examples of incorrect code for this rule with the "before"
option:
/*eslint operator-linebreak: ["error", "before"]*/
foo = 1 +
2;
foo =
5;
if (someCondition ||
otherCondition) {
}
answer = everything ?
42 :
foo;
Examples of correct code for this rule with the "before"
option:
/*eslint operator-linebreak: ["error", "before"]*/
foo = 1 + 2;
foo = 1
+ 2;
foo
= 5;
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;
none
Examples of incorrect code for this rule with the "none"
option:
/*eslint operator-linebreak: ["error", "none"]*/
foo = 1 +
2;
foo = 1
+ 2;
if (someCondition ||
otherCondition) {
}
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;
answer = everything ?
42 :
foo;
Examples of correct code for this rule with the "none"
option:
/*eslint operator-linebreak: ["error", "none"]*/
foo = 1 + 2;
foo = 5;
if (someCondition || otherCondition) {
}
answer = everything ? 42 : foo;
overrides
Examples of additional correct code for this rule with the { "overrides": { "+=": "before" } }
option:
/*eslint operator-linebreak: ["error", "after", { "overrides": { "+=": "before" } }]*/
var thing
+= 'thing';
Examples of additional correct code for this rule with the { "overrides": { "?": "ignore", ":": "ignore" } }
option:
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]*/
answer = everything ?
42
: foo;
answer = everything
?
42
:
foo;
When Not To Use It
If your project will not be using a common operator line break style, turn this rule off.
Related Rules
- [comma-style](comma-style.md) Source: http://eslint.org/docs/rules/
Missing space before opening brace. Open
if(descriptor.hasOwnProperty("writable")){
- Read upRead up
- Exclude checks
Require Or Disallow Space Before Blocks (space-before-blocks)
Consistency is an important part of any style guide. While it is a personal preference where to put the opening brace of blocks, it should be consistent across a whole project. Having an inconsistent style distracts the reader from seeing the important parts of the code.
Rule Details
This rule will enforce consistency of spacing before blocks. It is only applied on blocks that don’t begin on a new line.
- This rule ignores spacing which is between
=>
and a block. The spacing is handled by thearrow-spacing
rule. - This rule ignores spacing which is between a keyword and a block. The spacing is handled by the
keyword-spacing
rule.
Options
This rule takes one argument. If it is "always"
then blocks must always have at least one preceding space. If "never"
then all blocks should never have any preceding space. If different spacing is desired for function
blocks, keyword blocks and classes, an optional configuration object can be passed as the rule argument to
configure the cases separately.
( e.g. { "functions": "never", "keywords": "always", "classes": "always" }
)
The default is "always"
.
"always"
Examples of incorrect code for this rule with the "always" option:
/*eslint space-before-blocks: "error"*/
if (a){
b();
}
function a(){}
for (;;){
b();
}
try {} catch(a){}
class Foo{
constructor(){}
}
Examples of correct code for this rule with the "always" option:
/*eslint space-before-blocks: "error"*/
if (a) {
b();
}
if (a) {
b();
} else{ /*no error. this is checked by `keyword-spacing` rule.*/
c();
}
function a() {}
for (;;) {
b();
}
try {} catch(a) {}
"never"
Examples of incorrect code for this rule with the "never" option:
/*eslint space-before-blocks: ["error", "never"]*/
if (a) {
b();
}
function a() {}
for (;;) {
b();
}
try {} catch(a) {}
Examples of correct code for this rule with the "never" option:
/*eslint space-before-blocks: ["error", "never"]*/
if (a){
b();
}
function a(){}
for (;;){
b();
}
try{} catch(a){}
class Foo{
constructor(){}
}
Examples of incorrect code for this rule when configured { "functions": "never", "keywords": "always", "classes": "never" }
:
/*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "always", "classes": "never" }]*/
/*eslint-env es6*/
function a() {}
try {} catch(a){}
class Foo{
constructor() {}
}
Examples of correct code for this rule when configured { "functions": "never", "keywords": "always", "classes": "never" }
:
/*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "always", "classes": "never" }]*/
/*eslint-env es6*/
for (;;) {
// ...
}
describe(function(){
// ...
});
class Foo {
constructor(){}
}
Examples of incorrect code for this rule when configured { "functions": "always", "keywords": "never", "classes": "never" }
:
/*eslint space-before-blocks: ["error", { "functions": "always", "keywords": "never", "classes": "never" }]*/
/*eslint-env es6*/
function a(){}
try {} catch(a) {}
class Foo {
constructor(){}
}
Examples of correct code for this rule when configured { "functions": "always", "keywords": "never", "classes": "never" }
:
/*eslint space-before-blocks: ["error", { "functions": "always", "keywords": "never", "classes": "never" }]*/
/*eslint-env es6*/
if (a){
b();
}
var a = function() {}
class Foo{
constructor() {}
}
Examples of incorrect code for this rule when configured { "functions": "never", "keywords": "never", "classes": "always" }
:
/*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "never", "classes": "always" }]*/
/*eslint-env es6*/
class Foo{
constructor(){}
}
Examples of correct code for this rule when configured { "functions": "never", "keywords": "never", "classes": "always" }
:
/*eslint space-before-blocks: ["error", { "functions": "never", "keywords": "never", "classes": "always" }]*/
/*eslint-env es6*/
class Foo {
constructor(){}
}
When Not To Use It
You can turn this rule off if you are not concerned with the consistency of spacing before blocks.
Related Rules
- [keyword-spacing](keyword-spacing.md)
- [arrow-spacing](arrow-spacing.md)
- [brace-style](brace-style.md) Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
/**
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
if (this.isKernelExists(namedId)) {
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
*/
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
this._get_ghost(namedId),
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
* @return {Promise<Shiori>} ghost(shiori) instance
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
const dirpath = this._get_ghost_directory_path(namedId);
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
}
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
const shiori = await ShioriLoader.detect_shiori(fs, dirpath);
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
? target.prototype
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected space(s) after "for". Open
for(const key of Reflect.ownKeys(targetObj)){
- Read upRead up
- Exclude checks
enforce consistent spacing before and after keywords (keyword-spacing)
Keywords are syntax elements of JavaScript, such as function
and if
.
These identifiers have special meaning to the language and so often appear in a different color in code editors.
As an important part of the language, style guides often refer to the spacing that should be used around keywords.
For example, you might have a style guide that says keywords should be always surrounded by spaces, which would mean if-else
statements must look like this:
if (foo) {
// ...
} else {
// ...
}
Of course, you could also have a style guide that disallows spaces around keywords.
Rule Details
This rule enforces consistent spacing around keywords and keyword-like tokens: as
(in module declarations), async
(of async functions), await
(of await expressions), break
, case
, catch
, class
, const
, continue
, debugger
, default
, delete
, do
, else
, export
, extends
, finally
, for
, from
(in module declarations), function
, get
(of getters), if
, import
, in
, instanceof
, let
, new
, of
(in for-of statements), return
, set
(of setters), static
, super
, switch
, this
, throw
, try
, typeof
, var
, void
, while
, with
, and yield
. This rule is designed carefully not to conflict with other spacing rules: it does not apply to spacing where other rules report problems.
Options
This rule has an object option:
-
"before": true
(default) requires at least one space before keywords -
"before": false
disallows spaces before keywords -
"after": true
(default) requires at least one space after keywords -
"after": false
disallows spaces after keywords -
"overrides"
allows overriding spacing style for specified keywords
before
Examples of incorrect code for this rule with the default { "before": true }
option:
/*eslint keyword-spacing: ["error", { "before": true }]*/
if (foo) {
//...
}else if (bar) {
//...
}else {
//...
}
Examples of correct code for this rule with the default { "before": true }
option:
/*eslint keyword-spacing: ["error", { "before": true }]*/
/*eslint-env es6*/
if (foo) {
//...
} else if (bar) {
//...
} else {
//...
}
// no conflict with `array-bracket-spacing`
let a = [this];
let b = [function() {}];
// no conflict with `arrow-spacing`
let a = ()=> this.foo;
// no conflict with `block-spacing`
{function foo() {}}
// no conflict with `comma-spacing`
let a = [100,this.foo, this.bar];
// not conflict with `computed-property-spacing`
obj[this.foo] = 0;
// no conflict with `generator-star-spacing`
function *foo() {}
// no conflict with `key-spacing`
let obj = {
foo:function() {}
};
// no conflict with `object-curly-spacing`
let obj = {foo: this};
// no conflict with `semi-spacing`
let a = this;function foo() {}
// no conflict with `space-in-parens`
(function () {})();
// no conflict with `space-infix-ops`
if ("foo"in {foo: 0}) {}
if (10+this.foo<= this.bar) {}
// no conflict with `jsx-curly-spacing`
let a =
Examples of incorrect code for this rule with the { "before": false }
option:
/*eslint keyword-spacing: ["error", { "before": false }]*/
if (foo) {
//...
} else if (bar) {
//...
} else {
//...
}
Examples of correct code for this rule with the { "before": false }
option:
/*eslint keyword-spacing: ["error", { "before": false }]*/
if (foo) {
//...
}else if (bar) {
//...
}else {
//...
}
after
Examples of incorrect code for this rule with the default { "after": true }
option:
/*eslint keyword-spacing: ["error", { "after": true }]*/
if(foo) {
//...
} else if(bar) {
//...
} else{
//...
}
Examples of correct code for this rule with the default { "after": true }
option:
/*eslint keyword-spacing: ["error", { "after": true }]*/
if (foo) {
//...
} else if (bar) {
//...
} else {
//...
}
// not conflict with `array-bracket-spacing`
let a = [this];
// not conflict with `arrow-spacing`
let a = ()=> this.foo;
// not conflict with `comma-spacing`
let a = [100, this.foo, this.bar];
// not conflict with `computed-property-spacing`
obj[this.foo] = 0;
// not conflict with `generator-star-spacing`
function* foo() {}
// not conflict with `key-spacing`
let obj = {
foo:function() {}
};
// not conflict with `func-call-spacing`
class A {
constructor() {
super();
}
}
// not conflict with `object-curly-spacing`
let obj = {foo: this};
// not conflict with `semi-spacing`
let a = this;function foo() {}
// not conflict with `space-before-function-paren`
function() {}
// no conflict with `space-infix-ops`
if ("foo"in{foo: 0}) {}
if (10+this.foo<= this.bar) {}
// no conflict with `space-unary-ops`
function* foo(a) {
return yield+a;
}
// no conflict with `yield-star-spacing`
function* foo(a) {
return yield* a;
}
// no conflict with `jsx-curly-spacing`
let a =
Examples of incorrect code for this rule with the { "after": false }
option:
/*eslint keyword-spacing: ["error", { "after": false }]*/
if (foo) {
//...
} else if (bar) {
//...
} else {
//...
}
Examples of correct code for this rule with the { "after": false }
option:
/*eslint keyword-spacing: ["error", { "after": false }]*/
if(foo) {
//...
} else if(bar) {
//...
} else{
//...
}
overrides
Examples of correct code for this rule with the { "overrides": { "if": { "after": false }, "for": { "after": false }, "while": { "after": false } } }
option:
/*eslint keyword-spacing: ["error", { "overrides": {
"if": { "after": false },
"for": { "after": false },
"while": { "after": false }
} }]*/
if(foo) {
//...
} else if(bar) {
//...
} else {
//...
}
for(;;);
while(true) {
//...
}
When Not To Use It
If you don't want to enforce consistency on keyword spacing, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
if(descriptor.hasOwnProperty("writable")){
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
* デフォルトのゴーストのビュークラス
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
descriptor.writable = true;
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
* @param {RoutableComponentRoutes} [routes] - ルーティング
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
async loadGhost(namedId, profile, routes, controllers, GhostViewClass) {
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/
Expected linebreaks to be 'LF' but found 'CRLF'. Open
import {GhostKernel} from 'ghost-kernel';
- Read upRead up
- Exclude checks
enforce consistent linebreak style (linebreak-style)
When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).
The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF)
whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"
(for LF) and "\r\n"
for (CRLF).
Many versioning systems (like git and subversion) can automatically ensure the correct ending. However to cover all contingencies, you can activate this rule.
Rule Details
This rule enforces consistent line endings independent of operating system, VCS, or editor used across your codebase.
Options
This rule has a string option:
-
"unix"
(default) enforces the usage of Unix line endings:\n
for LF. -
"windows"
enforces the usage of Windows line endings:\r\n
for CRLF.
unix
Examples of incorrect code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a'; // \r\n
Examples of correct code for this rule with the default "unix"
option:
/*eslint linebreak-style: ["error", "unix"]*/
var a = 'a', // \n
b = 'b'; // \n
// \n
function foo(params) { // \n
// do stuff \n
}// \n
windows
Examples of incorrect code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a'; // \n
Examples of correct code for this rule with the "windows"
option:
/*eslint linebreak-style: ["error", "windows"]*/
var a = 'a', // \r\n
b = 'b'; // \r\n
// \r\n
function foo(params) { // \r\n
// do stuff \r\n
} // \r\n
Using this rule with version control systems
Version control systems sometimes have special behavior for linebreaks. To make it easy for developers to contribute to your codebase from different platforms, you may want to configure your VCS to handle linebreaks appropriately.
For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style
rule to report errors if configured with the "unix"
setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes
file to prevent git from converting linebreaks in .js
files:
*.js text eol=lf
When Not To Use It
If you aren't concerned about having different line endings within your code, then you can safely turn this rule off.
Compatibility
- JSCS: validateLineBreaks Source: http://eslint.org/docs/rules/