cBioPortal/iViz

View on GitHub
app/scripts/views/components/scatterPlot/scatterPlot.js

Summary

Maintainability
D
3 days
Test Coverage

Function ScatterPlot has 199 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  iViz.view.component.ScatterPlot = function() {
    var content = this;
    var chartId_;
    var data_;
    var groups_ = [];
Severity: Major
Found in app/scripts/views/components/scatterPlot/scatterPlot.js - About 7 hrs to fix

    Function update has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        content.update = function(_sampleIds) {
          var _selectedData = [];
          var _unselectedData = [];
    
          var _tmpSelectedSampleIdMap = {};
    Severity: Major
    Found in app/scripts/views/components/scatterPlot/scatterPlot.js - About 2 hrs to fix

      Function init has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          content.init = function(_data, opts) {
            opts_ = $.extend(true, {}, opts);
            chartId_ = opts_.chartId;
            data_ = _.filter(_data, function(datum) {
              return !isNaN(datum.FRACTION_GENOME_ALTERED) && !isNaN(datum.MUTATION_COUNT);
      Severity: Major
      Found in app/scripts/views/components/scatterPlot/scatterPlot.js - About 2 hrs to fix

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

              data.push({
                x: _.pluck(_unselectedData, 'FRACTION_GENOME_ALTERED'),
                y: _.pluck(_unselectedData, 'MUTATION_COUNT'),
                text: _unselectedDataQtips,
                mode: 'markers',
        Severity: Major
        Found in app/scripts/views/components/scatterPlot/scatterPlot.js and 1 other location - About 4 hrs to fix
        app/scripts/views/components/scatterPlot/scatterPlot.js on lines 161..175

        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 115.

        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

              data.push({
                x: _.pluck(_selectedData, 'FRACTION_GENOME_ALTERED'),
                y: _.pluck(_selectedData, 'MUTATION_COUNT'),
                text: _selectedDataQtips,
                mode: 'markers',
        Severity: Major
        Found in app/scripts/views/components/scatterPlot/scatterPlot.js and 1 other location - About 4 hrs to fix
        app/scripts/views/components/scatterPlot/scatterPlot.js on lines 146..160

        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 115.

        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

            function initCanvasDownloadData() {
              content.setDownloadData('svg', {
                title: opts_.title,
                chartDivId: opts_.chartId,
                fileName: opts_.title
        Severity: Major
        Found in app/scripts/views/components/scatterPlot/scatterPlot.js and 1 other location - About 2 hrs to fix
        app/scripts/views/components/survivalChart/main.js on lines 78..89

        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 88.

        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

        Missing JSDoc comment.
        Open

            function initTsvDownloadData() {

        Require JSDoc comment (require-jsdoc)

        JSDoc is a JavaScript API documentation generator. It uses specially-formatted comments inside of code to generate API documentation automatically. For example, this is what a JSDoc comment looks like for a function:

        /**
         * Adds two numbers together.
         * @param {int} num1 The first number.
         * @param {int} num2 The second number.
         * @returns {int} The sum of the two numbers.
         */
        function sum(num1, num2) {
            return num1 + num2;
        }

        Some style guides require JSDoc comments for all functions as a way of explaining function behavior.

        Rule Details

        This rule generates warnings for nodes that do not have JSDoc comments when they should. Supported nodes:

        • FunctionDeclaration
        • ClassDeclaration
        • MethodDefinition

        Options

        This rule accepts a require object with its properties as

        • FunctionDeclaration (default: true)
        • ClassDeclaration (default: false)
        • MethodDefinition (default: false)

        Default option settings are

        {
            "require-jsdoc": ["error", {
                "require": {
                    "FunctionDeclaration": true,
                    "MethodDefinition": false,
                    "ClassDeclaration": false
                }
            }]
        }

        The following patterns are considered problems:

        /*eslint "require-jsdoc": ["error", {
            "require": {
                "FunctionDeclaration": true,
                "MethodDefinition": true,
                "ClassDeclaration": true
            }
        }]*/
        
        function foo() {
            return 10;
        }
        
        class Test{
            getDate(){}
        }

        The following patterns are not considered problems:

        /*eslint "require-jsdoc": ["error", {
            "require": {
                "FunctionDeclaration": true,
                "MethodDefinition": true,
                "ClassDeclaration": true
            }
        }]*/
        
        /**
        * It returns 10
        */
        function foo() {
            return 10;
        }
        
        /**
        * It returns 10
        */
        var foo = function() {
            return 10;
        }
        
        var array = [1,2,3];
        array.filter(function(item) {
            return item > 2;
        });
        
        /**
        * It returns 10
        */
        class Test{
            /**
            * returns the date
            */
            getDate(){}
        }

        When Not To Use It

        If you do not require JSDoc for your functions, then you can leave this rule off.

        Related Rules

        Line 20 exceeds the maximum line length of 80.
        Open

                toReturn.push(cbio.util.toPrecision(Number(_data.FRACTION_GENOME_ALTERED), 2, 0.001));

        enforce a maximum line length (max-len)

        Very long lines of code in any language can be difficult to read. In order to aid in readability and maintainability many coders have developed a convention to limit lines of code to X number of characters (traditionally 80 characters).

        var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; // very long

        Rule Details

        This rule enforces a maximum line length to increase code readability and maintainability.

        Note: This rule calculates the length of a line via code points, not characters. That means if you use a double-byte character in your code, it will count as 2 code points instead of 1, and 2 will be used to calculate line length. This is a technical limitation of JavaScript that is made easier with ES2015, and we will look to update this when ES2015 is available in Node.js.

        Options

        This rule has a number or object option:

        • "code" (default 80) enforces a maximum line length
        • "tabWidth" (default 4) specifies the character width for tab characters
        • "comments" enforces a maximum line length for comments; defaults to value of code
        • "ignorePattern" ignores lines matching a regular expression; can only match a single line and need to be double escaped when written in YAML or JSON
        • "ignoreComments": true ignores all trailing comments and comments on their own line
        • "ignoreTrailingComments": true ignores only trailing comments
        • "ignoreUrls": true ignores lines that contain a URL

        code

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

        /*eslint max-len: ["error", 80]*/
        
        var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" };

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

        /*eslint max-len: ["error", 80]*/
        
        var foo = {
          "bar": "This is a bar.",
          "baz": { "qux": "This is a qux" },
          "easier": "to read"
        };

        tabWidth

        Examples of incorrect code for this rule with the default { "tabWidth": 4 } option:

        /*eslint max-len: ["error", 80, 4]*/
        
        \t  \t  var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };

        Examples of correct code for this rule with the default { "tabWidth": 4 } option:

        /*eslint max-len: ["error", 80, 4]*/
        
        \t  \t  var foo = {
        \t  \t  \t  \t  "bar": "This is a bar.",
        \t  \t  \t  \t  "baz": { "qux": "This is a qux" }
        \t  \t  };

        comments

        Examples of incorrect code for this rule with the { "comments": 65 } option:

        /*eslint max-len: ["error", { "comments": 65 }]*/
        
        /**
         * This is a comment that violates the maximum line length we have specified
        **/

        ignoreComments

        Examples of correct code for this rule with the { "ignoreComments": true } option:

        /*eslint max-len: ["error", { "ignoreComments": true }]*/
        
        /**
         * This is a really really really really really really really really really long comment
        **/

        ignoreTrailingComments

        Examples of correct code for this rule with the { "ignoreTrailingComments": true } option:

        /*eslint max-len: ["error", { "ignoreTrailingComments": true }]*/
        
        var foo = 'bar'; // This is a really really really really really really really long comment

        ignoreUrls

        Examples of correct code for this rule with the { "ignoreUrls": true } option:

        /*eslint max-len: ["error", { "ignoreUrls": true }]*/
        
        var url = 'https://www.example.com/really/really/really/really/really/really/really/long';

        ignorePattern

        Examples of correct code for this rule with the { "ignorePattern": true } option:

        /*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(/" }]*/
        
        var dep = require('really/really/really/really/really/really/really/really/long/module');

        Related Rules

        • [complexity](complexity.md)
        • [max-depth](max-depth.md)
        • [max-nested-callbacks](max-nested-callbacks.md)
        • [max-params](max-params.md)
        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

        Missing semicolon.
        Open

                })

        Enforce or Disallow Semicolons (semi)

        (fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

        JavaScript is unique amongst the C-like languages in that it doesn't require semicolons at the end of each statement. In many cases, the JavaScript engine can determine that a semicolon should be in a certain spot and will automatically add it. This feature is known as automatic semicolon insertion (ASI) and is considered one of the more controversial features of JavaScript. For example, the following lines are both valid:

        var name = "ESLint"
        var website = "eslint.org";

        On the first line, the JavaScript engine will automatically insert a semicolon, so this is not considered a syntax error. The JavaScript engine still knows how to interpret the line and knows that the line end indicates the end of the statement.

        In the debate over ASI, there are generally two schools of thought. The first is that we should treat ASI as if it didn't exist and always include semicolons manually. The rationale is that it's easier to always include semicolons than to try to remember when they are or are not required, and thus decreases the possibility of introducing an error.

        However, the ASI mechanism can sometimes be tricky to people who are using semicolons. For example, consider this code:

        return
        {
            name: "ESLint"
        };

        This may look like a return statement that returns an object literal, however, the JavaScript engine will interpret this code as:

        return;
        {
            name: "ESLint";
        }

        Effectively, a semicolon is inserted after the return statement, causing the code below it (a labeled literal inside a block) to be unreachable. This rule and the [no-unreachable](no-unreachable.md) rule will protect your code from such cases.

        On the other side of the argument are those who says that since semicolons are inserted automatically, they are optional and do not need to be inserted manually. However, the ASI mechanism can also be tricky to people who don't use semicolons. For example, consider this code:

        var globalCounter = { }
        
        (function () {
            var n = 0
            globalCounter.increment = function () {
                return ++n
            }
        })()

        In this example, a semicolon will not be inserted after the first line, causing a run-time error (because an empty object is called as if it's a function). The [no-unexpected-multiline](no-unexpected-multiline.md) rule can protect your code from such cases.

        Although ASI allows for more freedom over your coding style, it can also make your code behave in an unexpected way, whether you use semicolons or not. Therefore, it is best to know when ASI takes place and when it does not, and have ESLint protect your code from these potentially unexpected cases. In short, as once described by Isaac Schlueter, a \n character always ends a statement (just like a semicolon) unless one of the following is true:

        1. The statement has an unclosed paren, array literal, or object literal or ends in some other way that is not a valid way to end a statement. (For instance, ending with . or ,.)
        2. The line is -- or ++ (in which case it will decrement/increment the next token.)
        3. It is a for(), while(), do, if(), or else, and there is no {
        4. The next line starts with [, (, +, *, /, -, ,, ., or some other binary operator that can only be found between two tokens in a single expression.

        Rule Details

        This rule is aimed at ensuring consistent use of semicolons. You can decide whether or not to require semicolons at the end of statements.

        Options

        The rule takes one or two options. The first one is a string, which could be "always" or "never". The default is "always". The second one is an object for more fine-grained configuration when the first option is "always".

        You can set the option in configuration like this:

        "always"

        By using the default option, semicolons must be used any place where they are valid.

        semi: ["error", "always"]

        The following patterns are considered problems:

        /*eslint semi: "error"*/
        
        var name = "ESLint"
        
        object.method = function() {
            // ...
        }

        The following patterns are not considered problems:

        /*eslint semi: "error"*/
        
        var name = "ESLint";
        
        object.method = function() {
            // ...
        };

        Fine-grained control

        When setting the first option as "always", an additional option can be added to omit the last semicolon in a one-line block, that is, a block in which its braces (and therefore the content of the block) are in the same line:

        semi: ["error", "always", { "omitLastInOneLineBlock": true}]

        The following patterns are considered problems:

        /*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */
        
        if (foo) {
            bar()
        }
        
        if (foo) { bar(); }

        The following patterns are not considered problems:

        /*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */
        
        if (foo) { bar() }
        
        if (foo) { bar(); baz() }

        "never"

        If you want to enforce that semicolons are never used, switch the configuration to:

        semi: [2, "never"]

        Then, the following patterns are considered problems:

        /*eslint semi: ["error", "never"]*/
        
        var name = "ESLint";
        
        object.method = function() {
            // ...
        };

        And the following patterns are not considered problems:

        /*eslint semi: ["error", "never"]*/
        
        var name = "ESLint"
        
        object.method = function() {
            // ...
        }

        Even in "never" mode, semicolons are still allowed to disambiguate statements beginning with [, (, /, +, or -:

        /*eslint semi: ["error", "never"]*/
        
        var name = "ESLint"
        
        ;(function() {
            // ...
        })()

        When Not To Use It

        If you do not want to enforce semicolon usage (or omission) in any particular way, then you can turn this rule off.

        Further Reading

        Related Rules

        • [no-extra-semi](no-extra-semi.md)
        • [no-unexpected-multiline](no-unexpected-multiline.md)
        • [semi-spacing](semi-spacing.md) Source: http://eslint.org/docs/rules/

        Missing JSDoc comment.
        Open

            function initCanvasDownloadData() {

        Require JSDoc comment (require-jsdoc)

        JSDoc is a JavaScript API documentation generator. It uses specially-formatted comments inside of code to generate API documentation automatically. For example, this is what a JSDoc comment looks like for a function:

        /**
         * Adds two numbers together.
         * @param {int} num1 The first number.
         * @param {int} num2 The second number.
         * @returns {int} The sum of the two numbers.
         */
        function sum(num1, num2) {
            return num1 + num2;
        }

        Some style guides require JSDoc comments for all functions as a way of explaining function behavior.

        Rule Details

        This rule generates warnings for nodes that do not have JSDoc comments when they should. Supported nodes:

        • FunctionDeclaration
        • ClassDeclaration
        • MethodDefinition

        Options

        This rule accepts a require object with its properties as

        • FunctionDeclaration (default: true)
        • ClassDeclaration (default: false)
        • MethodDefinition (default: false)

        Default option settings are

        {
            "require-jsdoc": ["error", {
                "require": {
                    "FunctionDeclaration": true,
                    "MethodDefinition": false,
                    "ClassDeclaration": false
                }
            }]
        }

        The following patterns are considered problems:

        /*eslint "require-jsdoc": ["error", {
            "require": {
                "FunctionDeclaration": true,
                "MethodDefinition": true,
                "ClassDeclaration": true
            }
        }]*/
        
        function foo() {
            return 10;
        }
        
        class Test{
            getDate(){}
        }

        The following patterns are not considered problems:

        /*eslint "require-jsdoc": ["error", {
            "require": {
                "FunctionDeclaration": true,
                "MethodDefinition": true,
                "ClassDeclaration": true
            }
        }]*/
        
        /**
        * It returns 10
        */
        function foo() {
            return 10;
        }
        
        /**
        * It returns 10
        */
        var foo = function() {
            return 10;
        }
        
        var array = [1,2,3];
        array.filter(function(item) {
            return item > 2;
        });
        
        /**
        * It returns 10
        */
        class Test{
            /**
            * returns the date
            */
            getDate(){}
        }

        When Not To Use It

        If you do not require JSDoc for your functions, then you can leave this rule off.

        Related Rules

        Line 30 exceeds the maximum line length of 80.
        Open

                return !isNaN(datum.FRACTION_GENOME_ALTERED) && !isNaN(datum.MUTATION_COUNT);

        enforce a maximum line length (max-len)

        Very long lines of code in any language can be difficult to read. In order to aid in readability and maintainability many coders have developed a convention to limit lines of code to X number of characters (traditionally 80 characters).

        var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; // very long

        Rule Details

        This rule enforces a maximum line length to increase code readability and maintainability.

        Note: This rule calculates the length of a line via code points, not characters. That means if you use a double-byte character in your code, it will count as 2 code points instead of 1, and 2 will be used to calculate line length. This is a technical limitation of JavaScript that is made easier with ES2015, and we will look to update this when ES2015 is available in Node.js.

        Options

        This rule has a number or object option:

        • "code" (default 80) enforces a maximum line length
        • "tabWidth" (default 4) specifies the character width for tab characters
        • "comments" enforces a maximum line length for comments; defaults to value of code
        • "ignorePattern" ignores lines matching a regular expression; can only match a single line and need to be double escaped when written in YAML or JSON
        • "ignoreComments": true ignores all trailing comments and comments on their own line
        • "ignoreTrailingComments": true ignores only trailing comments
        • "ignoreUrls": true ignores lines that contain a URL

        code

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

        /*eslint max-len: ["error", 80]*/
        
        var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" };

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

        /*eslint max-len: ["error", 80]*/
        
        var foo = {
          "bar": "This is a bar.",
          "baz": { "qux": "This is a qux" },
          "easier": "to read"
        };

        tabWidth

        Examples of incorrect code for this rule with the default { "tabWidth": 4 } option:

        /*eslint max-len: ["error", 80, 4]*/
        
        \t  \t  var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };

        Examples of correct code for this rule with the default { "tabWidth": 4 } option:

        /*eslint max-len: ["error", 80, 4]*/
        
        \t  \t  var foo = {
        \t  \t  \t  \t  "bar": "This is a bar.",
        \t  \t  \t  \t  "baz": { "qux": "This is a qux" }
        \t  \t  };

        comments

        Examples of incorrect code for this rule with the { "comments": 65 } option:

        /*eslint max-len: ["error", { "comments": 65 }]*/
        
        /**
         * This is a comment that violates the maximum line length we have specified
        **/

        ignoreComments

        Examples of correct code for this rule with the { "ignoreComments": true } option:

        /*eslint max-len: ["error", { "ignoreComments": true }]*/
        
        /**
         * This is a really really really really really really really really really long comment
        **/

        ignoreTrailingComments

        Examples of correct code for this rule with the { "ignoreTrailingComments": true } option:

        /*eslint max-len: ["error", { "ignoreTrailingComments": true }]*/
        
        var foo = 'bar'; // This is a really really really really really really really long comment

        ignoreUrls

        Examples of correct code for this rule with the { "ignoreUrls": true } option:

        /*eslint max-len: ["error", { "ignoreUrls": true }]*/
        
        var url = 'https://www.example.com/really/really/really/really/really/really/really/long';

        ignorePattern

        Examples of correct code for this rule with the { "ignorePattern": true } option:

        /*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(/" }]*/
        
        var dep = require('really/really/really/really/really/really/really/really/long/module');

        Related Rules

        • [complexity](complexity.md)
        • [max-depth](max-depth.md)
        • [max-nested-callbacks](max-nested-callbacks.md)
        • [max-params](max-params.md)
        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

        Line 16 exceeds the maximum line length of 80.
        Open

                iViz.getCaseIdUsingUID('sample', _data.sample_uid), '<br>CNA fraction: '];

        enforce a maximum line length (max-len)

        Very long lines of code in any language can be difficult to read. In order to aid in readability and maintainability many coders have developed a convention to limit lines of code to X number of characters (traditionally 80 characters).

        var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; // very long

        Rule Details

        This rule enforces a maximum line length to increase code readability and maintainability.

        Note: This rule calculates the length of a line via code points, not characters. That means if you use a double-byte character in your code, it will count as 2 code points instead of 1, and 2 will be used to calculate line length. This is a technical limitation of JavaScript that is made easier with ES2015, and we will look to update this when ES2015 is available in Node.js.

        Options

        This rule has a number or object option:

        • "code" (default 80) enforces a maximum line length
        • "tabWidth" (default 4) specifies the character width for tab characters
        • "comments" enforces a maximum line length for comments; defaults to value of code
        • "ignorePattern" ignores lines matching a regular expression; can only match a single line and need to be double escaped when written in YAML or JSON
        • "ignoreComments": true ignores all trailing comments and comments on their own line
        • "ignoreTrailingComments": true ignores only trailing comments
        • "ignoreUrls": true ignores lines that contain a URL

        code

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

        /*eslint max-len: ["error", 80]*/
        
        var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" };

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

        /*eslint max-len: ["error", 80]*/
        
        var foo = {
          "bar": "This is a bar.",
          "baz": { "qux": "This is a qux" },
          "easier": "to read"
        };

        tabWidth

        Examples of incorrect code for this rule with the default { "tabWidth": 4 } option:

        /*eslint max-len: ["error", 80, 4]*/
        
        \t  \t  var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };

        Examples of correct code for this rule with the default { "tabWidth": 4 } option:

        /*eslint max-len: ["error", 80, 4]*/
        
        \t  \t  var foo = {
        \t  \t  \t  \t  "bar": "This is a bar.",
        \t  \t  \t  \t  "baz": { "qux": "This is a qux" }
        \t  \t  };

        comments

        Examples of incorrect code for this rule with the { "comments": 65 } option:

        /*eslint max-len: ["error", { "comments": 65 }]*/
        
        /**
         * This is a comment that violates the maximum line length we have specified
        **/

        ignoreComments

        Examples of correct code for this rule with the { "ignoreComments": true } option:

        /*eslint max-len: ["error", { "ignoreComments": true }]*/
        
        /**
         * This is a really really really really really really really really really long comment
        **/

        ignoreTrailingComments

        Examples of correct code for this rule with the { "ignoreTrailingComments": true } option:

        /*eslint max-len: ["error", { "ignoreTrailingComments": true }]*/
        
        var foo = 'bar'; // This is a really really really really really really really long comment

        ignoreUrls

        Examples of correct code for this rule with the { "ignoreUrls": true } option:

        /*eslint max-len: ["error", { "ignoreUrls": true }]*/
        
        var url = 'https://www.example.com/really/really/really/really/really/really/really/long';

        ignorePattern

        Examples of correct code for this rule with the { "ignorePattern": true } option:

        /*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(/" }]*/
        
        var dep = require('really/really/really/really/really/really/really/really/long/module');

        Related Rules

        • [complexity](complexity.md)
        • [max-depth](max-depth.md)
        • [max-nested-callbacks](max-nested-callbacks.md)
        • [max-params](max-params.md)
        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

        Missing semicolon.
        Open

                })

        Enforce or Disallow Semicolons (semi)

        (fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

        JavaScript is unique amongst the C-like languages in that it doesn't require semicolons at the end of each statement. In many cases, the JavaScript engine can determine that a semicolon should be in a certain spot and will automatically add it. This feature is known as automatic semicolon insertion (ASI) and is considered one of the more controversial features of JavaScript. For example, the following lines are both valid:

        var name = "ESLint"
        var website = "eslint.org";

        On the first line, the JavaScript engine will automatically insert a semicolon, so this is not considered a syntax error. The JavaScript engine still knows how to interpret the line and knows that the line end indicates the end of the statement.

        In the debate over ASI, there are generally two schools of thought. The first is that we should treat ASI as if it didn't exist and always include semicolons manually. The rationale is that it's easier to always include semicolons than to try to remember when they are or are not required, and thus decreases the possibility of introducing an error.

        However, the ASI mechanism can sometimes be tricky to people who are using semicolons. For example, consider this code:

        return
        {
            name: "ESLint"
        };

        This may look like a return statement that returns an object literal, however, the JavaScript engine will interpret this code as:

        return;
        {
            name: "ESLint";
        }

        Effectively, a semicolon is inserted after the return statement, causing the code below it (a labeled literal inside a block) to be unreachable. This rule and the [no-unreachable](no-unreachable.md) rule will protect your code from such cases.

        On the other side of the argument are those who says that since semicolons are inserted automatically, they are optional and do not need to be inserted manually. However, the ASI mechanism can also be tricky to people who don't use semicolons. For example, consider this code:

        var globalCounter = { }
        
        (function () {
            var n = 0
            globalCounter.increment = function () {
                return ++n
            }
        })()

        In this example, a semicolon will not be inserted after the first line, causing a run-time error (because an empty object is called as if it's a function). The [no-unexpected-multiline](no-unexpected-multiline.md) rule can protect your code from such cases.

        Although ASI allows for more freedom over your coding style, it can also make your code behave in an unexpected way, whether you use semicolons or not. Therefore, it is best to know when ASI takes place and when it does not, and have ESLint protect your code from these potentially unexpected cases. In short, as once described by Isaac Schlueter, a \n character always ends a statement (just like a semicolon) unless one of the following is true:

        1. The statement has an unclosed paren, array literal, or object literal or ends in some other way that is not a valid way to end a statement. (For instance, ending with . or ,.)
        2. The line is -- or ++ (in which case it will decrement/increment the next token.)
        3. It is a for(), while(), do, if(), or else, and there is no {
        4. The next line starts with [, (, +, *, /, -, ,, ., or some other binary operator that can only be found between two tokens in a single expression.

        Rule Details

        This rule is aimed at ensuring consistent use of semicolons. You can decide whether or not to require semicolons at the end of statements.

        Options

        The rule takes one or two options. The first one is a string, which could be "always" or "never". The default is "always". The second one is an object for more fine-grained configuration when the first option is "always".

        You can set the option in configuration like this:

        "always"

        By using the default option, semicolons must be used any place where they are valid.

        semi: ["error", "always"]

        The following patterns are considered problems:

        /*eslint semi: "error"*/
        
        var name = "ESLint"
        
        object.method = function() {
            // ...
        }

        The following patterns are not considered problems:

        /*eslint semi: "error"*/
        
        var name = "ESLint";
        
        object.method = function() {
            // ...
        };

        Fine-grained control

        When setting the first option as "always", an additional option can be added to omit the last semicolon in a one-line block, that is, a block in which its braces (and therefore the content of the block) are in the same line:

        semi: ["error", "always", { "omitLastInOneLineBlock": true}]

        The following patterns are considered problems:

        /*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */
        
        if (foo) {
            bar()
        }
        
        if (foo) { bar(); }

        The following patterns are not considered problems:

        /*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */
        
        if (foo) { bar() }
        
        if (foo) { bar(); baz() }

        "never"

        If you want to enforce that semicolons are never used, switch the configuration to:

        semi: [2, "never"]

        Then, the following patterns are considered problems:

        /*eslint semi: ["error", "never"]*/
        
        var name = "ESLint";
        
        object.method = function() {
            // ...
        };

        And the following patterns are not considered problems:

        /*eslint semi: ["error", "never"]*/
        
        var name = "ESLint"
        
        object.method = function() {
            // ...
        }

        Even in "never" mode, semicolons are still allowed to disambiguate statements beginning with [, (, /, +, or -:

        /*eslint semi: ["error", "never"]*/
        
        var name = "ESLint"
        
        ;(function() {
            // ...
        })()

        When Not To Use It

        If you do not want to enforce semicolon usage (or omission) in any particular way, then you can turn this rule off.

        Further Reading

        Related Rules

        • [no-extra-semi](no-extra-semi.md)
        • [no-unexpected-multiline](no-unexpected-multiline.md)
        • [semi-spacing](semi-spacing.md) Source: http://eslint.org/docs/rules/

        There are no issues that match your filters.

        Category
        Status