hrzlvn/coursequestionbank

View on GitHub
app/assets/javascripts/charts.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function firstGraph has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var firstGraph = function (divId, success_rate) {
    var gaugeOptions = {
        chart: {
            type: 'solidgauge'
        },
Severity: Major
Found in app/assets/javascripts/charts.js - About 2 hrs to fix

    Function entrysGraph has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var entrysGraph = function(divId, entryChoice) {
        yData = [];
        for (i = 0; i < entryChoice.length; ++i) {
            yData.push({name: "Entry " + (i + 1), data: [parseInt(entryChoice[i].trim())]});
        }
    Severity: Minor
    Found in app/assets/javascripts/charts.js - About 1 hr to fix

      Function totalGraph has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var totalGraph = function(divId, overallAttempts, wrong_cnt) {
          Highcharts.chart(divId, {
              chart: {
                  type: 'bar'
              },
      Severity: Minor
      Found in app/assets/javascripts/charts.js - About 1 hr to fix

        Function totalGraph has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var totalGraph = function(divId, overallAttempts, wrong_cnt) {
            Highcharts.chart(divId, {
                chart: {
                    type: 'bar'
                },
        Severity: Minor
        Found in app/assets/javascripts/charts.js - About 1 hr to fix

          Unexpected trailing comma.
          Open

                      max: 100,
          Severity: Minor
          Found in app/assets/javascripts/charts.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/

          Missing radix parameter.
          Open

                 wrong_cnt = parseInt($(this).find(".allAttemptsWrongAmount").text().trim());
          Severity: Minor
          Found in app/assets/javascripts/charts.js by eslint

          Require Radix Parameter (radix)

          When using the parseInt() function it is common to omit the second argument, the radix, and let the function try to determine from the first argument what type of number it is. By default, parseInt() will autodetect decimal and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also autodetected octal literals, which caused problems because many developers assumed a leading 0 would be ignored.

          This confusion led to the suggestion that you always use the radix parameter to parseInt() to eliminate unintended consequences. So instead of doing this:

          var num = parseInt("071");      // 57

          Do this:

          var num = parseInt("071", 10);  // 71

          ECMAScript 5 changed the behavior of parseInt() so that it no longer autodetects octal literals and instead treats them as decimal literals. However, the differences between hexadecimal and decimal interpretation of the first parameter causes many developers to continue using the radix parameter to ensure the string is interpreted in the intended way.

          On the other hand, if the code is targeting only ES5-compliant environments passing the radix 10 may be redundant. In such a case you might want to disallow using such a radix.

          Rule Details

          This rule is aimed at preventing the unintended conversion of a string to a number of a different base than intended or at preventing the redundant 10 radix if targeting modern environments only.

          Options

          There are two options for this rule:

          • "always" enforces providing a radix (default)
          • "as-needed" disallows providing the 10 radix

          always

          Examples of incorrect code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071");
          
          var num = parseInt(someValue);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          as-needed

          Examples of incorrect code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071");
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          When Not To Use It

          If you don't want to enforce either presence or omission of the 10 radix value you can turn this rule off.

          Further Reading

          'totalGraph' is already defined.
          Open

          var totalGraph = function(divId, overallAttempts, wrong_cnt) {
          Severity: Minor
          Found in app/assets/javascripts/charts.js by eslint

          disallow variable redeclaration (no-redeclare)

          In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

          Rule Details

          This rule is aimed at eliminating variables that have multiple declarations in the same scope.

          Examples of incorrect code for this rule:

          /*eslint no-redeclare: "error"*/
          
          var a = 3;
          var a = 10;

          Examples of correct code for this rule:

          /*eslint no-redeclare: "error"*/
          
          var a = 3;
          // ...
          a = 10;

          Options

          This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

          builtinGlobals

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

          /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
          
          var Object = 0;

          Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

          /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
          /*eslint-env browser*/
          
          var top = 0;

          The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

          Missing radix parameter.
          Open

                  yData.push({name: "Entry " + (i + 1), data: [parseInt(entryChoice[i].trim())]});
          Severity: Minor
          Found in app/assets/javascripts/charts.js by eslint

          Require Radix Parameter (radix)

          When using the parseInt() function it is common to omit the second argument, the radix, and let the function try to determine from the first argument what type of number it is. By default, parseInt() will autodetect decimal and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also autodetected octal literals, which caused problems because many developers assumed a leading 0 would be ignored.

          This confusion led to the suggestion that you always use the radix parameter to parseInt() to eliminate unintended consequences. So instead of doing this:

          var num = parseInt("071");      // 57

          Do this:

          var num = parseInt("071", 10);  // 71

          ECMAScript 5 changed the behavior of parseInt() so that it no longer autodetects octal literals and instead treats them as decimal literals. However, the differences between hexadecimal and decimal interpretation of the first parameter causes many developers to continue using the radix parameter to ensure the string is interpreted in the intended way.

          On the other hand, if the code is targeting only ES5-compliant environments passing the radix 10 may be redundant. In such a case you might want to disallow using such a radix.

          Rule Details

          This rule is aimed at preventing the unintended conversion of a string to a number of a different base than intended or at preventing the redundant 10 radix if targeting modern environments only.

          Options

          There are two options for this rule:

          • "always" enforces providing a radix (default)
          • "as-needed" disallows providing the 10 radix

          always

          Examples of incorrect code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071");
          
          var num = parseInt(someValue);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          as-needed

          Examples of incorrect code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071");
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          When Not To Use It

          If you don't want to enforce either presence or omission of the 10 radix value you can turn this rule off.

          Further Reading

          Missing radix parameter.
          Open

                 overallAttempts = parseInt($(this).find(".overallAttempts").text().trim());
          Severity: Minor
          Found in app/assets/javascripts/charts.js by eslint

          Require Radix Parameter (radix)

          When using the parseInt() function it is common to omit the second argument, the radix, and let the function try to determine from the first argument what type of number it is. By default, parseInt() will autodetect decimal and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also autodetected octal literals, which caused problems because many developers assumed a leading 0 would be ignored.

          This confusion led to the suggestion that you always use the radix parameter to parseInt() to eliminate unintended consequences. So instead of doing this:

          var num = parseInt("071");      // 57

          Do this:

          var num = parseInt("071", 10);  // 71

          ECMAScript 5 changed the behavior of parseInt() so that it no longer autodetects octal literals and instead treats them as decimal literals. However, the differences between hexadecimal and decimal interpretation of the first parameter causes many developers to continue using the radix parameter to ensure the string is interpreted in the intended way.

          On the other hand, if the code is targeting only ES5-compliant environments passing the radix 10 may be redundant. In such a case you might want to disallow using such a radix.

          Rule Details

          This rule is aimed at preventing the unintended conversion of a string to a number of a different base than intended or at preventing the redundant 10 radix if targeting modern environments only.

          Options

          There are two options for this rule:

          • "always" enforces providing a radix (default)
          • "as-needed" disallows providing the 10 radix

          always

          Examples of incorrect code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071");
          
          var num = parseInt(someValue);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          as-needed

          Examples of incorrect code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071");
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          When Not To Use It

          If you don't want to enforce either presence or omission of the 10 radix value you can turn this rule off.

          Further Reading

          Unexpected 'debugger' statement.
          Open

                 debugger
          Severity: Minor
          Found in app/assets/javascripts/charts.js by eslint

          disallow the use of debugger (no-debugger)

          The debugger statement is used to tell the executing JavaScript environment to stop execution and start up a debugger at the current point in the code. This has fallen out of favor as a good practice with the advent of modern debugging and development tools. Production code should definitely not contain debugger, as it will cause the browser to stop executing code and open an appropriate debugger.

          Rule Details

          This rule disallows debugger statements.

          Example of incorrect code for this rule:

          /*eslint no-debugger: "error"*/
          
          function isTruthy(x) {
              debugger;
              return Boolean(x);
          }

          Example of correct code for this rule:

          /*eslint no-debugger: "error"*/
          
          function isTruthy(x) {
              return Boolean(x); // set a breakpoint at this line
          }

          When Not To Use It

          If your code is still very much in development and don't want to worry about stripping debugger statements, then turn this rule off. You'll generally want to turn it back on when testing code prior to deployment.

          Further Reading

          Related Rules

          Unexpected trailing comma.
          Open

                      },
          Severity: Minor
          Found in app/assets/javascripts/charts.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/

          Missing radix parameter.
          Open

                 first_success = parseInt($(this).find(".first_success_rate").text().trim());
          Severity: Minor
          Found in app/assets/javascripts/charts.js by eslint

          Require Radix Parameter (radix)

          When using the parseInt() function it is common to omit the second argument, the radix, and let the function try to determine from the first argument what type of number it is. By default, parseInt() will autodetect decimal and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also autodetected octal literals, which caused problems because many developers assumed a leading 0 would be ignored.

          This confusion led to the suggestion that you always use the radix parameter to parseInt() to eliminate unintended consequences. So instead of doing this:

          var num = parseInt("071");      // 57

          Do this:

          var num = parseInt("071", 10);  // 71

          ECMAScript 5 changed the behavior of parseInt() so that it no longer autodetects octal literals and instead treats them as decimal literals. However, the differences between hexadecimal and decimal interpretation of the first parameter causes many developers to continue using the radix parameter to ensure the string is interpreted in the intended way.

          On the other hand, if the code is targeting only ES5-compliant environments passing the radix 10 may be redundant. In such a case you might want to disallow using such a radix.

          Rule Details

          This rule is aimed at preventing the unintended conversion of a string to a number of a different base than intended or at preventing the redundant 10 radix if targeting modern environments only.

          Options

          There are two options for this rule:

          • "always" enforces providing a radix (default)
          • "as-needed" disallows providing the 10 radix

          always

          Examples of incorrect code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071");
          
          var num = parseInt(someValue);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the default "always" option:

          /*eslint radix: "error"*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          as-needed

          Examples of incorrect code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071", 10);
          
          var num = parseInt("071", "abc");
          
          var num = parseInt();

          Examples of correct code for the "as-needed" option:

          /*eslint radix: ["error", "as-needed"]*/
          
          var num = parseInt("071");
          
          var num = parseInt("071", 8);
          
          var num = parseFloat(someValue);

          When Not To Use It

          If you don't want to enforce either presence or omission of the 10 radix value you can turn this rule off.

          Further Reading

          Unexpected trailing comma.
          Open

                      },
          Severity: Minor
          Found in app/assets/javascripts/charts.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/

          There are no issues that match your filters.

          Category
          Status