This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

eslint-config-5minds

1.0.2 • Public • Published

ESLint config for 5Minds projects

  • install with npm install --save-dev eslint-config-5minds
  • create a .eslintrc config with
{
    "extends": "5minds"
}

Have fun ;-)

Possible errors

1.1 no-cond-assign: disallow assignment operators in conditional expressions.

// good
if (=== 0) {
 
}
// bad
if (= 0) {
 
}

1.2 no-console: disallow the use of console.

// bad
console.log('Hello world');

1.3 no-constant-condition: disallow constant expressions in conditions.

// bad
if (false) {
 
}

1.4 no-control-regex: disallow control characters in regular expressions.

// bad
const pattern = /\x1f/;

1.5 no-debugger: disallow the use of debugger.

// bad
debugger;

1.6 no-dupe-args: disallow duplicate arguments in function definitions.

// bad
function foo(a, b, a) {
  console.log('value of the second a:', a);
}

1.7 no-dupe-keys: disallow duplicate keys in object literals.

// bad
const foo {
  bar: 1,
  qux: 2,
  bar: 3,
} 

1.8 no-duplicate-case: disallow duplicate case labels.

// bad
switch (weekday) {
  case 'monday':
    break;
  case 'tuesday':
    break;
  case 'monday':
    break;
  default:
    break;
}

1.9 no-empty: disallow empty block statements.

// bad
function doNothing() {
 
}

1.10 no-empty-character-class: disallow empty character classes in regular expressions.

// bad
'abcdefg'.match(/^abc[]/); // null

1.11 no-ex-assign: disallow reassigning exceptions in catch clauses.

// bad
try {
  parseInt('adf', 10);
} catch (error) {
  error = new Error('You cannot parse letters.');
  throw error;
}

1.12 no-extra-boolean-cast: disallow unnecessary boolean casts.

// bad
function negateNumber(num) {
  if (Boolean(num)) {
    return -1 * num;
  } else {
    throw new Error('missing input');
  }
}
 
// good
function negateNumber(num) {
  if (num) {
    return -1 * num;
  } else {
    throw new Error('missing input');
  }
}

1.13 no-extra-semi: disallow unnecessary semicolons.

// bad
;

1.14 no-func-assign: disallow reassigning function declarations.

// bad
function foo() {
 
}
foo = 'bar';

1.15 no-inner-declarations: disallow variable or function declarations in nested blocks.

const Foo = (function() {
  // good -> This is a function within a function
  function Foo() {
 
  }
  // good -> This is an instance method(same as declared with ES6-Class)
  Foo.prototype.compare = function compare(otherFoo) {
    return this === otherFoo;
  };
  return Foo;
}());
 
// good -> this is a global function
function createFoo() {
  return new Foo();
}
// bad -> function in nested block
if (foo) {
  function bar() {
 
  }
}

1.16 no-invalid-regexp: disallow invalid regular expression strings in RegExp constructors.

// good
'bar'.matches(/[a-z]*/);
// bad
'foo'.matches(/]a-z[*/);

1.17 no-irregular-whitespace: disallow irregular whitespace outside of strings and comments. Various whitespace characters can be inputted by programmers by mistake for example from copying or keyboard shortcuts. Pressing Alt + Space on OS X adds in a non breaking space character for example.

1.18 no-obj-calls: disallow calling global object properties as functions.

// bad
Math();

1.19 no-prototype-builtins: disallow calling some Object.prototype methods directly on objects.

// good
foo.hasOwnProperty('bar');
// bad
Object.prototype.hasOwnProperty.call(foo, 'bar');
 

1.20 no-regex-spaces: disallow multiple spaces in regular expressions.

// good
'  '.match(/ {2}/);
 
// better
'  '.match(/\s{2}/);
// bad
'  '.match(/  /);

1.21 no-sparse-arrays: disallow sparse arrays.

// good
const colors = [ "red", "blue", ];
colors.length === 2; // true
 
// bad
const colors = [ "red", ,"blue"];

1.22 no-unexpected-multiline: disallow confusing multiline expressions.

// good
const hello = 'world';
[1, 2, 3].forEach(addNumber);
 
