diaspora/diaspora

View on GitHub

Showing 163 issues of 4,306 total

Expected to return a value at the end of this function.
Open

  return this.each(function() {
Severity: Minor
Found in lib/assets/javascripts/clear-form.js by eslint

Require Consistent Returns (consistent-return)

One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function's return value.

Unlike statically-typed languages that will catch when a function doesn't return the type of data expected, JavaScript has no such checks, meaning that it's easy to make mistakes such as this:

```js function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

} ```

Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

Rule Details

This rule is aimed at ensuring all return statements either specify a value or don't specify a value.

It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

Examples of incorrect code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

}

function doSomething(condition) {

if (condition) {
    return;
} else {
    return true;
}

}

function doSomething(condition) {

if (condition) {
    return true;
}

} ```

Examples of correct code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return false;
}

}

function Foo() { if (!(this instanceof Foo)) { return new Foo(); }

this.a = 0;

} ```

When Not To Use It

If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule. Source: http://eslint.org/docs/rules/

Values of 0 shouldn't have units specified.
Open

  margin: 0px 3px 0 0px;

Element (li.as-selection-item.selected) is overqualified, just use .selected without element name.
Open

ul.as-selections li.as-selection-item.selected {

Values of 0 shouldn't have units specified.
Open

  margin: 0px 3px 0 0px;

Rule is empty.
Open

ul.as-selections li.as-selection-item a.as-close {

'PosixBracketExpressions' is defined but never used
Open

var PosixBracketExpressions = {

Disallow Unused Variables (no-unused-vars)

Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers.

Rule Details

This rule is aimed at eliminating unused variables, functions, and parameters of functions.

A variable is considered to be used if any of the following are true:

  • It represents a function that is called (doSomething())
  • It is read (var y = x)
  • It is passed into a function as an argument (doSomething(x))

A variable is not considered to be used if it is only ever assigned to (var x = 5) or declared.

Examples of incorrect code for this rule:

```js /eslint no-unused-vars: "error"/ /global someunusedvar/

//It checks variables you have defined as global someunusedvar = 42;

var x;

var y = 10; y = 5;

// By default, unused arguments cause warnings. (function(foo) { return 5; })();

// Unused recursive functions also cause warnings. function fact(n) { if (n < 2) return 1; return n * fact(n - 1); } ```

Examples of correct code for this rule:

```js /eslint no-unused-vars: "error"/

var x = 10; alert(x);

// foo is considered used here myFunc(function foo() { // ... }.bind(this));

(function(foo) { return foo; })(); ```

exported

In environments outside of CommonJS or ECMAScript modules, you may use var to create a global variable that may be used by other scripts. You can use the /* exported variableName */ comment block to indicate that this variable is being exported and therefore should not be considered unused.

Note that /* exported */ has no effect for any of the following:

  • when the environment is node or commonjs
  • when parserOptions.sourceType is module
  • when ecmaFeatures.globalReturn is true

Options

This rule takes one argument which can be a string or an object. The string settings are the same as those of the vars property (explained below).

By default this rule is enabled with all option for variables and after-used for arguments.

json { "rules": { "no-unused-vars": ["error", { "vars": "all", "args": "after-used" }] } }

vars

The vars option has two settings:

  • all checks all variables for usage, including those in the global scope. This is the default setting.
  • local checks only that locally-declared variables are used but will allow global variables to be unused.

vars: local

Examples of correct code for the { "vars": "local" } option:

```js /eslint no-unused-vars: ["error", { "vars": "local" }]/ /*global someunusedvar */

someunusedvar = 42; ```

varsIgnorePattern

The varsIgnorePattern option specifies exceptions not to check for usage: variables whose names match a regexp pattern. For example, variables whose names contain ignored or Ignored.

Examples of correct code for the { "varsIgnorePattern": "[iI]gnored" } option:

```js /eslint no-unused-vars: ["error", { "varsIgnorePattern": "[iI]gnored" }]/

var firstVarIgnored = 1; var secondVar = 2; console.log(secondVar); ```

args

The args option has three settings:

  • after-used - only the last argument must be used. This allows you, for instance, to have two named parameters to a function and as long as you use the second argument, ESLint will not warn you about the first. This is the default setting.
  • all - all named arguments must be used.
  • none - do not check arguments.

args: after-used

Examples of incorrect code for the default { "args": "after-used" } option:

```js /eslint no-unused-vars: ["error", { "args": "after-used" }]/

// 1 error // "baz" is defined but never used (function(foo, bar, baz) { return bar; })(); ```

Examples of correct code for the default { "args": "after-used" } option:

```js /eslint no-unused-vars: ["error", {"args": "after-used"}]/

(function(foo, bar, baz) { return baz; })(); ```

args: all

Examples of incorrect code for the { "args": "all" } option:

```js /eslint no-unused-vars: ["error", { "args": "all" }]/

// 2 errors // "foo" is defined but never used // "baz" is defined but never used (function(foo, bar, baz) { return bar; })(); ```

args: none

Examples of correct code for the { "args": "none" } option:

```js /eslint no-unused-vars: ["error", { "args": "none" }]/

(function(foo, bar, baz) { return bar; })(); ```

argsIgnorePattern

The argsIgnorePattern option specifies exceptions not to check for usage: arguments whose names match a regexp pattern. For example, variables whose names begin with an underscore.

Examples of correct code for the { "argsIgnorePattern": "^_" } option:

```js /eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }]/

function foo(x, _y) { return x + 1; } foo(); ```

caughtErrors

The caughtErrors option is used for catch block arguments validation.

It has two settings:

  • none - do not check error objects. This is the default setting.
  • all - all named arguments must be used.

caughtErrors: none

Not specifying this rule is equivalent of assigning it to none.

Examples of correct code for the { "caughtErrors": "none" } option:

```js /eslint no-unused-vars: ["error", { "caughtErrors": "none" }]/

try { //... } catch (err) { console.error("errors"); } ```

caughtErrors: all

Examples of incorrect code for the { "caughtErrors": "all" } option:

```js /eslint no-unused-vars: ["error", { "caughtErrors": "all" }]/

// 1 error // "err" is defined but never used try { //... } catch (err) { console.error("errors"); } ```

caughtErrorsIgnorePattern

The caughtErrorsIgnorePattern option specifies exceptions not to check for usage: catch arguments whose names match a regexp pattern. For example, variables whose names begin with a string 'ignore'.

Examples of correct code for the { "caughtErrorsIgnorePattern": "^ignore" } option:

```js /eslint no-unused-vars: ["error", { "caughtErrorsIgnorePattern": "^ignore" }]/

try { //... } catch (ignoreErr) { console.error("errors"); } ```

When Not To Use It

If you don't want to be notified about unused variables or function arguments, you can safely turn this rule off. Source: http://eslint.org/docs/rules/

Multiple spaces found before '-'.
Open

    return  -first_tf.get("name").localeCompare(second_tf.get("name"));

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Expected no return value.
Open

      return(preload);
Severity: Minor
Found in app/assets/javascripts/app/app.js by eslint

Require Consistent Returns (consistent-return)

One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function's return value.

Unlike statically-typed languages that will catch when a function doesn't return the type of data expected, JavaScript has no such checks, meaning that it's easy to make mistakes such as this:

```js function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

} ```

Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

Rule Details

This rule is aimed at ensuring all return statements either specify a value or don't specify a value.

It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

Examples of incorrect code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

}

function doSomething(condition) {

if (condition) {
    return;
} else {
    return true;
}

}

function doSomething(condition) {

if (condition) {
    return true;
}

} ```

Examples of correct code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return false;
}

}

function Foo() { if (!(this instanceof Foo)) { return new Foo(); }

this.a = 0;

} ```

When Not To Use It

If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule. Source: http://eslint.org/docs/rules/

Multiple spaces found before 'inAspect1'.
Open

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

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Multiple spaces found before 'inAspect2'.
Open

      if( !inAspect1 &&  inAspect2 ) return 1;

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Expected no return value.
Open

  return _.template("<img src=\"<%= src %>\" class=\"<%= imageClass %>\" " +

Require Consistent Returns (consistent-return)

One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function's return value.

Unlike statically-typed languages that will catch when a function doesn't return the type of data expected, JavaScript has no such checks, meaning that it's easy to make mistakes such as this:

```js function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

} ```

Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

Rule Details

This rule is aimed at ensuring all return statements either specify a value or don't specify a value.

It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

Examples of incorrect code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

}

function doSomething(condition) {

if (condition) {
    return;
} else {
    return true;
}

}

function doSomething(condition) {

if (condition) {
    return true;
}

} ```

Examples of correct code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return false;
}

}

function Foo() { if (!(this instanceof Foo)) { return new Foo(); }

this.a = 0;

} ```

When Not To Use It

If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule. Source: http://eslint.org/docs/rules/

Multiple spaces found before '"♥"'.
Open

                                               .replace(/<3/g,  "♥");

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Empty block statement.
Open

          } catch (__) {}

disallow empty block statements (no-empty)

Empty block statements, while not technically errors, usually occur due to refactoring that wasn't completed. They can cause confusion when reading code.

Rule Details

This rule disallows empty block statements. This rule ignores block statements which contain a comment (for example, in an empty catch or finally block of a try statement to indicate that execution should continue regardless of errors).

Examples of incorrect code for this rule:

```js /eslint no-empty: "error"/

if (foo) { }

while (foo) { }

switch(foo) { }

try { doSomething(); } catch(ex) {

} finally {

} ```

Examples of correct code for this rule:

```js /eslint no-empty: "error"/

if (foo) { // empty }

while (foo) { /* empty */ }

try { doSomething(); } catch (ex) { // continue regardless of error }

try { doSomething(); } finally { /* continue regardless of error */ } ```

Options

This rule has an object option for exceptions:

  • "allowEmptyCatch": true allows empty catch clauses (that is, which do not contain a comment)

allowEmptyCatch

Examples of additional correct code for this rule with the { "allowEmptyCatch": true } option:

```js /* eslint no-empty: ["error", { "allowEmptyCatch": true }] */ try { doSomething(); } catch (ex) {}

try { doSomething(); } catch (ex) {} finally { /* continue regardless of error */ } ```

When Not To Use It

If you intentionally use empty block statements then you can disable this rule.

Related Rules

  • [no-empty-function](./no-empty-function.md) Source: http://eslint.org/docs/rules/

Multiple spaces found before '"←"'.
Open

                                               .replace(/<-/g,  "←")

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Multiple spaces found before '"→"'.
Open

                                               .replace(/->/g,  "→")

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Multiple spaces found before '='.
Open

        url  = Routes.adminPodRecheck(this.id).toString();

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Unexpected trailing comma.
Open

  initialize : function() {},

require or disallow trailing commas (comma-dangle)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Trailing commas in object literals are valid according to the ECMAScript 5 (and ECMAScript 3!) spec. However, IE8 (when not in IE8 document mode) and below will throw an error when it encounters trailing commas in JavaScript.

js var foo = { bar: "baz", qux: "quux", };

Trailing commas simplify adding and removing items to objects and arrays, since only the lines you are modifying must be touched. Another argument in favor of trailing commas is that it improves the clarity of diffs when an item is added or removed from an object or array:

Less clear:

diff var foo = { - bar: "baz", - qux: "quux" + bar: "baz" };

More clear:

diff var foo = { bar: "baz", - qux: "quux", };

Rule Details

This rule enforces consistent use of trailing commas in object and array literals.

Options

This rule has a string option:

  • "never" (default) disallows trailing commas
  • "always" requires trailing commas
  • "always-multiline" requires trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }
  • "only-multiline" allows (but does not require) trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }

