GillesRasigade/pattern

View on GitHub
src/Queue/QueueRedis.js

Summary

Maintainability
A
0 mins
Test Coverage

This generator function does not have 'yield'.
Open

    return co(function* connect() {
Severity: Minor
Found in src/Queue/QueueRedis.js by eslint

Disallow generator functions that do not have yield (require-yield)

Rule Details

This rule generates warnings for generator functions that do not have the yield keyword.

Examples

Examples of incorrect code for this rule:

/*eslint require-yield: "error"*/
/*eslint-env es6*/

function* foo() {
  return 10;
}

Examples of correct code for this rule:

/*eslint require-yield: "error"*/
/*eslint-env es6*/

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

function foo() {
  return 10;
}

// This rule does not warn on empty generator functions.
function* foo() { }

When Not To Use It

If you don't want to notify generator functions that have no yield expression, then it's safe to disable this rule.

Related Rules

Use the spread operator instead of '.apply()'.
Open

      func.apply(null, args);
Severity: Minor
Found in src/Queue/QueueRedis.js by eslint

Suggest using the spread operator instead of .apply(). (prefer-spread)

Before ES2015, one must use Function.prototype.apply() to call variadic functions.

var args = [1, 2, 3, 4];
Math.max.apply(Math, args);

In ES2015, one can use the spread operator to call variadic functions.

/*eslint-env es6*/

var args = [1, 2, 3, 4];
Math.max(...args);

Rule Details

This rule is aimed to flag usage of Function.prototype.apply() in situations where the spread operator could be used instead.

Examples

Examples of incorrect code for this rule:

/*eslint prefer-spread: "error"*/

foo.apply(undefined, args);
foo.apply(null, args);
obj.foo.apply(obj, args);

Examples of correct code for this rule:

/*eslint prefer-spread: "error"*/

// Using the spread operator
foo(...args);
obj.foo(...args);

// The `this` binding is different.
foo.apply(obj, args);
obj.foo.apply(null, args);
obj.foo.apply(otherObj, args);

// The argument list is not variadic.
// Those are warned by the `no-useless-call` rule.
foo.apply(undefined, [1, 2, 3]);
foo.apply(null, [1, 2, 3]);
obj.foo.apply(obj, [1, 2, 3]);

Known limitations:

This rule analyzes code statically to check whether or not the this argument is changed. So, if the this argument is computed in a dynamic expression, this rule cannot detect a violation.

/*eslint prefer-spread: "error"*/

// This warns.
a[i++].foo.apply(a[i++], args);

// This does not warn.
a[++i].foo.apply(a[i], args);

When Not To Use It

This rule should not be used in ES3/5 environments.

In ES2015 (ES6) or later, if you don't want to be notified about Function.prototype.apply() callings, you can safely disable this rule.

Related Rules

There are no issues that match your filters.

Category
Status