// bad
const hello = 'world'
[1, 2, 3].forEach(addNumber);

1.23 no-unreachable: disallow unreachable code after return, throw, continue, and break statements.

// good
function foo() {
  console.log("done");
return true;
}
// bad
function foo() {
  return true;
  console.log("done");
}

1.24 no-unsafe-finally: disallow control flow statements in finally blocks.

// bad -> We expect this function to throw an error, then return
(() => {
  try {
    throw new Error("Try"); // error is thrown but suspended until finally block ends
  } finally {
    return 3; // 3 is returned before the error is thrown, which we did not expect
  }
})();

1.25 no-unsafe-negation: disallow negating the left operand of relational operators.

// good
if (!(key in object)) {
  // key is not in object
}
// bad
if (!key in object) {
  // equivalent to (!key) in object
}

1.26 use-isnan: require calls to isNaN() when checking for NaN.

// good
if (isNaN(foo)) {
 
}
// bad
if (foo == NaN) {
 
}

1.27 valid-typeof: enforce comparing typeof expressions against valid strings.

// good
if (typeof foo === 'string') {
 
}
// bad
if (typeof foo === 'strnng') {
 
}

Best practices

2.1 array-callback-return: enforce return statements in callbacks of array methods.

// good
list.forEach((element) => {
  process(element);
});
 
// good
list.map((element) => {
  return process(element);
});
// bad
list.map((element) => {
  process(element);
});

2.2 block-scoped-var: enforce the use of variables within the scope they are defined.

// good
function doIf() {
  var build;
 
  if (true) {
    build = true;
  }
 
console.log(build);
}
// bad
function doIf() {
  if (true) {
    var build = true;
  }
 
  console.log(build);
}

2.3 consistent-return: require return statements to either always or never specify values.

// good
function doSomething(condition) {
  if (condition) {
    return true;
  } else {
    return false;
  }
}
// bad
function doSomething(condition) {
  if (condition) {
    return true;
  } else {
    return;
  }
}

2.4 curly: enforce consistent brace style for all control statements.

// good
if (foo) {
  bar();
}
// bad
if (foo)
  bar();
else
  baz();

2.5 default-case: require default cases in switch statements.

// good
switch (weekday) {
  case 'Monday':
    break;
 
  default:
    break;
}
// bad
switch (weekday) {
  case 'Monday':
    break;
}

2.6 dot-location: enforce consistent newlines before property dots.

// good
document
.documentElement
// bad
document.
documentElement

2.7 dot-notation: enforce dot notation whenever possible.

// good
object.foo = true;
object[foo] = true;
object['foo bar'] = true;
// bad
object['foo'] = true;

2.8 eqeqeq: require the use of === and !== except for null-checks.

// good
if (foo == null) {
 
}
if (bar === 0) {
 
}
// bad
if (foo == 0) {
 
}

2.9 guard-for-in: require for-in loops to include an if statement.

// good
for (key in foo) {
  if (Object.prototype.hasOwnProperty.call(foo, key)) {
    doSomething(key);
  }
}
 
// better
Object.keys(foo).forEach((key) => {
  doSomething(key);
});
// bad
for (key in foo) {
  doSomething(key);
}

2.10 no-alert: disallow the use of alert, confirm, and prompt.

// bad
alert('Hello world');

2.11 no-caller: disallow the use of arguments.caller or arguments.callee.

// good
function factorial (n) {
  return !(> 1) ? 1 : factorial(- 1) * n;
}
 
[1, 2, 3, 4, 5].map(factorial);
// bad
[1, 2, 3, 4, 5].map(function(n) {
  return !(> 1) ? 1 : arguments.callee(- 1) * n;
});

2.12 no-case-declarations: disallow lexical declarations in case clauses.

// good
switch (foo) {
  case 1: {
    let x = 1;
    break;
  }
  default: {
    class C {}
  }
}
// bad
switch (foo) {
  case 1:
    let x = 1;
    break;
  default:
    class C {}
}

2.13 no-else-return: disallow else blocks after return statements in if statements.

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

2.14 no-empty-function: disallow empty functions.

// bad
function emptyFunc() {
 
}