never

Examples of incorrect code for this rule with the default "never" option:

```js /eslint comma-dangle: ["error", "never"]/

var foo = { bar: "baz", qux: "quux", };

var arr = [1,2,];

foo({ bar: "baz", qux: "quux", }); ```

Examples of correct code for this rule with the default "never" option:

```js /eslint comma-dangle: ["error", "never"]/

var foo = { bar: "baz", qux: "quux" };

var arr = [1,2];

foo({ bar: "baz", qux: "quux" }); ```

always

Examples of incorrect code for this rule with the "always" option:

```js /eslint comma-dangle: ["error", "always"]/

var foo = { bar: "baz", qux: "quux" };

var arr = [1,2];

foo({ bar: "baz", qux: "quux" }); ```

Examples of correct code for this rule with the "always" option:

```js /eslint comma-dangle: ["error", "always"]/

var foo = { bar: "baz", qux: "quux", };

var arr = [1,2,];

foo({ bar: "baz", qux: "quux", }); ```

always-multiline

Examples of incorrect code for this rule with the "always-multiline" option:

```js /eslint comma-dangle: ["error", "always-multiline"]/

var foo = { bar: "baz", qux: "quux" };

var foo = { bar: "baz", qux: "quux", };

var arr = [1,2,];

var arr = [1, 2,];

var arr = [ 1, 2 ];

foo({ bar: "baz", qux: "quux" }); ```

