nponiros/sync_server

View on GitHub

Showing 43 of 43 total issues

Expected the Promise rejection reason to be an Error.
Open

            reject();
Severity: Minor
Found in lib/db_connectors/NeDB/db.js by eslint

require using Error objects as Promise rejection reasons (prefer-promise-reject-errors)

It is considered good practice to only pass instances of the built-in Error object to the reject() function for user-defined errors in Promises. Error objects automatically store a stack trace, which can be used to debug an error by determining where it came from. If a Promise is rejected with a non-Error value, it can be difficult to determine where the rejection occurred.

Rule Details

This rule aims to ensure that Promises are only rejected with Error objects.

Options

This rule takes one optional object argument:

  • allowEmptyReject: true (false by default) allows calls to Promise.reject() with no arguments.

Examples of incorrect code for this rule:

/*eslint prefer-promise-reject-errors: "error"*/

Promise.reject("something bad happened");

Promise.reject(5);

Promise.reject();

new Promise(function(resolve, reject) {
  reject("something bad happened");
});

new Promise(function(resolve, reject) {
  reject();
});

Examples of correct code for this rule:

/*eslint prefer-promise-reject-errors: "error"*/

Promise.reject(new Error("something bad happened"));

Promise.reject(new TypeError("something bad happened"));

new Promise(function(resolve, reject) {
  reject(new Error("something bad happened"));
});

var foo = getUnknownValue();
Promise.reject(foo);

Examples of correct code for this rule with the allowEmptyReject: true option:

/*eslint prefer-promise-reject-errors: ["error", {"allowEmptyReject": true}]*/

Promise.reject();

new Promise(function(resolve, reject) {
  reject();
});

Known Limitations

Due to the limits of static analysis, this rule cannot guarantee that you will only reject Promises with Error objects. While the rule will report cases where it can guarantee that the rejection reason is clearly not an Error, it will not report cases where there is uncertainty about whether a given reason is an Error. For more information on this caveat, see the similar limitations in the no-throw-literal rule.

To avoid conflicts between rules, this rule does not report non-error values used in throw statements in async functions, even though these lead to Promise rejections. To lint for these cases, use the no-throw-literal rule.

When Not To Use It

If you're using custom non-error values as Promise rejection reasons, you can turn off this rule.

Further Reading

A space is required before '}'.
Open

        obj: {item: input.value},
Severity: Minor
Found in samples/ajax/index.js by eslint

enforce consistent spacing inside braces (object-curly-spacing)

While formatting preferences are very personal, a number of style guides require or disallow spaces between curly braces in the following situations:

// simple object literals
var obj = { foo: "bar" };

// nested object literals
var obj = { foo: { zoo: "bar" } };

// destructuring assignment (EcmaScript 6)
var { x, y } = y;

// import/export declarations (EcmaScript 6)
import { foo } from "bar";
export { foo };

Rule Details

This rule enforce consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers.

Options

This rule has two options, a string option and an object option.

String option:

  • "never" (default) disallows spacing inside of braces
  • "always" requires spacing inside of braces (except {})

Object option:

  • "arraysInObjects": true requires spacing inside of braces of objects beginning and/or ending with an array element (applies when the first option is set to never)
  • "arraysInObjects": false disallows spacing inside of braces of objects beginning and/or ending with an array element (applies when the first option is set to always)
  • "objectsInObjects": true requires spacing inside of braces of objects beginning and/or ending with an object element (applies when the first option is set to never)
  • "objectsInObjects": false disallows spacing inside of braces of objects beginning and/or ending with an object element (applies when the first option is set to always)

never

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

/*eslint object-curly-spacing: ["error", "never"]*/

var obj = { 'foo': 'bar' };
var obj = {'foo': 'bar' };
var obj = { baz: {'foo': 'qux'}, bar};
var obj = {baz: { 'foo': 'qux'}, bar};
var {x } = y;
import { foo } from 'bar';

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

/*eslint object-curly-spacing: ["error", "never"]*/

var obj = {'foo': 'bar'};
var obj = {'foo': {'bar': 'baz'}, 'qux': 'quxx'};
var obj = {
  'foo': 'bar'
};
var obj = {'foo': 'bar'
};
var obj = {
  'foo':'bar'};
var obj = {};
var {x} = y;
import {foo} from 'bar';

always

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

/*eslint object-curly-spacing: ["error", "always"]*/

var obj = {'foo': 'bar'};
var obj = {'foo': 'bar' };
var obj = { baz: {'foo': 'qux'}, bar};
var obj = {baz: { 'foo': 'qux' }, bar};
var obj = {'foo': 'bar'
};
var obj = {
  'foo':'bar'};
var {x} = y;
import {foo } from 'bar';

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

/*eslint object-curly-spacing: ["error", "always"]*/

var obj = {};
var obj = { 'foo': 'bar' };
var obj = { 'foo': { 'bar': 'baz' }, 'qux': 'quxx' };
var obj = {
  'foo': 'bar'
};
var { x } = y;
import { foo } from 'bar';

arraysInObjects

Examples of additional correct code for this rule with the "never", { "arraysInObjects": true } options:

/*eslint object-curly-spacing: ["error", "never", { "arraysInObjects": true }]*/

var obj = {"foo": [ 1, 2 ] };
var obj = {"foo": [ "baz", "bar" ] };

Examples of additional correct code for this rule with the "always", { "arraysInObjects": false } options:

/*eslint object-curly-spacing: ["error", "always", { "arraysInObjects": false }]*/

var obj = { "foo": [ 1, 2 ]};
var obj = { "foo": [ "baz", "bar" ]};

objectsInObjects

Examples of additional correct code for this rule with the "never", { "objectsInObjects": true } options:

/*eslint object-curly-spacing: ["error", "never", { "objectsInObjects": true }]*/

var obj = {"foo": {"baz": 1, "bar": 2} };

Examples of additional correct code for this rule with the "always", { "objectsInObjects": false } options:

/*eslint object-curly-spacing: ["error", "always", { "objectsInObjects": false }]*/

var obj = { "foo": { "baz": 1, "bar": 2 }};

When Not To Use It

You can turn this rule off if you are not concerned with the consistency of spacing between curly braces.

Related Rules

TODO found
Open

## TODO
Severity: Minor
Found in README.md by fixme
Severity
Category
Status
Source
Language