2.15 no-empty-pattern: disallow empty destructuring patterns.

// good -> sets default value
var {a= {}} = foo;
// bad -> does not create a var
var {a: {}} = foo;

2.16 no-eval: disallow the use of eval().

// good
class Foo {
 
}
// bad
eval('class Foo {}');

2.17 no-extend-native: disallow extending native types.

// bad
Object.prototype.foo = 'bar';

2.18 no-extra-bind: disallow unnecessary calls to .bind().

// good
var boundGetName = (function getName() {
  return this.name;
}).bind({ name: "ESLint" });
 
console.log(boundGetName());
// bad  -> useless
var boundGetName = (function getName() {
  return "ESLint";
}).bind({ name: "ESLint" });
 
console.log(boundGetName());

2.19 no-extra-label: disallow unnecessary labels.

// bad
A: while (a) {
  break A;
}

2.20 no-fallthrough: disallow fallthrough of case statements.

// good
switch(foo) {
  case 1:
    doSomething();
    break;
 
  case 2:
    doSomething();
}
// bad
switch(foo) {
  case 1:
    doSomething();
 
  case 2:
    doSomething();
}

2.21 no-floating-decimal: disallow leading or trailing decimal points in numeric literals.

// good
var num = 0.5;
var num = 2.0;
var num = -0.7;
// bad
var num = .5;
var num = 2.;
var num = -.7;

2.22 no-global-assign: disallow assignments to native objects or read-only global variables.

// bad
undefined = null;

2.23 no-implied-eval: disallow the use of eval()-like methods.

// good
setTimeout("alert('This is like eval.');", 100);
// bad
setTimeout(() => {
  alert('This is not like eval.');
}, 100);

2.24 no-iterator: disallow the use of the __iterator__ property.

// bad
Foo.prototype.__iterator__ = function() {
  return new FooIterator(this);
};

2.25 no-labels: disallow labeled statements.

// bad
A: while (a) {
  break A;
}

2.26 no-lone-blocks: disallow unnecessary nested blocks.

// good
function bar() {
  baz();
}
// bad
function bar() {
  {
    baz();
  }
}

2.27 no-loop-func: disallow function declarations and expressions inside loop statements.

// good
do {
  function a() { return i; };
  a();
} while (i);

2.28 no-multi-spaces: disallow multiple spaces.

2.29 no-multi-str: disallow multiline strings.

// good
const blindText = `Lorem ipsum
et dolor`;
// good
const blindText = 'Lorem ipsum et dolor';
// bad
const blindText = 'Lorem ipsum \
et dolor';

2.30 no-new: disallow new operators outside of assignments or comparisons.

// good
var thing = new Thing();
 
Thing();
// bad
new Thing();

2.31 no-new-func: disallow new operators with the Function object.

// bad
var x = new Function("a", "b", "return a + b");

2.32 no-new-wrappers: disallow new operators with the String, Number, and Boolean objects.

// good
const stringObject = 'Hello world';
// bad
const stringObject = new String('Hello world');

2.33 no-octal: disallow octal literals.

// bad
const num = 071;
 

2.34 no-octal-escape: disallow octal escape sequences in string literals.

// good
const foo = "Copyright \u00A9";   // unicode
// bad
const foo = "Copyright \251"; // octal
 

2.35 no-param-reassign: disallow reassigning function parameters.

// bad
function foo(bar) {
  bar++;
}

2.36 no-proto: disallow the use of the __proto__ property.

// good
const a = Object.getPrototypeOf(obj);
// bad
const a = obj.__proto__;

2.37 no-redeclare: disallow variable redeclaration.

// good
let a = 3;
= 10;
// bad
let a = 3;
let a = 10;

2.38 no-return-assign: disallow assignment operators in return statements.

// bad
function doSomething() {
  return foo = bar + 2;
}
 

2.39 no-script-url: disallow javascript: urls.

// bad
location.href = "javascript:void(0)";

2.40 no-self-assign: disallow assignments where both sides are exactly the same.

// good
foo = bar;
// bad
foo = foo;

2.41 no-self-compare: disallow comparisons where both sides are exactly the same.

