pat310/quick-pivot

View on GitHub

Showing 119 of 119 total issues

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

const data = [
  {name: 'patrick', borough: 'brooklyn', age: '28', gender: 'm'},
  {name: 'greg', borough: 'brooklyn', age: '29', gender: 'm'},
  {name: 'niles', borough: 'manhattan', age: '30', gender: 'm'},
  {name: 'jared', borough: 'manhattan', age: '29', gender: 'm'},
Severity: Major
Found in test/logic/groupByCategory.js and 7 other locations - About 7 hrs to fix
test/logic/accumulator.js on lines 4..13
test/logic/createColumnHeaders.js on lines 4..13
test/logic/fixDataFormat.js on lines 4..13
test/logic/fixDataFormat.js on lines 65..74
test/logic/fixDataFormat.js on lines 81..90
test/logic/groupByCategories.js on lines 4..13
test/logic/tableCreator.js on lines 4..13

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

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

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

    const expectedResults = [
      { name: 'Arya', gender: 'f', house: 'Stark', age: 10 },
      { name: 'Cersei', gender: 'f', house: 'Baratheon', age: 38 },
      { name: 'Tywin', gender: 'm', house: 'Lannister', age: 67 },
      { name: 'Tyrion', gender: 'm', house: 'Lannister', age: 34 },
Severity: Major
Found in test/filtering/filter.js and 1 other location - About 7 hrs to fix
test/filtering/filter.js on lines 19..28

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

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 8 locations. Consider refactoring.
Open

    const expectedData = [
      {name: 'greg', borough: 'brooklyn', age: '29', gender: 'm'},
      {name: 'jared', borough: 'manhattan', age: '29', gender: 'm'},
      {name: 'jessica', borough: 'brooklyn', age: '28', gender: 'f'},
      {name: 'markus', borough: 'manhattan', age: '28', gender: 'm'},
Severity: Major
Found in test/logic/fixDataFormat.js and 7 other locations - About 7 hrs to fix
test/logic/accumulator.js on lines 4..13
test/logic/createColumnHeaders.js on lines 4..13
test/logic/fixDataFormat.js on lines 4..13
test/logic/fixDataFormat.js on lines 65..74
test/logic/groupByCategories.js on lines 4..13
test/logic/groupByCategory.js on lines 4..13
test/logic/tableCreator.js on lines 4..13

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

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 8 locations. Consider refactoring.
Open

const data = [
  {name: 'patrick', borough: 'brooklyn', age: '28', gender: 'm'},
  {name: 'greg', borough: 'brooklyn', age: '29', gender: 'm'},
  {name: 'niles', borough: 'manhattan', age: '30', gender: 'm'},
  {name: 'jared', borough: 'manhattan', age: '29', gender: 'm'},
Severity: Major
Found in test/logic/fixDataFormat.js and 7 other locations - About 7 hrs to fix
test/logic/accumulator.js on lines 4..13
test/logic/createColumnHeaders.js on lines 4..13
test/logic/fixDataFormat.js on lines 65..74
test/logic/fixDataFormat.js on lines 81..90
test/logic/groupByCategories.js on lines 4..13
test/logic/groupByCategory.js on lines 4..13
test/logic/tableCreator.js on lines 4..13

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

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

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

          value: [
            'm',
            [
              {name: 'patrick', borough: 'brooklyn', age: '28', gender: 'm'},
              {name: 'greg', borough: 'brooklyn', age: '29', gender: 'm'},
Severity: Major
Found in test/logic/tableCreator.js and 1 other location - About 5 hrs to fix
test/logic/tableCreator.js on lines 71..95

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

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

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

            value: [
              'm',
              [
                {
                  name: 'patrick',
Severity: Major
Found in test/logic/tableCreator.js and 1 other location - About 5 hrs to fix
test/logic/tableCreator.js on lines 170..184

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

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

File tableCreator.js has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { expect } from 'chai';
import { tableCreator } from '../../src/logic.js';

const data = [
  {name: 'patrick', borough: 'brooklyn', age: '28', gender: 'm'},
Severity: Minor
Found in test/logic/tableCreator.js - About 4 hrs to fix

    File logic.js has 355 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @file Contains logic to actually pivot data
    */
    
    /**
    Severity: Minor
    Found in src/logic.js - About 4 hrs to fix

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

        it('should expand all header rows', () => {
          const pivot = create();
          pivot.collapseAll();
      
          pivot.expandAll();
      Severity: Major
      Found in test/index/expandAll.js and 1 other location - About 3 hrs to fix
      test/index/collapseAll.js on lines 51..59

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

      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

        it('should not fail if called multiple times', () => {
          const pivot = create();
      
          pivot.collapseAll();
          pivot.collapseAll();
      Severity: Major
      Found in test/index/collapseAll.js and 1 other location - About 3 hrs to fix
      test/index/expandAll.js on lines 60..68

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

      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

        expandAll() {
          this.data.table
            .map((row, rowNum) => row.type === 'rowHeader' ? rowNum : null)
            .filter(rowNum => rowNum !== null)
            .reverse()
      Severity: Major
      Found in src/index.js and 1 other location - About 3 hrs to fix
      src/index.js on lines 131..139

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

      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

        collapseAll() {
          this.data.table
            .map((row, rowNum) => row.type === 'rowHeader' ? rowNum : null)
            .filter(rowNum => rowNum !== null)
            .reverse()
      Severity: Major
      Found in src/index.js and 1 other location - About 3 hrs to fix
      src/index.js on lines 145..153

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

      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

      File filter.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { expect } from 'chai';
      import Pivot from '../../src';
      
      const dataArray = [
       ['name', 'gender', 'house', 'age'],
      Severity: Minor
      Found in test/index/filter.js - About 3 hrs to fix

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

          function rowRecurse(rowGroups, depth, rowHeaders = []) {
            for (const key in rowGroups) {
              if (Array.isArray(rowGroups[key])) {
                const recursedData = groupByCategories(rowGroups[key], cols);
        
        
        Severity: Major
        Found in src/logic.js - About 2 hrs to fix

          File expand.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { expect } from 'chai';
          import Pivot from '../../src';
          
          const dataArray = [
            ['name', 'gender', 'house', 'age'],
          Severity: Minor
          Found in test/index/expand.js - About 2 hrs to fix

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

                const expectedTableResults = [
                  {
                    value: ['total', 'total', 'Totals'],
                    row: 0,
                    depth: 0,
            Severity: Major
            Found in test/logic/tableCreator.js and 1 other location - About 2 hrs to fix
            test/logic/tableCreator.js on lines 284..298

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

            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

                      const expectedTableResults = [
                        {
                          value: ['count age', 'count age', 'Totals'],
                          row: 0,
                          depth: 0,
            Severity: Major
            Found in test/logic/tableCreator.js and 1 other location - About 2 hrs to fix
            test/logic/tableCreator.js on lines 305..319

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

            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

            Function fixDataFormat has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function fixDataFormat(data, rows = [], sortFunc) {
              if (!Array.isArray(data) || !data.length) return [];
            
              let formattedData = [];
            
            
            Severity: Minor
            Found in src/logic.js - About 1 hr to fix

              Line 22 exceeds the maximum line length of 80.
              Open

                { value: ['sum age', 'Stark', 'Baratheon', 'Lannister', 'Totals'], type: 'colHeader', depth: 0, row: 0 },
              Severity: Minor
              Found in test/index/collapseAll.js by eslint

              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. The length of a line is defined as the number of Unicode characters in the line.

              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
              • "ignoreStrings": true ignores lines that contain a double-quoted or single-quoted string
              • "ignoreTemplateLiterals": true ignores lines that contain a template literal
              • "ignoreRegExpLiterals": true ignores lines that contain a RegExp literal

              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';

              ignoreStrings

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

              /*eslint max-len: ["error", { "ignoreStrings": true }]*/
              
              var longString = 'this is a really really really really really long string!';

              ignoreTemplateLiterals

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

              /*eslint max-len: ["error", { "ignoreTemplateLiterals": true }]*/
              
              var longTemplateLiteral = `this is a really really really really really long template literal!`;

              ignoreRegExpLiterals

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

              /*eslint max-len: ["error", { "ignoreRegExpLiterals": true }]*/
              
              var longRegExpLiteral = /this is a really really really really really long regular expression!/;

              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 22 exceeds the maximum line length of 80.
              Open

                { value: ['sum age', 'Stark', 'Baratheon', 'Lannister', 'Totals'], type: 'colHeader', depth: 0, row: 0 },
              Severity: Minor
              Found in test/index/expandAll.js by eslint

              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. The length of a line is defined as the number of Unicode characters in the line.

              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
              • "ignoreStrings": true ignores lines that contain a double-quoted or single-quoted string
              • "ignoreTemplateLiterals": true ignores lines that contain a template literal
              • "ignoreRegExpLiterals": true ignores lines that contain a RegExp literal

              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';

              ignoreStrings

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

              /*eslint max-len: ["error", { "ignoreStrings": true }]*/
              
              var longString = 'this is a really really really really really long string!';

              ignoreTemplateLiterals

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

              /*eslint max-len: ["error", { "ignoreTemplateLiterals": true }]*/
              
              var longTemplateLiteral = `this is a really really really really really long template literal!`;

              ignoreRegExpLiterals

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

              /*eslint max-len: ["error", { "ignoreRegExpLiterals": true }]*/
              
              var longRegExpLiteral = /this is a really really really really really long regular expression!/;

              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/
              Severity
              Category
              Status
              Source
              Language