Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • key-spacing
  • padding-line-between-statements
  • comma-dangle
  • max-len
  • eol-last
  • no-multiple-empty-lines
  • no-this-before-super
  • refer-destructuring
  • prefer-object-spread
  • jsx-quotes
  • prefer-const
  • promise/prefer-await-to-then

  • react/sort-comp
  • react/jsx-one-expression-per-line
  • react/jsx-closing-bracket-location
  • react/jsx-closing-tag-location

  • react/jsx-wrap-multilines

  • react/jsx-curly-spacing 

  • no-array-constructor
  • no-loop-func
  • no-new-func
  • max-lines
  • prefer-destructuring
  • eslint-plugin-filenames
  • max-depth
  • no-constant-condition

key-spacing

currently: "key-spacing": "off"

  • beforeColon

Examples of incorrect code for this rule with the default { "beforeColon": false } option:

Code Block
/*eslint key-spacing: ["error", { "beforeColon": false }]*/
var obj = { "foo" : 42 };

Examples of correct code for this rule with the default { "beforeColon": false } option:

Code Block
/*eslint key-spacing: ["error", { "beforeColon": false }]*/
var obj = { "foo": 42 };
  • afterColon

Examples of incorrect code for this rule with the default { "afterColon": true } option:

Code Block
/*eslint key-spacing: ["error", { "afterColon": true }]*/
var obj = { "foo":42 };

Examples of correct code for this rule with the default { "afterColon": true } option:

...

  • key-spacing
  • padding-line-between-statements

...

  • one or more blank lines are required between a variable declaration and a return statement.

Examples of incorrect code for the [{ blankLine: "always", prev: "*", next: "return" }] configuration:

...

  • comma-dangle
  • max-len
  • eol-last
  • no-multiple-empty-lines
  • no-this-before-super
  • refer-destructuring
  • prefer-object-spread
  • jsx-quotes
  • prefer-const
  • promise/prefer-await-to-then

  • react/sort-comp
  • react/jsx-one-expression-per-line
  • react/jsx-closing-bracket-location
  • react/jsx-closing-tag-location

  • react/jsx-wrap-multilines

  • react/jsx-curly-spacing 

  • no-array-constructor
  • no-loop-func
  • no-new-func
  • max-lines
  • prefer-destructuring
  • eslint-plugin-filenames
  • max-depth
  • no-constant-condition

key-spacing

currently: "key-spacing": "off"

  • beforeColon

Examples of incorrect code for this rule with the default { "beforeColon": false } option:

Code Block
/*eslint key-spacing: ["error", { "beforeColon": false }]*/
var obj = { "foo" : 42 };

Examples of correct code for this rule with the default { "beforeColon": false } option:

Code Block
/*eslint key-spacing: ["error", { "beforeColon": false }]*/
var obj = { "foo": 42 };
  • afterColon

Examples of incorrect code for this rule with the default { "afterColon": true } option:

Code Block
/*eslint key-spacing: ["error", { "afterColon": true }]*/
var obj = { "foo":42 };

Examples of correct code for this rule with the default { "afterColon": true } option:

Code Block
/*eslint key-spacing: ["error", { "afterColon": true }]*/
var obj = { "foo": 42 };

padding-line-between-statements

  • one or more blank lines are required between a variable declaration and a return statement.

Examples of incorrect code for the [{ blankLine: "always", prev: "*", next: "return" }] configuration:

Code Block
/*eslint padding-line-between-statements: [
    "error",
    { blankLine: "always", prev: "*", next: "return" }
]*/

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

...

This rule covers SonarCloud rule: Files should not have too many lines

max-lines: ["error", 1000]

prefer-destructuring [sonar]

...

Code Block
//Examples of incorrect code for this rule:

// With `array` enabled
var foo = array[0];

// With `object` enabled
var foo = object.foo;
var foo = object['foo'];
//Examples of correct code for this rule:

// With `array` enabled
var [ foo ] = array;
var foo = array[0someIndex];

// With `object` enabled
var { foo } = object.foo;

var foo = object['foo'];
//Examples of correct code for this rule:

// With `array` enabled
var [ foo ] = array;
var foo = array[someIndex];

// With `object` enabled
var { foo } = object;

var foo = object.bar;

...

.bar;

eslint-plugin-filenames [sonar]

This rule covers SonarCloud rule: Default export names and file names should match

"filenames/match-exported": "error"

max-depth [sonar]

This rule covers SonarCloud rule: Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply"filenames/match-exported": "error"

"max-depth": ["error", 3]

no-constant-condition [sonar]

This rule covers SonarCloud rule: Default export names and file names should match

...

 Conditionally executed blocks should be reachableConditional expressions which are always true or false can lead to dead code. There shouldn't be expressions like if (false){}

"no-constant-condition": "error"

max-depth [sonar]


This rule covers SonarCloud rule: Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply"filenames/match-exportedSome of sonar rules are covered in the eslint plugin - https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/README.md

"no-empty-function": "error",
"no-empty": "error",
"max-lines-per-

...

function":

...

[
"error",

...


200
],

no-constant-condition [sonar]

This rule covers SonarCloud rule: Conditionally executed blocks should be reachableConditional expressions which are always true or false can lead to dead code. There shouldn't be expressions like if (false){}

"no-constant-condition": "error"

Some of sonar rules are covered in the eslint plugin - https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/README.md"max-params": [
"error",
7
],
"require-yield": "error",
"no-duplicate-imports": "error",
"no-labels": "error"