Examples of correct code for this rule with the "always-multiline" option:

```js /eslint comma-dangle: ["error", "always-multiline"]/

var foo = { bar: "baz", qux: "quux", };

var foo = {bar: "baz", qux: "quux"}; var arr = [1,2];

var arr = [1, 2];

var arr = [ 1, 2, ];

foo({ bar: "baz", qux: "quux", }); ```

only-multiline

Examples of incorrect code for this rule with the "only-multiline" option:

```js /eslint comma-dangle: ["error", "only-multiline"]/

var foo = { bar: "baz", qux: "quux", };

var arr = [1,2,];

var arr = [1, 2,];

```

Examples of correct code for this rule with the "only-multiline" option:

```js /eslint comma-dangle: ["error", "only-multiline"]/

var foo = { bar: "baz", qux: "quux", };

var foo = { bar: "baz", qux: "quux" };

var foo = {bar: "baz", qux: "quux"}; var arr = [1,2];

var arr = [1, 2];

var arr = [ 1, 2, ];

var arr = [ 1, 2 ];

foo({ bar: "baz", qux: "quux", });

foo({ bar: "baz", qux: "quux" }); ```

When Not To Use It

You can turn this rule off if you are not concerned with dangling commas. Source: http://eslint.org/docs/rules/

Multiple spaces found before 'new'.
Open

    var person =  new app.models.Profile({ id : personId});