// bad
if (=== x) {
 
}

2.42 no-sequences: disallow comma operators.

// good -> init and update of for is an exception
for (= 0, j = 10; i < j; i++, j--);
// bad -> use && instead
while (val = foo(), val < 42);

2.43 no-throw-literal: disallow throwing literals as exceptions.

// good
throw new Error('error');
// bad
throw 'error';

2.44 no-unused-expressions: disallow unused expressions.

// good
? b() : c();
// bad
? b : 0;

2.45 no-unused-labels: disallow unused labels.

// good
A: {
  if (foo()) {
    break A;
  }
  bar();
}
// bad
A: var foo = 0;

2.46 no-useless-call: disallow unnecessary calls to .call() and .apply().

// good
foo.call(obj, 1, 2, 3);
// bad
foo.call(undefined, 1, 2, 3);

2.47 no-useless-concat: disallow unnecessary concatenation of literals or template literals.

// good
const a = a + '1';
// bad
const a = `some` + `string`;

2.48 no-useless-escape: disallow unnecessary escape characters.

// bad
let foo = "hol\a"; // > foo = "hola"

2.49 no-useless-return: disallow redundant return statements.

// good
function foo() {
  doSomething();
}
// bad
function foo() {
  doSomething();
  return;
}

2.50 no-void: disallow void operators.

// bad
var foo = void bar();

2.51 no-with: disallow with statements.

// bad
with (point) {
  r = Math.sqrt(* x + y * y); // is r a member of point?
}

2.52 radix: enforce the consistent use of the radix argument when using parseInt().

// good
parseInt('2000', 10);
// bad
parseInt('2000');

2.53 vars-on-top: require var declarations to be placed at the top of their containing scope.

// good
function doSomething() {
  var first;
  var second;
  if (true) {
    first = true;
  }
}
// bad
function doSomething() {
  var first;
  if (true) {
    first = true;
  }
  var second;
}

2.54 wrap-iife: require parentheses around immediate function invocations.

// good
var x = (function () { return { y: 1 };}());
// bad
var x = function () { return { y: 1 };}();
var x = (function () { return { y: 1 };})();

2.55 yoda: disallow “Yoda” conditions.

// good
if (color === 'red') {
  // ...
}
// bad
if ('red' === color) {
  // ...
}

Strict

Variables

4.1 no-delete-var: disallow deleting variables.

// bad
var x;
delete x;

4.2 no-label-var: disallow labels that share a name with a variable.

// bad
var x = foo;
function bar() {
x:
  for (;;) {
    break x;
  }
}

4.3 no-shadow: disallow variable declarations from shadowing variables declared in the outer scope.

// bad
var a = 3;
function b() {
  var a = 10;
}

4.4 no-shadow-restricted-names: disallow identifiers from shadowing restricted names.

// bad
function NaN(){}

4.5 no-undef: disallow the use of undeclared variables unless mentioned in /*global */ comments.

// good
const b = 10;
// bad
= 10;

4.6 no-undef-init: disallow initializing variables to undefined.

// good
const undef = undefined;
// bad
let undef = undefined;

4.7 no-unused-vars: disallow unused variables.

// good
var y = 10;
processSomehow(y);
// bad
var y = 10;
= 2;

4.8 no-use-before-define: disallow the use of variables before they are defined.

// bad
processSomehow(y);
var y = 10;

Node.Js and CommonJS

5.1 global-require: require require() calls to be placed at top-level module scope.

// good
var fs = require("fs");
// bad
function foo() {
  if (condition) {
    var fs = require("fs");
  }
}

5.2 no-new-require: disallow new operators with calls to require.

// good
var AppHeader = require('app-header');
var appHeader = new AppHeader();
// bad
var appHeader = new require('app-header');

5.3 no-path-concat: disallow string concatenation with __dirname and __filename.

// good
var fullPath = path.join(__dirname, "foo.js");
// bad
var fullPath = __dirname + "/foo.js";

Stylistic Issues

6.1 array-bracket-spacing: enforce no spacing inside array brackets.

// good
var arr = ['foo', 'bar'];
var [x, y] = z;
// bad
var arr = [ 'foo', 'bar' ];
var [ x, y ] = z;

