diaspora/diaspora

View on GitHub

Showing 43 of 4,306 total issues

Expected { after 'if' condition.
Open

      if( !inAspect1 &&  inAspect2 ) return 1;

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Unexpected 'else' after 'return'.
Open

    } else {
Severity: Minor
Found in lib/assets/javascripts/keycodes.js by eslint

Disallow return before else (no-else-return)

If an if block contains a return statement, the else block becomes unnecessary. Its contents can be placed outside of the block.

js function foo() { if (x) { return y; } else { return z; } }

Rule Details

This rule is aimed at highlighting an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.

Examples of incorrect code for this rule:

```js /eslint no-else-return: "error"/

function foo() { if (x) { return y; } else { return z; } }

function foo() { if (x) { return y; } else if (z) { return w; } else { return t; } }

function foo() { if (x) { return y; } else { var t = "foo"; }

return t;

}

// Two warnings for nested occurrences function foo() { if (x) { if (y) { return y; } else { return x; } } else { return z; } } ```

Examples of correct code for this rule:

```js /eslint no-else-return: "error"/

function foo() { if (x) { return y; }

return z;

}

function foo() { if (x) { return y; } else if (z) { var t = "foo"; } else { return w; } }

function foo() { if (x) { if (z) { return y; } } else { return z; } } ``` Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      if(charCode >= 1536 && charCode <= 1791) // Sarabic, Persian, ...

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

    if( !con1.person || !con2.person ) return 1;

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      if(  inAspect1 && !inAspect2 ) return -1;

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=64256 && charCode<=64335) // Hebrew present

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode >= 64336 && charCode <= 65023) // Arabic present 2

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      if( this.isRTL(str) ) return 'rtl';

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=1424 && charCode<=1535) // Hebrew

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=1792 && charCode<=1871) // Syriac

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=1984 && charCode<=2047) // NKo

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode >= 65136 && charCode <= 65279) // Arabic present 1

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=1920 && charCode<=1983) // Thaana

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=67840 && charCode<=67871)  // Phoenician

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

  if( !context ) context = this;

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Unexpected 'else' after 'return'.
Open

  } else {

Disallow return before else (no-else-return)

If an if block contains a return statement, the else block becomes unnecessary. Its contents can be placed outside of the block.

js function foo() { if (x) { return y; } else { return z; } }

Rule Details

This rule is aimed at highlighting an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.

Examples of incorrect code for this rule:

```js /eslint no-else-return: "error"/

function foo() { if (x) { return y; } else { return z; } }

function foo() { if (x) { return y; } else if (z) { return w; } else { return t; } }

function foo() { if (x) { return y; } else { var t = "foo"; }

return t;

}

// Two warnings for nested occurrences function foo() { if (x) { if (y) { return y; } else { return x; } } else { return z; } } ```

Examples of correct code for this rule:

```js /eslint no-else-return: "error"/

function foo() { if (x) { return y; }

return z;

}

function foo() { if (x) { return y; } else if (z) { var t = "foo"; } else { return w; } }

function foo() { if (x) { if (z) { return y; } } else { return z; } } ``` Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=68096 && charCode<=68184)  // Kharoshthi

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

  if( !context ) context = this;

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected { after 'if' condition.
Open

      else if(charCode>=11568 && charCode<=11647) // Tifinagh

Require Following Curly Brace Conventions (curly)

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

js if (foo) foo++;

Can be rewritten as:

js if (foo) { foo++; }

There are, however, some who prefer to only use braces when there is more than one statement to be executed.

Rule Details

This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces. It will warn when it encounters blocks that omit curly braces.

Options

all

Examples of incorrect code for the default "all" option:

```js /eslint curly: "error"/

if (foo) foo++;

while (bar) baz();

if (foo) { baz(); } else qux(); ```

Examples of correct code for the default "all" option:

```js /eslint curly: "error"/

if (foo) { foo++; }

while (bar) { baz(); }

if (foo) { baz(); } else { qux(); } ```

multi

By default, this rule warns whenever if, else, for, while, or do are used without block statements as their body. However, you can specify that block statements should be used only when there are multiple statements in the block and warn when there is only one statement in the block.

Examples of incorrect code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) { foo++; }

if (foo) bar(); else { foo++; }

while (true) { doSomething(); }

for (var i=0; i < items.length; i++) { doSomething(); } ```

Examples of correct code for the "multi" option:

```js /eslint curly: ["error", "multi"]/

if (foo) foo++;

else foo();

while (true) { doSomething(); doSomethingElse(); } ```

multi-line

Alternatively, you can relax the rule to allow brace-less single-line if, else if, else, for, while, or do, while still enforcing the use of curly braces for other instances.

Examples of incorrect code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) doSomething(); else doSomethingElse();

if (foo) foo( bar, baz); ```

Examples of correct code for the "multi-line" option:

```js /eslint curly: ["error", "multi-line"]/

if (foo) foo++; else doSomething();

if (foo) foo++; else if (bar) baz() else doSomething();

do something(); while (foo);

while (foo && bar) baz();

if (foo) { foo++; }

if (foo) { foo++; }

while (true) { doSomething(); doSomethingElse(); } ```