Disallow multiple spaces (no-multi-spaces)

(fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Multiple spaces in a row that are not used for indentation are typically mistakes. For example:

```js

if(foo === "bar") {}

```

It's hard to tell, but there are two spaces between foo and ===. Multiple spaces such as this are generally frowned upon in favor of single spaces:

```js

if(foo === "bar") {}

```

Rule Details

This rule aims to disallow multiple whitespace around logical expressions, conditional expressions, declarations, array elements, object properties, sequences and function parameters.

Examples of incorrect code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Examples of correct code for this rule:

```js /eslint no-multi-spaces: "error"/

var a = 1;

if(foo === "bar") {}

a << b

var arr = [1, 2];

a ? b: c ```

Options

To avoid contradictions if some other rules require multiple spaces, this rule has an option to ignore certain node types in the abstract syntax tree (AST) of JavaScript code.

exceptions

The exceptions object expects property names to be AST node types as defined by ESTree. The easiest way to determine the node types for exceptions is to use the online demo.

Only the Property node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals.

Examples of correct code for the default "exceptions": { "Property": true } option:

```js /eslint no-multi-spaces: "error"/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of incorrect code for the "exceptions": { "Property": false } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "Property": false } }]/ /eslint key-spacing: ["error", { align: "value" }]/

var obj = { first: "first", second: "second" }; ```

Examples of correct code for the "exceptions": { "BinaryExpression": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "BinaryExpression": true } }]/

