Apollon77/meross-cloud

View on GitHub

Showing 41 of 52 total issues

File index.js has 632 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* jshint -W097 */
/* jshint -W030 */
/* jshint strict:true */
/* jslint node: true */
/* jslint esversion: 6 */
Severity: Major
Found in index.js - About 1 day to fix

    MerossCloudDevice has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MerossCloudDevice extends EventEmitter {
    
        constructor(cloudInstance, dev) {
            super();
    
    
    Severity: Minor
    Found in index.js - About 5 hrs to fix

      Function initMqtt has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          initMqtt(dev) {
              const domain = dev.domain || this.mqttDomain; // reservedDomain ???
              if (!this.mqttConnections[domain] || !this.mqttConnections[domain].client) {
                  const appId = crypto.createHash('md5').update(`API${uuidv4()}`).digest("hex");
                  const clientId = `app:${appId}`;
      Severity: Major
      Found in index.js - About 3 hrs to fix

        Function login has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            login(callback) {
                if (!this.options.email) {
                    return callback && callback(new Error('Email missing'));
                }
                if (!this.options.password) {
        Severity: Minor
        Found in index.js - About 1 hr to fix

          Function initMqtt has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              initMqtt(dev) {
                  const domain = dev.domain || this.mqttDomain; // reservedDomain ???
                  if (!this.mqttConnections[domain] || !this.mqttConnections[domain].client) {
                      const appId = crypto.createHash('md5').update(`API${uuidv4()}`).digest("hex");
                      const clientId = `app:${appId}`;
          Severity: Minor
          Found in index.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function handleMessage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              handleMessage(message) {
                  if (!this.deviceConnected) return;
                  if (!message || !message.header) return;
                  if (message && message.header && message.header.from && !message.header.from.includes(this.dev.uuid)) return;
                  // {"header":{"messageId":"14b4951d0627ea904dd8685c480b7b2e","namespace":"Appliance.Control.ToggleX","method":"PUSH","payloadVersion":1,"from":"/appliance/1806299596727829081434298f15a991/publish","timestamp":1539602435,"timestampMs":427,"sign":"f33bb034ac2d5d39289e6fa3dcead081"},"payload":{"togglex":[{"channel":0,"onoff":0,"lmTime":1539602434},{"channel":1,"onoff":0,"lmTime":1539602434},{"channel":2,"onoff":0,"lmTime":1539602434},{"channel":3,"onoff":0,"lmTime":1539602434},{"channel":4,"onoff":0,"lmTime":1539602434}]}}
          Severity: Minor
          Found in index.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Consider simplifying this complex logical expression.
          Open

                  if (this.localHttpFirst && ip) {
                      this.sendMessageHttp(dev, ip, data, err => {
                          let res = !err;
                          const isGetMessage = data && data.header && data.header.method === 'GET';
                          let resendToCloud = !isGetMessage || (isGetMessage && !this.onlyLocalForGet);
          Severity: Critical
          Found in index.js - About 1 hr to fix

            Function constructor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                constructor(options) {
                    super();
            
                    this.options = options || {};
                    this.token = null;
            Severity: Minor
            Found in index.js - About 1 hr to fix

              Function getDevices has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  getDevices(callback) {
                      this.options.logger && this.options.logger(`Get Devices from Meross cloud server`);
                      this.authenticatedPost(DEV_LIST, {}, (err, deviceList) => {
                          if (err) {
                              callback && callback(err);
              Severity: Minor
              Found in index.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                        if (!this.mqttConnections[domain] || !this.mqttConnections[domain].client) {
                            const appId = crypto.createHash('md5').update(`API${uuidv4()}`).digest("hex");
                            const clientId = `app:${appId}`;
                
                            // Password is calculated as the MD5 of USERID concatenated with KEY
                Severity: Major
                Found in index.js - About 1 hr to fix

                  Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      constructor(options) {
                          super();
                  
                          this.options = options || {};
                          this.token = null;
                  Severity: Minor
                  Found in index.js - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Consider simplifying this complex logical expression.
                  Open

                              if (!error && response && response.statusCode === 200 && body) {
                                  this.options.logger && this.options.logger(`HTTP-Response (${requestCounter}) OK: ${body}`);
                                  try {
                                      body = JSON.parse(body);
                                  }
                  Severity: Major
                  Found in index.js - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if (!error && response && response.statusCode === 200 && body) {
                                    this.options.logger && this.options.logger(`HTTP-Local-Response OK ${dev.uuid}: ${JSON.stringify(body)}`);
                                    if (body) {
                                        setImmediate(() => {
                                            this.devices[dev.uuid].handleMessage(body);
                    Severity: Major
                    Found in index.js - About 40 mins to fix

                      Expected an assignment or function call and instead saw an expression.
                      Open

                                      this.options.logger && this.options.logger(`Can not reuse former token because email/password are different!`);
                      Severity: Minor
                      Found in index.js by eslint

                      Disallow Unused Expressions (no-unused-expressions)

                      An unused expression which has no effect on the state of the program indicates a logic error.

                      For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                      Rule Details

                      This rule aims to eliminate unused expressions which have no effect on the state of the program.

                      This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                      var i = 0;
                      function increment() { i += 1; }
                      increment(); // return value is unused, but i changed as a side effect
                      
                      var nThings = 0;
                      function Thing() { nThings += 1; }
                      new Thing(); // constructed object is unused, but nThings changed as a side effect

                      This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                      Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                      Options

                      This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                      • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                      • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                      • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                      These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                      Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      0
                      
                      if(0) 0
                      
                      {0}
                      
                      f(0), {}
                      
                      a && b()
                      
                      a, b()
                      
                      c = a, b;
                      
                      a() && function namedFunctionInExpressionContext () {f();}
                      
                      (function anIncompleteIIFE () {});
                      
                      injectGlobal`body{ color: red; }`

                      Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                      "use strict";
                      "use asm"
                      "use stricter";
                      "use babel"
                      "any other strings like this in the prologue";

                      Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      {} // In this context, this is a block statement, not an object literal
                      
                      {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                      
                      function namedFunctionDeclaration () {}
                      
                      (function aGenuineIIFE () {}());
                      
                      f()
                      
                      a = 0
                      
                      new C
                      
                      delete a.b
                      
                      void a

                      allowShortCircuit

                      Examples of incorrect code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a || b

                      Examples of correct code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a && b()
                      a() || (b = c)

                      allowTernary

                      Examples of incorrect code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b : 0
                      a ? b : c()

                      Examples of correct code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b() : c()
                      a ? (b = c) : d()

                      allowShortCircuit and allowTernary

                      Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                      
                      a ? b() || (c = d) : e()

                      allowTaggedTemplates

                      Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      `some untagged template string`;

                      Examples of correct code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      tag`some tagged template string`;

                      Source: http://eslint.org/docs/rules/

                      Expected an assignment or function call and instead saw an expression.
                      Open

                                          this.options.logger && this.options.logger(`Pre-existing token seems invalid ... Doing login`);
                      Severity: Minor
                      Found in index.js by eslint

                      Disallow Unused Expressions (no-unused-expressions)

                      An unused expression which has no effect on the state of the program indicates a logic error.

                      For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                      Rule Details

                      This rule aims to eliminate unused expressions which have no effect on the state of the program.

                      This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                      var i = 0;
                      function increment() { i += 1; }
                      increment(); // return value is unused, but i changed as a side effect
                      
                      var nThings = 0;
                      function Thing() { nThings += 1; }
                      new Thing(); // constructed object is unused, but nThings changed as a side effect

                      This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                      Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                      Options

                      This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                      • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                      • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                      • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                      These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                      Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      0
                      
                      if(0) 0
                      
                      {0}
                      
                      f(0), {}
                      
                      a && b()
                      
                      a, b()
                      
                      c = a, b;
                      
                      a() && function namedFunctionInExpressionContext () {f();}
                      
                      (function anIncompleteIIFE () {});
                      
                      injectGlobal`body{ color: red; }`

                      Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                      "use strict";
                      "use asm"
                      "use stricter";
                      "use babel"
                      "any other strings like this in the prologue";

                      Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      {} // In this context, this is a block statement, not an object literal
                      
                      {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                      
                      function namedFunctionDeclaration () {}
                      
                      (function aGenuineIIFE () {}());
                      
                      f()
                      
                      a = 0
                      
                      new C
                      
                      delete a.b
                      
                      void a

                      allowShortCircuit

                      Examples of incorrect code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a || b

                      Examples of correct code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a && b()
                      a() || (b = c)

                      allowTernary

                      Examples of incorrect code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b : 0
                      a ? b : c()

                      Examples of correct code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b() : c()
                      a ? (b = c) : d()

                      allowShortCircuit and allowTernary

                      Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                      
                      a ? b() || (c = d) : e()

                      allowTaggedTemplates

                      Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      `some untagged template string`;

                      Examples of correct code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      tag`some tagged template string`;

                      Source: http://eslint.org/docs/rules/

                      Expected return with your callback function.
                      Open

                                          callback && callback(err, deviceListLength);
                      Severity: Minor
                      Found in index.js by eslint

                      Enforce Return After Callback (callback-return)

                      The callback pattern is at the heart of most I/O and event-driven programming in JavaScript.

                      function doSomething(err, callback) {
                          if (err) {
                              return callback(err);
                          }
                          callback();
                      }

                      To prevent calling the callback multiple times it is important to return anytime the callback is triggered outside of the main function body. Neglecting this technique often leads to issues where you do something more than once. For example, in the case of an HTTP request, you may try to send HTTP headers more than once leading Node.js to throw a Can't render headers after they are sent to the client. error.

                      Rule Details

                      This rule is aimed at ensuring that callbacks used outside of the main function block are always part-of or immediately preceding a return statement. This rule decides what is a callback based on the name of the function being called.

                      Options

                      The rule takes a single option - an array of possible callback names - which may include object methods. The default callback names are callback, cb, next.

                      Default callback names

                      Examples of incorrect code for this rule with the default ["callback", "cb", "next"] option:

                      /*eslint callback-return: "error"*/
                      
                      function foo(err, callback) {
                          if (err) {
                              callback(err);
                          }
                          callback();
                      }

                      Examples of correct code for this rule with the default ["callback", "cb", "next"] option:

                      /*eslint callback-return: "error"*/
                      
                      function foo(err, callback) {
                          if (err) {
                              return callback(err);
                          }
                          callback();
                      }

                      Supplied callback names

                      Examples of incorrect code for this rule with the option ["done", "send.error", "send.success"]:

                      /*eslint callback-return: ["error", ["done", "send.error", "send.success"]]*/
                      
                      function foo(err, done) {
                          if (err) {
                              done(err);
                          }
                          done();
                      }
                      
                      function bar(err, send) {
                          if (err) {
                              send.error(err);
                          }
                          send.success();
                      }

                      Examples of correct code for this rule with the option ["done", "send.error", "send.success"]:

                      /*eslint callback-return: ["error", ["done", "send.error", "send.success"]]*/
                      
                      function foo(err, done) {
                          if (err) {
                              return done(err);
                          }
                          done();
                      }
                      
                      function bar(err, send) {
                          if (err) {
                              return send.error(err);
                          }
                          send.success();
                      }

                      Known Limitations

                      Because it is difficult to understand the meaning of a program through static analysis, this rule has limitations:

                      • false negatives when this rule reports correct code, but the program calls the callback more than one time (which is incorrect behavior)
                      • false positives when this rule reports incorrect code, but the program calls the callback only one time (which is correct behavior)

                      Passing the callback by reference

                      The static analysis of this rule does not detect that the program calls the callback if it is an argument of a function (for example, setTimeout).

                      Example of a false negative when this rule reports correct code:

                      /*eslint callback-return: "error"*/
                      
                      function foo(err, callback) {
                          if (err) {
                              setTimeout(callback, 0); // this is bad, but WILL NOT warn
                          }
                          callback();
                      }

                      Triggering the callback within a nested function

                      The static analysis of this rule does not detect that the program calls the callback from within a nested function or an immediately-invoked function expression (IIFE).

                      Example of a false negative when this rule reports correct code:

                      /*eslint callback-return: "error"*/
                      
                      function foo(err, callback) {
                          if (err) {
                              process.nextTick(function() {
                                  return callback(); // this is bad, but WILL NOT warn
                              });
                          }
                          callback();
                      }

                      If/else statements

                      The static analysis of this rule does not detect that the program calls the callback only one time in each branch of an if statement.

                      Example of a false positive when this rule reports incorrect code:

                      /*eslint callback-return: "error"*/
                      
                      function foo(err, callback) {
                          if (err) {
                              callback(err); // this is fine, but WILL warn
                          } else {
                              callback();    // this is fine, but WILL warn
                          }
                      }

                      When Not To Use It

                      There are some cases where you might want to call a callback function more than once. In those cases this rule may lead to incorrect behavior. In those cases you may want to reserve a special name for those callbacks and not include that in the list of callbacks that trigger warnings.

                      Further Reading

                      Related Rules

                      Expected an assignment or function call and instead saw an expression.
                      Open

                                          this.devices[devId] && this.devices[devId].emit('error', error ? error.toString() : null);
                      Severity: Minor
                      Found in index.js by eslint

                      Disallow Unused Expressions (no-unused-expressions)

                      An unused expression which has no effect on the state of the program indicates a logic error.

                      For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                      Rule Details

                      This rule aims to eliminate unused expressions which have no effect on the state of the program.

                      This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                      var i = 0;
                      function increment() { i += 1; }
                      increment(); // return value is unused, but i changed as a side effect
                      
                      var nThings = 0;
                      function Thing() { nThings += 1; }
                      new Thing(); // constructed object is unused, but nThings changed as a side effect

                      This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                      Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                      Options

                      This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                      • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                      • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                      • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                      These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                      Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      0
                      
                      if(0) 0
                      
                      {0}
                      
                      f(0), {}
                      
                      a && b()
                      
                      a, b()
                      
                      c = a, b;
                      
                      a() && function namedFunctionInExpressionContext () {f();}
                      
                      (function anIncompleteIIFE () {});
                      
                      injectGlobal`body{ color: red; }`

                      Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                      "use strict";
                      "use asm"
                      "use stricter";
                      "use babel"
                      "any other strings like this in the prologue";

                      Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      {} // In this context, this is a block statement, not an object literal
                      
                      {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                      
                      function namedFunctionDeclaration () {}
                      
                      (function aGenuineIIFE () {}());
                      
                      f()
                      
                      a = 0
                      
                      new C
                      
                      delete a.b
                      
                      void a

                      allowShortCircuit

                      Examples of incorrect code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a || b

                      Examples of correct code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a && b()
                      a() || (b = c)

                      allowTernary

                      Examples of incorrect code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b : 0
                      a ? b : c()

                      Examples of correct code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b() : c()
                      a ? (b = c) : d()

                      allowShortCircuit and allowTernary

                      Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                      
                      a ? b() || (c = d) : e()

                      allowTaggedTemplates

                      Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      `some untagged template string`;

                      Examples of correct code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      tag`some tagged template string`;

                      Source: http://eslint.org/docs/rules/

                      Expected an assignment or function call and instead saw an expression.
                      Open

                                          this.devices[devId] && this.devices[devId].emit('close', error ? error.toString() : null);
                      Severity: Minor
                      Found in index.js by eslint

                      Disallow Unused Expressions (no-unused-expressions)

                      An unused expression which has no effect on the state of the program indicates a logic error.

                      For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                      Rule Details

                      This rule aims to eliminate unused expressions which have no effect on the state of the program.

                      This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                      var i = 0;
                      function increment() { i += 1; }
                      increment(); // return value is unused, but i changed as a side effect
                      
                      var nThings = 0;
                      function Thing() { nThings += 1; }
                      new Thing(); // constructed object is unused, but nThings changed as a side effect

                      This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                      Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                      Options

                      This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                      • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                      • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                      • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                      These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                      Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      0
                      
                      if(0) 0
                      
                      {0}
                      
                      f(0), {}
                      
                      a && b()
                      
                      a, b()
                      
                      c = a, b;
                      
                      a() && function namedFunctionInExpressionContext () {f();}
                      
                      (function anIncompleteIIFE () {});
                      
                      injectGlobal`body{ color: red; }`

                      Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                      "use strict";
                      "use asm"
                      "use stricter";
                      "use babel"
                      "any other strings like this in the prologue";

                      Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      {} // In this context, this is a block statement, not an object literal
                      
                      {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                      
                      function namedFunctionDeclaration () {}
                      
                      (function aGenuineIIFE () {}());
                      
                      f()
                      
                      a = 0
                      
                      new C
                      
                      delete a.b
                      
                      void a

                      allowShortCircuit

                      Examples of incorrect code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a || b

                      Examples of correct code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a && b()
                      a() || (b = c)

                      allowTernary

                      Examples of incorrect code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b : 0
                      a ? b : c()

                      Examples of correct code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b() : c()
                      a ? (b = c) : d()

                      allowShortCircuit and allowTernary

                      Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                      
                      a ? b() || (c = d) : e()

                      allowTaggedTemplates

                      Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      `some untagged template string`;

                      Examples of correct code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      tag`some tagged template string`;

                      Source: http://eslint.org/docs/rules/

                      Expected an assignment or function call and instead saw an expression.
                      Open

                                  this.options.logger && this.options.logger(`HTTP-Local-Response Error ${dev.uuid}: ${error} / Status=${response ? response.statusCode : '--'}`);
                      Severity: Minor
                      Found in index.js by eslint

                      Disallow Unused Expressions (no-unused-expressions)

                      An unused expression which has no effect on the state of the program indicates a logic error.

                      For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                      Rule Details

                      This rule aims to eliminate unused expressions which have no effect on the state of the program.

                      This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                      var i = 0;
                      function increment() { i += 1; }
                      increment(); // return value is unused, but i changed as a side effect
                      
                      var nThings = 0;
                      function Thing() { nThings += 1; }
                      new Thing(); // constructed object is unused, but nThings changed as a side effect

                      This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                      Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                      Options

                      This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                      • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                      • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                      • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                      These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                      Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      0
                      
                      if(0) 0
                      
                      {0}
                      
                      f(0), {}
                      
                      a && b()
                      
                      a, b()
                      
                      c = a, b;
                      
                      a() && function namedFunctionInExpressionContext () {f();}
                      
                      (function anIncompleteIIFE () {});
                      
                      injectGlobal`body{ color: red; }`

                      Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                      "use strict";
                      "use asm"
                      "use stricter";
                      "use babel"
                      "any other strings like this in the prologue";

                      Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                      /*eslint no-unused-expressions: "error"*/
                      
                      {} // In this context, this is a block statement, not an object literal
                      
                      {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                      
                      function namedFunctionDeclaration () {}
                      
                      (function aGenuineIIFE () {}());
                      
                      f()
                      
                      a = 0
                      
                      new C
                      
                      delete a.b
                      
                      void a

                      allowShortCircuit

                      Examples of incorrect code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a || b

                      Examples of correct code for the { "allowShortCircuit": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                      
                      a && b()
                      a() || (b = c)

                      allowTernary

                      Examples of incorrect code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b : 0
                      a ? b : c()

                      Examples of correct code for the { "allowTernary": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                      
                      a ? b() : c()
                      a ? (b = c) : d()

                      allowShortCircuit and allowTernary

                      Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                      /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                      
                      a ? b() || (c = d) : e()

                      allowTaggedTemplates

                      Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      `some untagged template string`;

                      Examples of correct code for the { "allowTaggedTemplates": true } option:

                      /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                      
                      tag`some tagged template string`;

                      Source: http://eslint.org/docs/rules/

                      Unexpected trailing comma.
                      Open

                                  mfaCode: this.options.mfaCode || undefined,
                      Severity: Minor
                      Found in index.js by eslint

                      require or disallow trailing commas (comma-dangle)

                      Trailing commas in object literals are valid according to the ECMAScript 5 (and ECMAScript 3!) spec. However, IE8 (when not in IE8 document mode) and below will throw an error when it encounters trailing commas in JavaScript.

                      var foo = {
                          bar: "baz",
                          qux: "quux",
                      };

                      Trailing commas simplify adding and removing items to objects and arrays, since only the lines you are modifying must be touched. Another argument in favor of trailing commas is that it improves the clarity of diffs when an item is added or removed from an object or array:

                      Less clear:

                      var foo = {
                      -    bar: "baz",
                      -    qux: "quux"
                      +    bar: "baz"
                       };

                      More clear:

                      var foo = {
                           bar: "baz",
                      -    qux: "quux",
                       };

                      Rule Details

                      This rule enforces consistent use of trailing commas in object and array literals.

                      Options

                      This rule has a string option or an object option:

                      {
                          "comma-dangle": ["error", "never"],
                          // or
                          "comma-dangle": ["error", {
                              "arrays": "never",
                              "objects": "never",
                              "imports": "never",
                              "exports": "never",
                              "functions": "ignore",
                          }]
                      }
                      • "never" (default) disallows trailing commas
                      • "always" requires trailing commas
                      • "always-multiline" requires trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }
                      • "only-multiline" allows (but does not require) trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }

                      Trailing commas in function declarations and function calls are valid syntax since ECMAScript 2017; however, the string option does not check these situations for backwards compatibility.

                      You can also use an object option to configure this rule for each type of syntax. Each of the following options can be set to "never", "always", "always-multiline", "only-multiline", or "ignore". The default for each option is "never" unless otherwise specified.

                      • arrays is for array literals and array patterns of destructuring. (e.g. let [a,] = [1,];)
                      • objects is for object literals and object patterns of destructuring. (e.g. let {a,} = {a: 1};)
                      • imports is for import declarations of ES Modules. (e.g. import {a,} from "foo";)
                      • exports is for export declarations of ES Modules. (e.g. export {a,};)
                      • functions is for function declarations and function calls. (e.g. (function(a,){ })(b,);)
                        functions is set to "ignore" by default for consistency with the string option.

                      never

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

                      /*eslint comma-dangle: ["error", "never"]*/
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux",
                      };
                      
                      var arr = [1,2,];
                      
                      foo({
                        bar: "baz",
                        qux: "quux",
                      });

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

                      /*eslint comma-dangle: ["error", "never"]*/
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux"
                      };
                      
                      var arr = [1,2];
                      
                      foo({
                        bar: "baz",
                        qux: "quux"
                      });

                      always

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

                      /*eslint comma-dangle: ["error", "always"]*/
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux"
                      };
                      
                      var arr = [1,2];
                      
                      foo({
                        bar: "baz",
                        qux: "quux"
                      });

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

                      /*eslint comma-dangle: ["error", "always"]*/
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux",
                      };
                      
                      var arr = [1,2,];
                      
                      foo({
                        bar: "baz",
                        qux: "quux",
                      });

                      always-multiline

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

                      /*eslint comma-dangle: ["error", "always-multiline"]*/
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux"
                      };
                      
                      var foo = { bar: "baz", qux: "quux", };
                      
                      var arr = [1,2,];
                      
                      var arr = [1,
                          2,];
                      
                      var arr = [
                          1,
                          2
                      ];
                      
                      foo({
                        bar: "baz",
                        qux: "quux"
                      });

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

                      /*eslint comma-dangle: ["error", "always-multiline"]*/
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux",
                      };
                      
                      var foo = {bar: "baz", qux: "quux"};
                      var arr = [1,2];
                      
                      var arr = [1,
                          2];
                      
                      var arr = [
                          1,
                          2,
                      ];
                      
                      foo({
                        bar: "baz",
                        qux: "quux",
                      });

                      only-multiline

                      Examples of incorrect code for this rule with the "only-multiline" option:

                      /*eslint comma-dangle: ["error", "only-multiline"]*/
                      
                      var foo = { bar: "baz", qux: "quux", };
                      
                      var arr = [1,2,];
                      
                      var arr = [1,
                          2,];

                      Examples of correct code for this rule with the "only-multiline" option:

                      /*eslint comma-dangle: ["error", "only-multiline"]*/
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux",
                      };
                      
                      var foo = {
                          bar: "baz",
                          qux: "quux"
                      };
                      
                      var foo = {bar: "baz", qux: "quux"};
                      var arr = [1,2];
                      
                      var arr = [1,
                          2];
                      
                      var arr = [
                          1,
                          2,
                      ];
                      
                      var arr = [
                          1,
                          2
                      ];
                      
                      foo({
                        bar: "baz",
                        qux: "quux",
                      });
                      
                      foo({
                        bar: "baz",
                        qux: "quux"
                      });

                      functions

                      Examples of incorrect code for this rule with the {"functions": "never"} option:

                      /*eslint comma-dangle: ["error", {"functions": "never"}]*/
                      
                      function foo(a, b,) {
                      }
                      
                      foo(a, b,);
                      new foo(a, b,);

                      Examples of correct code for this rule with the {"functions": "never"} option:

                      /*eslint comma-dangle: ["error", {"functions": "never"}]*/
                      
                      function foo(a, b) {
                      }
                      
                      foo(a, b);
                      new foo(a, b);

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

                      /*eslint comma-dangle: ["error", {"functions": "always"}]*/
                      
                      function foo(a, b) {
                      }
                      
                      foo(a, b);
                      new foo(a, b);

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

                      /*eslint comma-dangle: ["error", {"functions": "always"}]*/
                      
                      function foo(a, b,) {
                      }
                      
                      foo(a, b,);
                      new foo(a, b,);

                      When Not To Use It

                      You can turn this rule off if you are not concerned with dangling commas. Source: http://eslint.org/docs/rules/

                      Severity
                      Category
                      Status
                      Source
                      Language