6.2 block-spacing: enforce consistent spacing inside single-line blocks.

// good
function foo() { return true; }
if (foo) { bar = 0; }
// bad
function foo() {return true;}
if (foo) {bar = 0;}

6.3 brace-style: enforce consistent brace style for blocks(1TBS).

// good
if (foo) {
  bar();
} else {
  baz();
}
// bad
if (foo) {
  bar();
}
else {
  baz();
}

6.4 camelcase: enforce camelcase naming convention.

// good
const camelCase = 'good';
// bad
const snake_case = 'bad';

6.5 comma-dangle: require or disallow trailing commas.

// good
const foo = {
  bar: 'baz',
  qux: 'quux',
};
// bad
const foo = {
  bar: 'baz',
  qux: 'quux'
};

6.6 comma-spacing: enforce consistent spacing before and after commas.

// good
const arr = [1, 2];
// bad
const arr = [1 , 2];

6.7 comma-style: enforce consistent comma style.

// good
function bar() {
  return {
    'a': 1,
    'b:': 2
  };
}
// bad
function bar() {
  return {
    'a': 1
    ,'b:': 2
  };
}

6.8 computed-property-spacing: enforce consistent spacing inside computed property brackets.

// good
obj[key]
// bad
obj[ key]

6.9 eol-last: require or disallow newline at the end of files.

6.10 func-name-matching: require function names to match the name of the variable or property to which they are assigned.

// good
var foo = function bar() {};
// bad
var foo = function foo() {};

6.11 func-names: require or disallow named function expressions.

// good
arr.filter(function isEven(a) {
  return (% 2) === 0;
});
// bad
arr.filter(function(a) {
  return (% 2) === 0;
});

6.12 indent: enforce consistent indentation(2 spaces).

6.13 key-spacing: enforce consistent spacing between keys and values in object literal properties.

// good
var obj = { "foo": 42 };
 
// bad
var obj = { "foo" : 42 };

6.14 keyword-spacing: enforce consistent spacing before and after keywords.

// good
if (foo) {
  //...
} else if (bar) {
  //...
} else {
  //...
}
// bad
if (foo) {
  //...
}else if (bar) {
  //...
} else{
  //...
}

6.15 linebreak-style: enforce consistent linebreak style(unix -> LF instead of CRLF)

6.16 max-len: enforce a maximum line length of 100 characters.

6.17 new-cap: require constructor names to begin with a capital letter.

// good
const c = new Constructor();
// bad
const c = new constructor();

6.18 new-parens: require parentheses when invoking a constructor with no arguments.

// good
const c = new Constructor();
// bad
const c = new Constructor;

6.19 newline-per-chained-call: require a newline after each call in a method chain.

// good
doSomething()
.then(()=> {
  // ..
});
 
// bad
doSomething().then(()=> {
  // ..
});

6.20 no-array-constructor: disallow Array constructors.

// bad
new Array(0, 1, 2)

6.21 no-continue: disallow continue statements.

// bad
continue;

6.22 no-lonely-if: disallow if statements as the only statement in else blocks.

// good
if (foo) {
  // ...
} else if (bar) {
    // ...
  }
}
// bad
if (foo) {
  // ...
} else {
  if (bar) {
    // ...
  }
}

6.23 no-mixed-operators: disallow mixed binary operators.

// good
let i = 2 + (2 * 2);
// bad
let i = 2 + 2 * 2;

6.24 no-mixed-spaces-and-tabs: disallow mixed spaces and tabs for indentation.

6.25 no-multi-assign: disallow use of chained assignment expressions.

// bad
var a = b = c = 5;

6.26 no-multiple-empty-lines: disallow multiple empty lines.

// good
doSomething();
 
doSomeOtherThing();
yetAnotherThing();
// bad
doSomething();
 
 
doSomeOtherThing();

6.27 no-nested-ternary: disallow nested ternary expressions.

// bad
var foo = bar ? baz : qux === quxx ? bing : bam;

6.28 no-new-object: disallow Object constructors.

// good
var myObject = {};
// bad
var myObject = new Object();

