nponiros/sync_server

View on GitHub

Showing 43 of 43 total issues

Function applyClientChanges has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function applyClientChanges(db, baseRevision, currentRevision, clientChanges, clientIdentity) {
Severity: Minor
Found in lib/sync/apply_client_changes.js - About 35 mins to fix

    Function getServerChanges has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function getServerChanges(db, syncedRevision, clientIdentity, partialsThreshold, currentDBRevision) {
    Severity: Minor
    Found in lib/sync/get_server_changes.js - About 35 mins to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            if (ifaceEntry.family === 'IPv4') {
              logger.console.info(`${ifaceEntry.family}: ${protocol}://${ifaceEntry.address}:${port}`);
            } else {
      Severity: Minor
      Found in lib/server/print_interfaces.js and 1 other location - About 35 mins to fix
      lib/server/print_interfaces.js on lines 14..16

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            } else {
              logger.console.info(`${ifaceEntry.family}: ${protocol}://[${ifaceEntry.address}]:${port}`);
            }
      Severity: Minor
      Found in lib/server/print_interfaces.js and 1 other location - About 35 mins to fix
      lib/server/print_interfaces.js on lines 12..14

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            Object
              .keys(prevChange.mods)
              .filter((subPath) => subPath.indexOf(keyPath + '.') === 0)
              .forEach((subPath) => {
                Reflect.deleteProperty(clonedChange.mods, subPath);
      Severity: Minor
      Found in lib/sync/combine_update_and_update.js and 1 other location - About 35 mins to fix
      lib/sync/combine_update_and_update.js on lines 24..34

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            Object
              .keys(prevChange.mods)
              .filter((parentPath) => keyPath.indexOf(parentPath + '.') === 0)
              .forEach((parentPath) => {
                setByKeyPath(
      Severity: Minor
      Found in lib/sync/combine_update_and_update.js and 1 other location - About 35 mins to fix
      lib/sync/combine_update_and_update.js on lines 42..47

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      growl Command Injection
      Open

          "growl": {
            "version": "1.9.2",
            "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz",
            "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
            "dev": true
      Severity: Minor
      Found in package-lock.json by nodesecurity

      Command Injection

      Overview:

      Growl adds growl notification support to nodejs.

      Growl does not properly sanitize input before passing it to exec, allowing for arbitrary command execution.

      Recommendation:

      Update to version 1.10.2 or greater

      debug Regular Expression Denial of Service
      Open

          "debug": {
            "version": "2.6.0",
            "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz",
            "integrity": "sha1-vFlryr52F/Edn6FTYe3tVgi4SZs=",
            "dev": true,
      Severity: Minor
      Found in package-lock.json by nodesecurity

      Regular Expression Denial of Service

      Overview:

      The debug module is vulnerable to regular expression denial of service when untrusted user input is passed into the o formatter. It takes around 50k characters to block for 2 seconds making this a low severity issue.

      Recommendation:

      Upgrade to version 2.6.9 or greater if you are on the 2.6.x series or 3.1.0 or greater.

      debug Regular Expression Denial of Service
      Open

              "debug": {
                "version": "2.2.0",
                "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
                "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
                "dev": true,
      Severity: Minor
      Found in package-lock.json by nodesecurity

      Regular Expression Denial of Service

      Overview:

      The debug module is vulnerable to regular expression denial of service when untrusted user input is passed into the o formatter. It takes around 50k characters to block for 2 seconds making this a low severity issue.

      Recommendation:

      Upgrade to version 2.6.9 or greater if you are on the 2.6.x series or 3.1.0 or greater.

      'clientIdentity' is defined but never used.
      Open

        let clientIdentity;
      Severity: Minor
      Found in samples/socket/index.js by eslint

      Disallow Unused Variables (no-unused-vars)

      Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers.

      Rule Details

      This rule is aimed at eliminating unused variables, functions, and parameters of functions.

      A variable is considered to be used if any of the following are true:

      • It represents a function that is called (doSomething())
      • It is read (var y = x)
      • It is passed into a function as an argument (doSomething(x))
      • It is read inside of a function that is passed to another function (doSomething(function() { foo(); }))

      A variable is not considered to be used if it is only ever assigned to (var x = 5) or declared.

      Examples of incorrect code for this rule:

      /*eslint no-unused-vars: "error"*/
      /*global some_unused_var*/
      
      // It checks variables you have defined as global
      some_unused_var = 42;
      
      var x;
      
      // Write-only variables are not considered as used.
      var y = 10;
      y = 5;
      
      // A read for a modification of itself is not considered as used.
      var z = 0;
      z = z + 1;
      
      // By default, unused arguments cause warnings.
      (function(foo) {
          return 5;
      })();
      
      // Unused recursive functions also cause warnings.
      function fact(n) {
          if (n < 2) return 1;
          return n * fact(n - 1);
      }
      
      // When a function definition destructures an array, unused entries from the array also cause warnings.
      function getY([x, y]) {
          return y;
      }

      Examples of correct code for this rule:

      /*eslint no-unused-vars: "error"*/
      
      var x = 10;
      alert(x);
      
      // foo is considered used here
      myFunc(function foo() {
          // ...
      }.bind(this));
      
      (function(foo) {
          return foo;
      })();
      
      var myFunc;
      myFunc = setTimeout(function() {
          // myFunc is considered used
          myFunc();
      }, 50);
      
      // Only the second argument from the descructured array is used.
      function getY([, y]) {
          return y;
      }

      exported

      In environments outside of CommonJS or ECMAScript modules, you may use var to create a global variable that may be used by other scripts. You can use the /* exported variableName */ comment block to indicate that this variable is being exported and therefore should not be considered unused.

      Note that /* exported */ has no effect for any of the following:

      • when the environment is node or commonjs
      • when parserOptions.sourceType is module
      • when ecmaFeatures.globalReturn is true

      The line comment // exported variableName will not work as exported is not line-specific.

      Examples of correct code for /* exported variableName */ operation:

      /* exported global_var */
      
      var global_var = 42;

      Options

      This rule takes one argument which can be a string or an object. The string settings are the same as those of the vars property (explained below).

      By default this rule is enabled with all option for variables and after-used for arguments.

      {
          "rules": {
              "no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
          }
      }

      vars

      The vars option has two settings:

      • all checks all variables for usage, including those in the global scope. This is the default setting.
      • local checks only that locally-declared variables are used but will allow global variables to be unused.

      vars: local

      Examples of correct code for the { "vars": "local" } option:

      /*eslint no-unused-vars: ["error", { "vars": "local" }]*/
      /*global some_unused_var */
      
      some_unused_var = 42;

      varsIgnorePattern

      The varsIgnorePattern option specifies exceptions not to check for usage: variables whose names match a regexp pattern. For example, variables whose names contain ignored or Ignored.

      Examples of correct code for the { "varsIgnorePattern": "[iI]gnored" } option:

      /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "[iI]gnored" }]*/
      
      var firstVarIgnored = 1;
      var secondVar = 2;
      console.log(secondVar);

      args

      The args option has three settings:

      • after-used - only the last argument must be used. This allows you, for instance, to have two named parameters to a function and as long as you use the second argument, ESLint will not warn you about the first. This is the default setting.
      • all - all named arguments must be used.
      • none - do not check arguments.

      args: after-used

      Examples of incorrect code for the default { "args": "after-used" } option:

      /*eslint no-unused-vars: ["error", { "args": "after-used" }]*/
      
      // 1 error
      // "baz" is defined but never used
      (function(foo, bar, baz) {
          return bar;
      })();

      Examples of correct code for the default { "args": "after-used" } option:

      /*eslint no-unused-vars: ["error", {"args": "after-used"}]*/
      
      (function(foo, bar, baz) {
          return baz;
      })();

      args: all

      Examples of incorrect code for the { "args": "all" } option:

      /*eslint no-unused-vars: ["error", { "args": "all" }]*/
      
      // 2 errors
      // "foo" is defined but never used
      // "baz" is defined but never used
      (function(foo, bar, baz) {
          return bar;
      })();

      args: none

      Examples of correct code for the { "args": "none" } option:

      /*eslint no-unused-vars: ["error", { "args": "none" }]*/
      
      (function(foo, bar, baz) {
          return bar;
      })();

      ignoreRestSiblings

      The ignoreRestSiblings option is a boolean (default: false). Using a Rest Property it is possible to "omit" properties from an object, but by default the sibling properties are marked as "unused". With this option enabled the rest property's siblings are ignored.

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

      /*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/
      // 'type' is ignored because it has a rest property sibling.
      var { type, ...coords } = data;

      argsIgnorePattern

      The argsIgnorePattern option specifies exceptions not to check for usage: arguments whose names match a regexp pattern. For example, variables whose names begin with an underscore.

      Examples of correct code for the { "argsIgnorePattern": "^_" } option:

      /*eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }]*/
      
      function foo(x, _y) {
          return x + 1;
      }
      foo();

      caughtErrors

      The caughtErrors option is used for catch block arguments validation.

      It has two settings:

      • none - do not check error objects. This is the default setting.
      • all - all named arguments must be used.

      caughtErrors: none

      Not specifying this rule is equivalent of assigning it to none.

      Examples of correct code for the { "caughtErrors": "none" } option:

      /*eslint no-unused-vars: ["error", { "caughtErrors": "none" }]*/
      
      try {
          //...
      } catch (err) {
          console.error("errors");
      }

      caughtErrors: all

      Examples of incorrect code for the { "caughtErrors": "all" } option:

      /*eslint no-unused-vars: ["error", { "caughtErrors": "all" }]*/
      
      // 1 error
      // "err" is defined but never used
      try {
          //...
      } catch (err) {
          console.error("errors");
      }

      caughtErrorsIgnorePattern

      The caughtErrorsIgnorePattern option specifies exceptions not to check for usage: catch arguments whose names match a regexp pattern. For example, variables whose names begin with a string 'ignore'.

      Examples of correct code for the { "caughtErrorsIgnorePattern": "^ignore" } option:

      /*eslint no-unused-vars: ["error", { "caughtErrorsIgnorePattern": "^ignore" }]*/
      
      try {
          //...
      } catch (ignoreErr) {
          console.error("errors");
      }

      When Not To Use It

      If you don't want to be notified about unused variables or function arguments, you can safely turn this rule off. Source: http://eslint.org/docs/rules/

      A space is required after '{'.
      Open

                obj: {item: input.value},
      Severity: Minor
      Found in samples/socket/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

      Unexpected literal in error position of callback.
      Open

                  cb({
      Severity: Minor
      Found in lib/sync/socket_handler.js by eslint

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

      Unexpected literal in error position of callback.
      Open

                  cb({ succeeded: true, data });
      Severity: Minor
      Found in lib/sync/socket_handler.js by eslint

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

      A space is required before '}'.
      Open

                obj: {item: input.value},
      Severity: Minor
      Found in samples/socket/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

      Missing trailing comma.
      Open

              }]
      Severity: Minor
      Found in samples/socket/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/

      'Headers' is not defined.
      Open

          const headers = new Headers();
      Severity: Minor
      Found in samples/ajax/index.js by eslint

      Disallow Undeclared Variables (no-undef)

      This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

      Rule Details

      Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

      Examples of incorrect code for this rule:

      /*eslint no-undef: "error"*/
      
      var a = someFunction();
      b = 10;

      Examples of correct code for this rule with global declaration:

      /*global someFunction b:true*/
      /*eslint no-undef: "error"*/
      
      var a = someFunction();
      b = 10;

      The b:true syntax in /*global */ indicates that assignment to b is correct.

      Examples of incorrect code for this rule with global declaration:

      /*global b*/
      /*eslint no-undef: "error"*/
      
      b = 10;

      By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

      Options

      • typeof set to true will warn for variables used inside typeof check (Default false).

      typeof

      Examples of correct code for the default { "typeof": false } option:

      /*eslint no-undef: "error"*/
      
      if (typeof UndefinedIdentifier === "undefined") {
          // do something ...
      }

      You can use this option if you want to prevent typeof check on a variable which has not been declared.

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

      /*eslint no-undef: ["error", { "typeof": true }] */
      
      if(typeof a === "string"){}

      Examples of correct code for the { "typeof": true } option with global declaration:

      /*global a*/
      /*eslint no-undef: ["error", { "typeof": true }] */
      
      if(typeof a === "string"){}

      Environments

      For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

      browser

      Examples of correct code for this rule with browser environment:

      /*eslint no-undef: "error"*/
      /*eslint-env browser*/
      
      setTimeout(function() {
          alert("Hello");
      });

      node

      Examples of correct code for this rule with node environment:

      /*eslint no-undef: "error"*/
      /*eslint-env node*/
      
      var fs = require("fs");
      module.exports = function() {
          console.log(fs);
      };

      When Not To Use It

      If explicit declaration of global variables is not to your taste.

      Compatibility

      This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

      Too many blank lines at the end of file. Max of 0 allowed.
      Open

      Severity: Minor
      Found in lib/server/socket/server.js by eslint

      disallow multiple empty lines (no-multiple-empty-lines)

      Some developers prefer to have multiple blank lines removed, while others feel that it helps improve readability. Whitespace is useful for separating logical sections of code, but excess whitespace takes up more of the screen.

      Rule Details

      This rule aims to reduce the scrolling required when reading through your code. It will warn when the maximum amount of empty lines has been exceeded.

      Options

      This rule has an object option:

      • "max" (default: 2) enforces a maximum number of consecutive empty lines.
      • "maxEOF" enforces a maximum number of consecutive empty lines at the end of files.
      • "maxBOF" enforces a maximum number of consecutive empty lines at the beginning of files.

      max

      Examples of incorrect code for this rule with the default { "max": 2 } option:

      /*eslint no-multiple-empty-lines: "error"*/
      
      var foo = 5;
      
      
      
      var bar = 3;

      Examples of correct code for this rule with the default { "max": 2 } option:

      /*eslint no-multiple-empty-lines: "error"*/
      
      var foo = 5;
      
      
      var bar = 3;

      maxEOF

      Examples of incorrect code for this rule with the { max: 2, maxEOF: 1 } options:

      /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 1 }]*/
      
      var foo = 5;
      
      
      var bar = 3;

      Examples of correct code for this rule with the { max: 2, maxEOF: 1 } options:

      /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 1 }]*/
      
      var foo = 5;
      
      
      var bar = 3;

      maxBOF

      Examples of incorrect code for this rule with the { max: 2, maxBOF: 1 } options:

      /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxBOF": 1 }]*/
      
      
      var foo = 5;
      
      
      var bar = 3;

      Examples of correct code for this rule with the { max: 2, maxBOF: 1 } options:

      /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxBOF": 1}]*/
      
      var foo = 5;
      
      
      var bar = 3;

      When Not To Use It

      If you do not care about extra blank lines, turn this off. Source: http://eslint.org/docs/rules/

      A space is required after '{'.
      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

      'WebSocket' is not defined.
      Open

          ws = new WebSocket(URL);
      Severity: Minor
      Found in samples/socket/index.js by eslint

      Disallow Undeclared Variables (no-undef)

      This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

      Rule Details

      Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

      Examples of incorrect code for this rule:

      /*eslint no-undef: "error"*/
      
      var a = someFunction();
      b = 10;

      Examples of correct code for this rule with global declaration:

      /*global someFunction b:true*/
      /*eslint no-undef: "error"*/
      
      var a = someFunction();
      b = 10;

      The b:true syntax in /*global */ indicates that assignment to b is correct.

      Examples of incorrect code for this rule with global declaration:

      /*global b*/
      /*eslint no-undef: "error"*/
      
      b = 10;

      By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

      Options

      • typeof set to true will warn for variables used inside typeof check (Default false).

      typeof

      Examples of correct code for the default { "typeof": false } option:

      /*eslint no-undef: "error"*/
      
      if (typeof UndefinedIdentifier === "undefined") {
          // do something ...
      }

      You can use this option if you want to prevent typeof check on a variable which has not been declared.

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

      /*eslint no-undef: ["error", { "typeof": true }] */
      
      if(typeof a === "string"){}

      Examples of correct code for the { "typeof": true } option with global declaration:

      /*global a*/
      /*eslint no-undef: ["error", { "typeof": true }] */
      
      if(typeof a === "string"){}

      Environments

      For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

      browser

      Examples of correct code for this rule with browser environment:

      /*eslint no-undef: "error"*/
      /*eslint-env browser*/
      
      setTimeout(function() {
          alert("Hello");
      });

      node

      Examples of correct code for this rule with node environment:

      /*eslint no-undef: "error"*/
      /*eslint-env node*/
      
      var fs = require("fs");
      module.exports = function() {
          console.log(fs);
      };

      When Not To Use It

      If explicit declaration of global variables is not to your taste.

      Compatibility

      This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

      'fetch' is not defined.
      Open

          fetch(URL, {
      Severity: Minor
      Found in samples/ajax/index.js by eslint

      Disallow Undeclared Variables (no-undef)

      This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for example, from forgetting the var keyword in a for loop initializer).

      Rule Details

      Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment.

      Examples of incorrect code for this rule:

      /*eslint no-undef: "error"*/
      
      var a = someFunction();
      b = 10;

      Examples of correct code for this rule with global declaration:

      /*global someFunction b:true*/
      /*eslint no-undef: "error"*/
      
      var a = someFunction();
      b = 10;

      The b:true syntax in /*global */ indicates that assignment to b is correct.

      Examples of incorrect code for this rule with global declaration:

      /*global b*/
      /*eslint no-undef: "error"*/
      
      b = 10;

      By default, variables declared in /*global */ are read-only, therefore assignment is incorrect.

      Options

      • typeof set to true will warn for variables used inside typeof check (Default false).

      typeof

      Examples of correct code for the default { "typeof": false } option:

      /*eslint no-undef: "error"*/
      
      if (typeof UndefinedIdentifier === "undefined") {
          // do something ...
      }

      You can use this option if you want to prevent typeof check on a variable which has not been declared.

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

      /*eslint no-undef: ["error", { "typeof": true }] */
      
      if(typeof a === "string"){}

      Examples of correct code for the { "typeof": true } option with global declaration:

      /*global a*/
      /*eslint no-undef: ["error", { "typeof": true }] */
      
      if(typeof a === "string"){}

      Environments

      For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in Specifying Environments. A few examples are given below.

      browser

      Examples of correct code for this rule with browser environment:

      /*eslint no-undef: "error"*/
      /*eslint-env browser*/
      
      setTimeout(function() {
          alert("Hello");
      });

      node

      Examples of correct code for this rule with node environment:

      /*eslint no-undef: "error"*/
      /*eslint-env node*/
      
      var fs = require("fs");
      module.exports = function() {
          console.log(fs);
      };

      When Not To Use It

      If explicit declaration of global variables is not to your taste.

      Compatibility

      This rule provides compatibility with treatment of global variables in JSHint and JSLint. Source: http://eslint.org/docs/rules/

      Severity
      Category
      Status
      Source
      Language