mountain-pass/addressr

View on GitHub
loader.js

Summary

Maintainability
A
0 mins
Test Coverage

Don't use process.exit(); throw an error instead.
Open

    process.exit()
Severity: Minor
Found in loader.js by eslint

Disallow process.exit() (no-process-exit)

The process.exit() method in Node.js is used to immediately stop the Node.js process and exit. This is a dangerous operation because it can occur in any method at any point in time, potentially stopping a Node.js application completely when an error occurs. For example:

if (somethingBadHappened) {
    console.error("Something bad happened!");
    process.exit(1);
}

This code could appear in any module and will stop the entire application when somethingBadHappened is truthy. This doesn't give the application any chance to respond to the error. It's usually better to throw an error and allow the application to handle it appropriately:

if (somethingBadHappened) {
    throw new Error("Something bad happened!");
}

By throwing an error in this way, other parts of the application have an opportunity to handle the error rather than stopping the application altogether. If the error bubbles all the way up to the process without being handled, then the process will exit and a non-zero exit code will returned, so the end result is the same.

If you are using process.exit() only for specifying the exit code, you can set process.exitCode (introduced in Node.js 0.11.8) instead.

Rule Details

This rule aims to prevent the use of process.exit() in Node.js JavaScript. As such, it warns whenever process.exit() is found in code.

Examples of incorrect code for this rule:

/*eslint no-process-exit: "error"*/

process.exit(1);
process.exit(0);

Examples of correct code for this rule:

/*eslint no-process-exit: "error"*/

Process.exit();
var exit = process.exit;

When Not To Use It

There may be a part of a Node.js application that is responsible for determining the correct exit code to return upon exiting. In that case, you should turn this rule off to allow proper handling of the exit code. Source: http://eslint.org/docs/rules/

Definition for rule 'unicorn/filename-case' was not found.
Open

import debug from 'debug'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    console.log('======================')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    logger(`Fin`)
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

import { esConnect } from './client/elasticsearch'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    printVersion()
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Each then() should return a value or throw
Open

  .then(() => {
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    console.log('======================')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

const error = debug('error')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    console.log('Addressr - Data Loader')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    const end = process.hrtime(start)
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Definition for rule 'unicorn/prevent-abbreviations' was not found.
Open

import debug from 'debug'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    throw error_
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Definition for rule 'unicorn/no-null' was not found.
Open

import debug from 'debug'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    logger('data loaded')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    logger('es client connected')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

const logger = debug('api')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Each then() should return a value or throw
Open

  .then(() => {
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    process.exit()
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Each then() should return a value or throw
Open

  .then(() => {
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

  debug.enable('api,error')
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

import { loadGnaf } from './service/address-service'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

import { printVersion } from './service/printVersion'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Each then() should return a value or throw
Open

  .then(() => {
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace error_ with (error_)
Open

  .catch(error_ => {
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Each then() should return a value or throw
Open

  .then(() => {
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    logger(`Execution time: ${end[0]}s ${end[1] / 1000000}ms`)
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

  })
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Definition for rule 'unicorn/no-process-exit' was not found.
Open

import debug from 'debug'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

import debug from 'debug'
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

    error('error loading data', error_)
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert ;
Open

const start = process.hrtime()
Severity: Minor
Found in loader.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

There are no issues that match your filters.

Category
Status