6.29 no-restricted-syntax: disallow specified syntax(e.g. debugger, with, labels)

6.30 no-underscore-dangle: disallow dangling underscores in identifiers.

// bad
var _foo;

6.31 no-unneeded-ternary: disallow ternary operators when simpler alternatives exist.

// good
const a = Boolean(condition);
// bad
const a = (condition) ? true : false;

6.32 no-whitespace-before-property: disallow whitespace before properties.

// good
foo.bar.baz.quz
// bad
foo. bar .baz . quz

6.33 object-curly-spacing: enforce consistent spacing inside braces.

// good
var obj = {'foo': 'bar'};
// bad
var obj = { 'foo': 'bar' };

6.34 object-property-newline: enforce placing object properties on separate lines.

// good
var obj = {
  foo: "foo",
  bar: "bar",
  baz: "baz"
};
// bad
var obj = {foo: "foo", bar: "bar", baz: "baz"};

6.35 one-var: enforce variables to be declared separately in functions.

// good
var bar;
var baz;
// bad
var bar, baz;

6.36 one-var-declaration-per-line: require or disallow newlines around variable declarations.

// good
const a = 0,
  b = 0;
// bad
const a = 0,  b = 0;

6.37 operator-assignment: require or disallow assignment operator shorthand where possible.

// good
+= y;
// bad
= x + y;

6.38 padded-blocks: disallow padding within blocks.

// good
if (a) {
  b();
}
// bad
if (a) {
 
  b();
 
}

6.39 quote-props: require quotes around object literal property names if needed, otherwise forbid them.

// good
var object1 = {
  "a-b": 0,
  "0x0": 0,
  "1e2": 0,
  foo: 0,
};
// bad
var object = {
  "a": 0,
  "0": 0,
  "true": 0,
  "null": 0
};

6.40 quotes: enforce the consistent use of single quotes. Template-Strings are still allowed(if they contain a JS-Expression).

// good
const hw = 'Hello world';
// good
const hw2 = `${greet()} world`;
// bad
const hw = "Hello world";
// bad
const hw2 = `Hello world`;

6.41 semi: require semicolons instead of ASI(automatic semicolon insertion).

// good
var name = "ESLint";
// bad
var name = "ESLint"

6.42 semi-spacing: enforce consistent spacing before and after semicolons.

// good
var foo;
// bad
var foo ;

6.43 space-before-blocks: enforce consistent spacing before blocks.

// good
if (a) {
  b();
}
// bad
if (a){
  b();
}

6.44 space-before-function-paren: disallow spacing before function definition opening parenthesis(except for anonymous functions).

// good
function foo() {
  return function () {
 
  }
};
 
// bad
function foo () {
  // ...
};
 

6.45 space-in-parens: enforce consistent spacing inside parentheses.

// good
foo('bar');
// bad
foo( 'bar');
foo('bar' );
foo( 'bar' );

6.46 space-infix-ops: require spacing around infix operators.

// good
+ b
// bad
a+b

6.47 space-unary-ops: enforce consistent spacing before or after unary operators.

// good
typeof (foo);
// bad
typeof(foo);

6.48 spaced-comment: enforce consistent spacing after the // or /* in a comment.

// good
// This is a comment with a whitespace at the beginning
// bad
//This is a comment with no whitespace at the beginning

6.49 unicode-bom: require or disallow Unicode byte order mark (BOM).

The Unicode Byte Order Mark (BOM) is used to specify whether code units are big endian or little endian. That is, whether the most significant or least significant bytes come first. UTF-8 does not require a BOM because byte ordering does not matter when characters are a single byte. Since UTF-8 is the dominant encoding of the web, we make "never" the default option.

ECMAScript 6

7.1 arrow-body-style: require braces around arrow function bodies.

// good
const foo = () => {
  return 0;
};
// bad
const foo = () => 0;

7.2 arrow-spacing: enforce consistent spacing before and after the arrow in arrow functions.

// good
() => {};
// bad
()=> {};
() =>{};
()=>{};

7.3 constructor-super: require super() calls in constructors.