multi-or-nest

You can use another configuration that forces brace-less if, else if, else, for, while, or do if their body contains only one single-line statement. And forces braces in all other cases.

Examples of incorrect code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) foo = { bar: baz, qux: foo };

while (true) if(foo) doSomething(); else doSomethingElse();

if (foo) { foo++; }

while (true) { doSomething(); }

for (var i = 0; foo; i++) { doSomething(); } ```

Examples of correct code for the "multi-or-nest" option:

```js /eslint curly: ["error", "multi-or-nest"]/

if (!foo) { foo = { bar: baz, qux: foo }; }

while (true) { if(foo) doSomething(); else doSomethingElse(); }

if (foo) foo++;

while (true) doSomething();

for (var i = 0; foo; i++) doSomething(); ```

consistent

When using any of the multi* options, you can add an option to enforce all bodies of a if, else if and else chain to be with or without braces.

Examples of incorrect code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else buz();

if (foo) bar(); else if (faa) bor(); else { other(); things(); }

if (true) foo(); else { baz(); }

if (foo) { foo++; } ```

Examples of correct code for the "multi", "consistent" options:

```js /eslint curly: ["error", "multi", "consistent"]/

if (foo) { bar(); baz(); } else { buz(); }

if (foo) { bar(); } else if (faa) { bor(); } else { other(); things(); }

if (true) foo(); else baz();

if (foo) foo++;

```

When Not To Use It

If you have no strict conventions about when to use block statements and when not to, you can safely disable this rule. Source: http://eslint.org/docs/rules/

Expected literal to be on the right side of <=.
Open

      if (0xD800 <= code && code <= 0xDBFF) {

Require or disallow Yoda Conditions (yoda)

Yoda conditions are so named because the literal value of the condition comes first while the variable comes second. For example, the following is a Yoda condition:

js if ("red" === color) { // ... }

This is called a Yoda condition because it reads as, "red is the color", similar to the way the Star Wars character Yoda speaks. Compare to the other way of arranging the operands:

js if (color === "red") { // ... }

This typically reads, "color is red", which is arguably a more natural way to describe the comparison.

Proponents of Yoda conditions highlight that it is impossible to mistakenly use = instead of == because you cannot assign to a literal value. Doing so will cause a syntax error and you will be informed of the mistake early on. This practice was therefore very common in early programming where tools were not yet available.

Opponents of Yoda conditions point out that tooling has made us better programmers because tools will catch the mistaken use of = instead of == (ESLint will catch this for you). Therefore, they argue, the utility of the pattern doesn't outweigh the readability hit the code takes while using Yoda conditions.

Rule Details

This rule aims to enforce consistent style of conditions which compare a variable to a literal value.

Options

This rule can take a string option:

  • If it is the default "never", then comparisons must never be Yoda conditions.
  • If it is "always", then the literal value must always come first.

The default "never" option can have exception options in an object literal:

  • If the "exceptRange" property is true, the rule allows yoda conditions in range comparisons which are wrapped directly in parentheses, including the parentheses of an if or while condition. The default value is false. A range comparison tests whether a variable is inside or outside the range between two literal values.
  • If the "onlyEquality" property is true, the rule reports yoda conditions only for the equality operators == and ===. The default value is false.

The onlyEquality option allows a superset of the exceptions which exceptRange allows, thus both options are not useful together.

never

Examples of incorrect code for the default "never" option:

```js /eslint yoda: "error"/

if ("red" === color) { // ... }

if (true == flag) { // ... }

if (5 > count) { // ... }

if (-1 < str.indexOf(substr)) { // ... }

if (0 <= x && x < 1) { // ... } ```

Examples of correct code for the default "never" option:

```js /eslint yoda: "error"/

if (5 & value) { // ... }

if (value === "red") { // ... } ```

exceptRange

Examples of correct code for the "never", { "exceptRange": true } options:

```js /eslint yoda: ["error", "never", { "exceptRange": true }]/

function isReddish(color) { return (color.hue < 60 || 300 < color.hue); }

if (x < -1 || 1 < x) { // ... }

if (count < 10 && (0 <= rand && rand < 1)) { // ... }

function howLong(arr) { return (0 <= arr.length && arr.length < 10) ? "short" : "long"; } ```

onlyEquality

Examples of correct code for the "never", { "onlyEquality": true } options:

```js /eslint yoda: ["error", "never", { "onlyEquality": true }]/

if (x < -1 || 9 < x) { }

if (x !== 'foo' && 'bar' != x) { } ```

always

Examples of incorrect code for the "always" option:

```js /eslint yoda: ["error", "always"]/

if (color == "blue") { // ... } ```

Examples of correct code for the "always" option:

```js /eslint yoda: ["error", "always"]/

if ("blue" == value) { // ... }

if (-1 < str.indexOf(substr)) { // ... } ```

Further Reading

Severity
Category
Status
Source