var a = 1 * 2; ```

Examples of correct code for the "exceptions": { "VariableDeclarator": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]/

var someVar = 'foo'; var someOtherVar = 'barBaz'; ```

Examples of correct code for the "exceptions": { "ImportDeclaration": true } option:

```js /eslint no-multi-spaces: ["error", { exceptions: { "ImportDeclaration": true } }]/

import mod from 'mod'; import someOtherMod from 'some-other-mod'; ```

When Not To Use It

If you don't want to check and disallow multiple spaces, then you should turn this rule off.

Related Rules

  • [key-spacing](key-spacing.md)
  • [space-infix-ops](space-infix-ops.md)
  • [space-in-brackets](space-in-brackets.md) (deprecated)
  • [space-in-parens](space-in-parens.md)
  • [space-after-keywords](space-after-keywords)
  • [space-unary-ops](space-unary-ops)
  • [space-return-throw-case](space-return-throw-case) Source: http://eslint.org/docs/rules/

Expected to return a value at the end of this function.
Open

  fetch: function() {

Require Consistent Returns (consistent-return)

One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function's return value.

Unlike statically-typed languages that will catch when a function doesn't return the type of data expected, JavaScript has no such checks, meaning that it's easy to make mistakes such as this:

```js function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

} ```

Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

Rule Details

This rule is aimed at ensuring all return statements either specify a value or don't specify a value.

It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

Examples of incorrect code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

}

function doSomething(condition) {

if (condition) {
    return;
} else {
    return true;
}

}

function doSomething(condition) {

if (condition) {
    return true;
}

} ```

Examples of correct code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return false;
}

}

function Foo() { if (!(this instanceof Foo)) { return new Foo(); }

this.a = 0;

} ```

When Not To Use It

If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule. Source: http://eslint.org/docs/rules/

Expected to return a value at the end of this function.
Open

  fetch: function() {

Require Consistent Returns (consistent-return)

One of the confusing aspects of JavaScript is that any function may or may not return a value at any point in time. When a function exits without any return statement executing, the function returns undefined. Similarly, calling return without specifying any value will cause the function to return undefined. Only when return is called with a value is there a change in the function's return value.

Unlike statically-typed languages that will catch when a function doesn't return the type of data expected, JavaScript has no such checks, meaning that it's easy to make mistakes such as this:

```js function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

} ```

Here, one branch of the function returns true, a Boolean value, while the other exits without specifying any value (and so returns undefined). This may be an indicator of a coding error, especially if this pattern is found in larger functions.

Rule Details

This rule is aimed at ensuring all return statements either specify a value or don't specify a value.

It excludes constructors which, when invoked with the new operator, return the instantiated object if another object is not explicitly returned. This rule treats a function as a constructor if its name starts with an uppercase letter.

Examples of incorrect code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return;
}

}

function doSomething(condition) {

if (condition) {
    return;
} else {
    return true;
}

}

function doSomething(condition) {

if (condition) {
    return true;
}

} ```

Examples of correct code for this rule:

```js /eslint consistent-return: "error"/

function doSomething(condition) {

if (condition) {
    return true;
} else {
    return false;
}

}

function Foo() { if (!(this instanceof Foo)) { return new Foo(); }

this.a = 0;

} ```

When Not To Use It

If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule. Source: http://eslint.org/docs/rules/

Severity
Category
Status