// good
class A {
  constructor() { }
}
// good
class A extends B {
  constructor() {
    super();
  }
}
// bad
class A {
  constructor() {
    super();
  }
}
// bad
class A extends B {
  constructor() { }
}

7.4 generator-star-spacing: enforce consistent spacing behind * operators in generator functions.

// good
function* generator() {}
// bad
function *generator() {}

7.5 no-class-assign: disallow reassigning class members.

// good
let A = class A { }
A = 0;
 
// bad
class A { }
A = 0;

7.6 no-confusing-arrow: disallow arrow functions where they could be confused with comparisons.

// good
var x = a => 1 ? 2 : 3;
// bad
var x = a => { return 1 ? 2 : 3; };

7.7 no-const-assign: disallow reassigning const variables.

// bad
const a = 0;
= 1;

7.8 no-dupe-class-members: disallow duplicate class members.

// bad
class Foo {
  bar() { }
  bar() { }
}

7.9 no-duplicate-imports: disallow duplicate module imports.

// good
import {merge, find} from 'module';
// bad
import {merge} from 'module';
import {find} from 'module';

7.10 no-new-symbol: disallow new operators with the Symbol object.

// bad
var foo = new Symbol('foo');

7.11 no-this-before-super: disallow this/super before calling super() in constructors.

// good
class A extends B {
  constructor() {
    super();
    this.a = 0;
  }
}
// bad
class A extends B {
  constructor() {
    this.a = 0;
    super();
  }
}

7.12 no-useless-computed-key: disallow unnecessary computed property keys in object literals.

// good
var a = { x: 0 };
// bad
var a = { ['x']: 0 };

7.13 no-useless-constructor: disallow unnecessary constructors.

// good
class A {
  constructor () {
    doSomething();
  }
}
// bad
class A {
  constructor () {
  }
}

7.14 no-useless-rename: disallow renaming import, export, and destructured assignments to the same name.

// good
import { foo } from "bar";
// bad
import { foo as foo } from "bar";

7.15 no-var: require let or const instead of var.

// good
let foo;
const bar;
// bad
var qux;

7.16 object-shorthand: require or disallow method and property shorthand syntax for object literals.

// good
var foo = {
  "bar-baz": function() {},
  "qux": qux
};
// bad
var foo = {
  "bar-baz"() {}
};

7.17 prefer-arrow-callback: require arrow functions as callbacks.

// good
app.get((req, res, next) => {
  res.send(this.response);
});
// bad
app.get(function (req, res, next) {
  res.send(this.response); // this is not what you might expect here
});

7.18 prefer-const: require const declarations for variables that are never reassigned after declared.

// good
const pi = 3.14;
// bad
let pi = 3.14

7.19 prefer-numeric-literals: disallow parseInt() in favor of binary, octal, and hexadecimal literals.

// bad
parseInt("111110111", 2) === 503;

7.20 prefer-rest-params: require rest parameters instead of arguments.

// good
function foo(...args) {
  console.log(args);
}
// bad
function foo() {
  console.log(arguments);
}

7.21 prefer-spread: require spread operators instead of .apply().

// good
foo(...args);
// bad
foo.apply(undefined, args);

7.22 prefer-template: require template literals instead of string concatenation.

// good
var str = `Hello ${name}!`;
// bad
var str = 'Hello, ' + name + '!';

7.23 require-yield: require generator functions to contain yield.

// good
function* foo() {
  yield 5;
  return 10;
}
 
// bad
function* foo() {
  return 10;
}

7.24 rest-spread-spacing: enforce spacing between rest and spread operators and their expressions.

// good
fn(...args)
// bad
fn(... args)

7.25 template-curly-spacing: disallow spacing around embedded expressions of template strings.

// good
`hello, ${people.name}!`;
// bad
`hello, ${ people.name}!`;

7.26 yield-star-spacing: require spacing after the * in yield* expressions.

// good
function* generator() {
  yield* other();
}

Readme

Keywords

Package Sidebar

Install

npm i eslint-config-5minds

Weekly Downloads

3

Version

1.0.2

License

SEE LICENSE IN LICENSE.md

Unpacked Size

43.4 kB

Total Files

5

Last publish

Collaborators

  • moellenbeck
  • obivarg