marionebl/jogwheel

View on GitHub
source/test/integration/index.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function main has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function main() {
    const state = document.querySelector('[data-stage-state]');
    const stage = document.querySelector('[data-stage-demos]');
    const handle = document.querySelector('[data-stage-handle]');
    const img = document.createElement('img');
Severity: Major
Found in source/test/integration/index.js - About 4 hrs to fix

    Function onload has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    const onload = async function () {
                        const frameDocument = frame.contentDocument || frame.contentWindow.document;
                        const inject = getInject(frameDocument.body);
    
                        // fetch test styling
    Severity: Minor
    Found in source/test/integration/index.js - About 1 hr to fix

      Unexpected named async function 'inject'.
      Open

          return async function inject(asset) {
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      Require or disallow named function expressions (func-names)

      A pattern that's becoming more common is to give function expressions names to aid in debugging. For example:

      Foo.prototype.bar = function bar() {};

      Adding the second bar in the above example is optional. If you leave off the function name then when the function throws an exception you are likely to get something similar to anonymous function in the stack trace. If you provide the optional name for a function expression then you will get the name of the function expression in the stack trace.

      Rule Details

      This rule can enforce or disallow the use of named function expressions.

      Options

      This rule has a string option:

      • "always" (default) requires function expressions to have a name
      • "as-needed" requires function expressions to have a name, if the name cannot be assigned automatically in an ES6 environment
      • "never" disallows named function expressions, except in recursive functions, where a name is needed

      always

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

      /*eslint func-names: ["error", "always"]*/
      
      Foo.prototype.bar = function() {};
      
      (function() {
          // ...
      }())

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

      /*eslint func-names: ["error", "always"]*/
      
      Foo.prototype.bar = function bar() {};
      
      (function bar() {
          // ...
      }())

      as-needed

      ECMAScript 6 introduced a name property on all functions. The value of name is determined by evaluating the code around the function to see if a name can be inferred. For example, a function assigned to a variable will automatically have a name property equal to the name of the variable. The value of name is then used in stack traces for easier debugging.

      Examples of incorrect code for this rule with the default "as-needed" option:

      /*eslint func-names: ["error", "as-needed"]*/
      
      Foo.prototype.bar = function() {};
      
      (function() {
          // ...
      }())

      Examples of correct code for this rule with the default "as-needed" option:

      /*eslint func-names: ["error", "as-needed"]*/
      
      var bar = function() {};
      
      (function bar() {
          // ...
      }())

      never

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

      /*eslint func-names: ["error", "never"]*/
      
      Foo.prototype.bar = function bar() {};
      
      (function bar() {
          // ...
      }())

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

      /*eslint func-names: ["error", "never"]*/
      
      Foo.prototype.bar = function() {};
      
      (function() {
          // ...
      }())

      Further Reading

      Compatibility

      Comments should not begin with a lowercase character
      Open

                          // await css and html, inject them
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      enforce or disallow capitalization of the first letter of a comment (capitalized-comments)

      Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase.

      In general, no comment style is any more or less valid than any others, but many developers would agree that a consistent style can improve a project's maintainability.

      Rule Details

      This rule aims to enforce a consistent style of comments across your codebase, specifically by either requiring or disallowing a capitalized letter as the first word character in a comment. This rule will not issue warnings when non-cased letters are used.

      By default, this rule will require a non-lowercase letter at the beginning of comments.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      Options

      This rule has two options: a string value "always" or "never" which determines whether capitalization of the first word of a comment should be required or forbidden, and optionally an object containing more configuration parameters for the rule.

      Here are the supported object options:

      • ignorePattern: A string representing a regular expression pattern of words that should be ignored by this rule. If the first word of a comment matches the pattern, this rule will not report that comment.
        • Note that the following words are always ignored by this rule: ["jscs", "jshint", "eslint", "istanbul", "global", "globals", "exported"].
      • ignoreInlineComments: If this is true, the rule will not report on comments in the middle of code. By default, this is false.
      • ignoreConsecutiveComments: If this is true, the rule will not report on a comment which violates the rule, as long as the comment immediately follows another comment. By default, this is false.

      Here is an example configuration:

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "ignorePattern": "pragma|ignored",
                  "ignoreInlineComments": true
              }
          ]
      }

      "always"

      Using the "always" option means that this rule will report any comments which start with a lowercase letter. This is the default configuration for this rule.

      Note that configuration comments and comments which start with URLs are never reported.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      "never"

      Using the "never" option means that this rule will report any comments which start with an uppercase letter.

      Examples of incorrect code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // Capitalized comment

      Examples of correct code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // lowercase comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment

      ignorePattern

      The ignorePattern object takes a string value, which is used as a regular expression applied to the first word of a comment.

      Examples of correct code with the "ignorePattern" option set to "pragma":

      /* eslint capitalized-comments: ["error", "always", { "ignorePattern": "pragma" }] */
      
      function foo() {
          /* pragma wrap(true) */
      }

      ignoreInlineComments

      Setting the ignoreInlineComments option to true means that comments in the middle of code (with a token on the same line as the beginning of the comment, and another token on the same line as the end of the comment) will not be reported by this rule.

      Examples of correct code with the "ignoreInlineComments" option set to true:

      /* eslint capitalized-comments: ["error", "always", { "ignoreInlineComments": true }] */
      
      function foo(/* ignored */ a) {
      }

      ignoreConsecutiveComments

      If the ignoreConsecutiveComments option is set to true, then comments which otherwise violate the rule will not be reported as long as they immediately follow another comment. This can be applied more than once.

      Examples of correct code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // This comment is valid since it has the correct capitalization.
      // this comment is ignored since it follows another comment,
      // and this one as well because it follows yet another comment.
      
      /* Here is a block comment which has the correct capitalization, */
      /* but this one is ignored due to being consecutive; */
      /*
       * in fact, even if any of these are multi-line, that is fine too.
       */

      Examples of incorrect code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // this comment is invalid, but only on this line.
      // this comment does NOT get reported, since it is a consecutive comment.

      Using Different Options for Line and Block Comments

      If you wish to have a different configuration for line comments and block comments, you can do so by using two different object configurations (note that the capitalization option will be enforced consistently for line and block comments):

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "line": {
                      "ignorePattern": "pragma|ignored",
                  },
                  "block": {
                      "ignoreInlineComments": true,
                      "ignorePattern": "ignored"
                  }
              }
          ]
      }

      Examples of incorrect code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // capitalized line comment, this is incorrect, blockignore does not help here
      /* lowercased block comment, this is incorrect too */

      Examples of correct code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // Uppercase line comment, this is correct
      /* blockignore lowercase block comment, this is correct due to ignorePattern */

      When Not To Use It

      This rule can be disabled if you do not care about the grammatical style of comments in your codebase.

      Compatibility

      Comments should not begin with a lowercase character
      Open

                          // fetch test javascript
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      enforce or disallow capitalization of the first letter of a comment (capitalized-comments)

      Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase.

      In general, no comment style is any more or less valid than any others, but many developers would agree that a consistent style can improve a project's maintainability.

      Rule Details

      This rule aims to enforce a consistent style of comments across your codebase, specifically by either requiring or disallowing a capitalized letter as the first word character in a comment. This rule will not issue warnings when non-cased letters are used.

      By default, this rule will require a non-lowercase letter at the beginning of comments.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      Options

      This rule has two options: a string value "always" or "never" which determines whether capitalization of the first word of a comment should be required or forbidden, and optionally an object containing more configuration parameters for the rule.

      Here are the supported object options:

      • ignorePattern: A string representing a regular expression pattern of words that should be ignored by this rule. If the first word of a comment matches the pattern, this rule will not report that comment.
        • Note that the following words are always ignored by this rule: ["jscs", "jshint", "eslint", "istanbul", "global", "globals", "exported"].
      • ignoreInlineComments: If this is true, the rule will not report on comments in the middle of code. By default, this is false.
      • ignoreConsecutiveComments: If this is true, the rule will not report on a comment which violates the rule, as long as the comment immediately follows another comment. By default, this is false.

      Here is an example configuration:

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "ignorePattern": "pragma|ignored",
                  "ignoreInlineComments": true
              }
          ]
      }

      "always"

      Using the "always" option means that this rule will report any comments which start with a lowercase letter. This is the default configuration for this rule.

      Note that configuration comments and comments which start with URLs are never reported.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      "never"

      Using the "never" option means that this rule will report any comments which start with an uppercase letter.

      Examples of incorrect code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // Capitalized comment

      Examples of correct code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // lowercase comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment

      ignorePattern

      The ignorePattern object takes a string value, which is used as a regular expression applied to the first word of a comment.

      Examples of correct code with the "ignorePattern" option set to "pragma":

      /* eslint capitalized-comments: ["error", "always", { "ignorePattern": "pragma" }] */
      
      function foo() {
          /* pragma wrap(true) */
      }

      ignoreInlineComments

      Setting the ignoreInlineComments option to true means that comments in the middle of code (with a token on the same line as the beginning of the comment, and another token on the same line as the end of the comment) will not be reported by this rule.

      Examples of correct code with the "ignoreInlineComments" option set to true:

      /* eslint capitalized-comments: ["error", "always", { "ignoreInlineComments": true }] */
      
      function foo(/* ignored */ a) {
      }

      ignoreConsecutiveComments

      If the ignoreConsecutiveComments option is set to true, then comments which otherwise violate the rule will not be reported as long as they immediately follow another comment. This can be applied more than once.

      Examples of correct code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // This comment is valid since it has the correct capitalization.
      // this comment is ignored since it follows another comment,
      // and this one as well because it follows yet another comment.
      
      /* Here is a block comment which has the correct capitalization, */
      /* but this one is ignored due to being consecutive; */
      /*
       * in fact, even if any of these are multi-line, that is fine too.
       */

      Examples of incorrect code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // this comment is invalid, but only on this line.
      // this comment does NOT get reported, since it is a consecutive comment.

      Using Different Options for Line and Block Comments

      If you wish to have a different configuration for line comments and block comments, you can do so by using two different object configurations (note that the capitalization option will be enforced consistently for line and block comments):

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "line": {
                      "ignorePattern": "pragma|ignored",
                  },
                  "block": {
                      "ignoreInlineComments": true,
                      "ignorePattern": "ignored"
                  }
              }
          ]
      }

      Examples of incorrect code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // capitalized line comment, this is incorrect, blockignore does not help here
      /* lowercased block comment, this is incorrect too */

      Examples of correct code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // Uppercase line comment, this is correct
      /* blockignore lowercase block comment, this is correct due to ignorePattern */

      When Not To Use It

      This rule can be disabled if you do not care about the grammatical style of comments in your codebase.

      Compatibility

      Unexpected function expression.
      Open

          tape('integration', async function(t) { // eslint-disable-line no-loop-func
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      Suggest using arrow functions as callbacks. (prefer-arrow-callback)

      Arrow functions are suited to callbacks, because:

      • this keywords in arrow functions bind to the upper scope's.
      • The notation of the arrow function is shorter than function expression's.

      Rule Details

      This rule is aimed to flag usage of function expressions in an argument list.

      The following patterns are considered problems:

      /*eslint prefer-arrow-callback: "error"*/
      
      foo(function(a) { return a; });
      foo(function() { return this.a; }.bind(this));

      The following patterns are not considered problems:

      /*eslint prefer-arrow-callback: "error"*/
      /*eslint-env es6*/
      
      foo(a => a);
      foo(function*() { yield; });
      
      // this is not a callback.
      var foo = function foo(a) { return a; };
      
      // using `this` without `.bind(this)`.
      foo(function() { return this.a; });
      
      // recursively.
      foo(function bar(n) { return n && n + bar(n - 1); });

      Options

      This rule takes one optional argument, an object which is an options object.

      allowNamedFunctions

      This is a boolean option and it is false by default. When set to true, the rule doesn't warn on named functions used as callbacks.

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

      /*eslint prefer-arrow-callback: ["error", { "allowNamedFunctions": true }]*/
      
      foo(function bar() {});

      allowUnboundThis

      This is a boolean option and it is true by default. When set to false, this option allows the use of this without restriction and checks for dynamically assigned this values such as when using Array.prototype.map with a context argument. Normally, the rule will flag the use of this whenever a function does not use bind() to specify the value of this constantly.

      Examples of incorrect code for the { "allowUnboundThis": false } option:

      /*eslint prefer-arrow-callback: ["error", { "allowUnboundThis": false }]*/
      /*eslint-env es6*/
      
      foo(function() { this.a; });
      
      foo(function() { (() => this); });
      
      someArray.map(function (itm) { return this.doSomething(itm); }, someObject);

      When Not To Use It

      This rule should not be used in ES3/5 environments.

      In ES2015 (ES6) or later, if you don't want to be notified about function expressions in an argument list, you can safely disable this rule. Source: http://eslint.org/docs/rules/

      Comments should not begin with a lowercase character
      Open

                          // fetch test styling
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      enforce or disallow capitalization of the first letter of a comment (capitalized-comments)

      Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase.

      In general, no comment style is any more or less valid than any others, but many developers would agree that a consistent style can improve a project's maintainability.

      Rule Details

      This rule aims to enforce a consistent style of comments across your codebase, specifically by either requiring or disallowing a capitalized letter as the first word character in a comment. This rule will not issue warnings when non-cased letters are used.

      By default, this rule will require a non-lowercase letter at the beginning of comments.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      Options

      This rule has two options: a string value "always" or "never" which determines whether capitalization of the first word of a comment should be required or forbidden, and optionally an object containing more configuration parameters for the rule.

      Here are the supported object options:

      • ignorePattern: A string representing a regular expression pattern of words that should be ignored by this rule. If the first word of a comment matches the pattern, this rule will not report that comment.
        • Note that the following words are always ignored by this rule: ["jscs", "jshint", "eslint", "istanbul", "global", "globals", "exported"].
      • ignoreInlineComments: If this is true, the rule will not report on comments in the middle of code. By default, this is false.
      • ignoreConsecutiveComments: If this is true, the rule will not report on a comment which violates the rule, as long as the comment immediately follows another comment. By default, this is false.

      Here is an example configuration:

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "ignorePattern": "pragma|ignored",
                  "ignoreInlineComments": true
              }
          ]
      }

      "always"

      Using the "always" option means that this rule will report any comments which start with a lowercase letter. This is the default configuration for this rule.

      Note that configuration comments and comments which start with URLs are never reported.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      "never"

      Using the "never" option means that this rule will report any comments which start with an uppercase letter.

      Examples of incorrect code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // Capitalized comment

      Examples of correct code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // lowercase comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment

      ignorePattern

      The ignorePattern object takes a string value, which is used as a regular expression applied to the first word of a comment.

      Examples of correct code with the "ignorePattern" option set to "pragma":

      /* eslint capitalized-comments: ["error", "always", { "ignorePattern": "pragma" }] */
      
      function foo() {
          /* pragma wrap(true) */
      }

      ignoreInlineComments

      Setting the ignoreInlineComments option to true means that comments in the middle of code (with a token on the same line as the beginning of the comment, and another token on the same line as the end of the comment) will not be reported by this rule.

      Examples of correct code with the "ignoreInlineComments" option set to true:

      /* eslint capitalized-comments: ["error", "always", { "ignoreInlineComments": true }] */
      
      function foo(/* ignored */ a) {
      }

      ignoreConsecutiveComments

      If the ignoreConsecutiveComments option is set to true, then comments which otherwise violate the rule will not be reported as long as they immediately follow another comment. This can be applied more than once.

      Examples of correct code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // This comment is valid since it has the correct capitalization.
      // this comment is ignored since it follows another comment,
      // and this one as well because it follows yet another comment.
      
      /* Here is a block comment which has the correct capitalization, */
      /* but this one is ignored due to being consecutive; */
      /*
       * in fact, even if any of these are multi-line, that is fine too.
       */

      Examples of incorrect code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // this comment is invalid, but only on this line.
      // this comment does NOT get reported, since it is a consecutive comment.

      Using Different Options for Line and Block Comments

      If you wish to have a different configuration for line comments and block comments, you can do so by using two different object configurations (note that the capitalization option will be enforced consistently for line and block comments):

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "line": {
                      "ignorePattern": "pragma|ignored",
                  },
                  "block": {
                      "ignoreInlineComments": true,
                      "ignorePattern": "ignored"
                  }
              }
          ]
      }

      Examples of incorrect code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // capitalized line comment, this is incorrect, blockignore does not help here
      /* lowercased block comment, this is incorrect too */

      Examples of correct code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // Uppercase line comment, this is correct
      /* blockignore lowercase block comment, this is correct due to ignorePattern */

      When Not To Use It

      This rule can be disabled if you do not care about the grammatical style of comments in your codebase.

      Compatibility

      Comments should not begin with a lowercase character
      Open

                          // fetch test markup
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      enforce or disallow capitalization of the first letter of a comment (capitalized-comments)

      Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase.

      In general, no comment style is any more or less valid than any others, but many developers would agree that a consistent style can improve a project's maintainability.

      Rule Details

      This rule aims to enforce a consistent style of comments across your codebase, specifically by either requiring or disallowing a capitalized letter as the first word character in a comment. This rule will not issue warnings when non-cased letters are used.

      By default, this rule will require a non-lowercase letter at the beginning of comments.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      Options

      This rule has two options: a string value "always" or "never" which determines whether capitalization of the first word of a comment should be required or forbidden, and optionally an object containing more configuration parameters for the rule.

      Here are the supported object options:

      • ignorePattern: A string representing a regular expression pattern of words that should be ignored by this rule. If the first word of a comment matches the pattern, this rule will not report that comment.
        • Note that the following words are always ignored by this rule: ["jscs", "jshint", "eslint", "istanbul", "global", "globals", "exported"].
      • ignoreInlineComments: If this is true, the rule will not report on comments in the middle of code. By default, this is false.
      • ignoreConsecutiveComments: If this is true, the rule will not report on a comment which violates the rule, as long as the comment immediately follows another comment. By default, this is false.

      Here is an example configuration:

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "ignorePattern": "pragma|ignored",
                  "ignoreInlineComments": true
              }
          ]
      }

      "always"

      Using the "always" option means that this rule will report any comments which start with a lowercase letter. This is the default configuration for this rule.

      Note that configuration comments and comments which start with URLs are never reported.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      "never"

      Using the "never" option means that this rule will report any comments which start with an uppercase letter.

      Examples of incorrect code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // Capitalized comment

      Examples of correct code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // lowercase comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment

      ignorePattern

      The ignorePattern object takes a string value, which is used as a regular expression applied to the first word of a comment.

      Examples of correct code with the "ignorePattern" option set to "pragma":

      /* eslint capitalized-comments: ["error", "always", { "ignorePattern": "pragma" }] */
      
      function foo() {
          /* pragma wrap(true) */
      }

      ignoreInlineComments

      Setting the ignoreInlineComments option to true means that comments in the middle of code (with a token on the same line as the beginning of the comment, and another token on the same line as the end of the comment) will not be reported by this rule.

      Examples of correct code with the "ignoreInlineComments" option set to true:

      /* eslint capitalized-comments: ["error", "always", { "ignoreInlineComments": true }] */
      
      function foo(/* ignored */ a) {
      }

      ignoreConsecutiveComments

      If the ignoreConsecutiveComments option is set to true, then comments which otherwise violate the rule will not be reported as long as they immediately follow another comment. This can be applied more than once.

      Examples of correct code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // This comment is valid since it has the correct capitalization.
      // this comment is ignored since it follows another comment,
      // and this one as well because it follows yet another comment.
      
      /* Here is a block comment which has the correct capitalization, */
      /* but this one is ignored due to being consecutive; */
      /*
       * in fact, even if any of these are multi-line, that is fine too.
       */

      Examples of incorrect code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // this comment is invalid, but only on this line.
      // this comment does NOT get reported, since it is a consecutive comment.

      Using Different Options for Line and Block Comments

      If you wish to have a different configuration for line comments and block comments, you can do so by using two different object configurations (note that the capitalization option will be enforced consistently for line and block comments):

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "line": {
                      "ignorePattern": "pragma|ignored",
                  },
                  "block": {
                      "ignoreInlineComments": true,
                      "ignorePattern": "ignored"
                  }
              }
          ]
      }

      Examples of incorrect code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // capitalized line comment, this is incorrect, blockignore does not help here
      /* lowercased block comment, this is incorrect too */

      Examples of correct code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // Uppercase line comment, this is correct
      /* blockignore lowercase block comment, this is correct due to ignorePattern */

      When Not To Use It

      This rule can be disabled if you do not care about the grammatical style of comments in your codebase.

      Compatibility

      Missing space before function parentheses.
      Open

          tape('integration', async function(t) { // eslint-disable-line no-loop-func
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      Require or disallow a space before function parenthesis (space-before-function-paren)

      When formatting a function, whitespace is allowed between the function name or function keyword and the opening paren. Named functions also require a space between the function keyword and the function name, but anonymous functions require no whitespace. For example:

      function withoutSpace(x) {
          // ...
      }
      
      function withSpace (x) {
          // ...
      }
      
      var anonymousWithoutSpace = function() {};
      
      var anonymousWithSpace = function () {};

      Style guides may require a space after the function keyword for anonymous functions, while others specify no whitespace. Similarly, the space after a function name may or may not be required.

      Rule Details

      This rule aims to enforce consistent spacing before function parentheses and as such, will warn whenever whitespace doesn't match the preferences specified.

      Options

      This rule has a string option or an object option:

      {
          "space-before-function-paren": ["error", "always"],
          // or
          "space-before-function-paren": ["error", {
              "anonymous": "always",
              "named": "always",
              "asyncArrow": "ignore"
          }],
      }
      • always (default) requires a space followed by the ( of arguments.
      • never disallows any space followed by the ( of arguments.

      The string option does not check async arrow function expressions for backward compatibility.

      You can also use a separate option for each type of function. Each of the following options can be set to "always", "never", or "ignore". Default is "always" basically.

      • anonymous is for anonymous function expressions (e.g. function () {}).
      • named is for named function expressions (e.g. function foo () {}).
      • asyncArrow is for async arrow function expressions (e.g. async () => {}). asyncArrow is set to "ignore" by default for backwards compatibility.

      "always"

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

      /*eslint space-before-function-paren: "error"*/
      /*eslint-env es6*/
      
      function foo() {
          // ...
      }
      
      var bar = function() {
          // ...
      };
      
      var bar = function foo() {
          // ...
      };
      
      class Foo {
          constructor() {
              // ...
          }
      }
      
      var foo = {
          bar() {
              // ...
          }
      };

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

      /*eslint space-before-function-paren: "error"*/
      /*eslint-env es6*/
      
      function foo () {
          // ...
      }
      
      var bar = function () {
          // ...
      };
      
      var bar = function foo () {
          // ...
      };
      
      class Foo {
          constructor () {
              // ...
          }
      }
      
      var foo = {
          bar () {
              // ...
          }
      };
      
      // async arrow function expressions are ignored by default.
      var foo = async () => 1
      var foo = async() => 1

      "never"

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

      /*eslint space-before-function-paren: ["error", "never"]*/
      /*eslint-env es6*/
      
      function foo () {
          // ...
      }
      
      var bar = function () {
          // ...
      };
      
      var bar = function foo () {
          // ...
      };
      
      class Foo {
          constructor () {
              // ...
          }
      }
      
      var foo = {
          bar () {
              // ...
          }
      };

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

      /*eslint space-before-function-paren: ["error", "never"]*/
      /*eslint-env es6*/
      
      function foo() {
          // ...
      }
      
      var bar = function() {
          // ...
      };
      
      var bar = function foo() {
          // ...
      };
      
      class Foo {
          constructor() {
              // ...
          }
      }
      
      var foo = {
          bar() {
              // ...
          }
      };
      
      // async arrow function expressions are ignored by default.
      var foo = async () => 1
      var foo = async() => 1

      {"anonymous": "always", "named": "never", "asyncArrow": "always"}

      Examples of incorrect code for this rule with the {"anonymous": "always", "named": "never", "asyncArrow": "always"} option:

      /*eslint space-before-function-paren: ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}]*/
      /*eslint-env es6*/
      
      function foo () {
          // ...
      }
      
      var bar = function() {
          // ...
      };
      
      class Foo {
          constructor () {
              // ...
          }
      }
      
      var foo = {
          bar () {
              // ...
          }
      };
      
      var foo = async(a) => await a

      Examples of correct code for this rule with the {"anonymous": "always", "named": "never", "asyncArrow": "always"} option:

      /*eslint space-before-function-paren: ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}]*/
      /*eslint-env es6*/
      
      function foo() {
          // ...
      }
      
      var bar = function () {
          // ...
      };
      
      class Foo {
          constructor() {
              // ...
          }
      }
      
      var foo = {
          bar() {
              // ...
          }
      };
      
      var foo = async (a) => await a

      {"anonymous": "never", "named": "always"}

      Examples of incorrect code for this rule with the {"anonymous": "never", "named": "always"} option:

      /*eslint space-before-function-paren: ["error", { "anonymous": "never", "named": "always" }]*/
      /*eslint-env es6*/
      
      function foo() {
          // ...
      }
      
      var bar = function () {
          // ...
      };
      
      class Foo {
          constructor() {
              // ...
          }
      }
      
      var foo = {
          bar() {
              // ...
          }
      };

      Examples of correct code for this rule with the {"anonymous": "never", "named": "always"} option:

      /*eslint space-before-function-paren: ["error", { "anonymous": "never", "named": "always" }]*/
      /*eslint-env es6*/
      
      function foo () {
          // ...
      }
      
      var bar = function() {
          // ...
      };
      
      class Foo {
          constructor () {
              // ...
          }
      }
      
      var foo = {
          bar () {
              // ...
          }
      };

      {"anonymous": "ignore", "named": "always"}

      Examples of incorrect code for this rule with the {"anonymous": "ignore", "named": "always"} option:

      /*eslint space-before-function-paren: ["error", { "anonymous": "ignore", "named": "always" }]*/
      /*eslint-env es6*/
      
      function foo() {
          // ...
      }
      
      class Foo {
          constructor() {
              // ...
          }
      }
      
      var foo = {
          bar() {
              // ...
          }
      };

      Examples of correct code for this rule with the {"anonymous": "ignore", "named": "always"} option:

      /*eslint space-before-function-paren: ["error", { "anonymous": "ignore", "named": "always" }]*/
      /*eslint-env es6*/
      
      var bar = function() {
          // ...
      };
      
      var bar = function () {
          // ...
      };
      
      function foo () {
          // ...
      }
      
      class Foo {
          constructor () {
              // ...
          }
      }
      
      var foo = {
          bar () {
              // ...
          }
      };

      When Not To Use It

      You can turn this rule off if you are not concerned with the consistency of spacing before function parenthesis.

      Related Rules

      Comments should not begin with a lowercase character
      Open

                          // inject js when css and html is injected
      Severity: Minor
      Found in source/test/integration/index.js by eslint

      enforce or disallow capitalization of the first letter of a comment (capitalized-comments)

      Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase.

      In general, no comment style is any more or less valid than any others, but many developers would agree that a consistent style can improve a project's maintainability.

      Rule Details

      This rule aims to enforce a consistent style of comments across your codebase, specifically by either requiring or disallowing a capitalized letter as the first word character in a comment. This rule will not issue warnings when non-cased letters are used.

      By default, this rule will require a non-lowercase letter at the beginning of comments.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      Options

      This rule has two options: a string value "always" or "never" which determines whether capitalization of the first word of a comment should be required or forbidden, and optionally an object containing more configuration parameters for the rule.

      Here are the supported object options:

      • ignorePattern: A string representing a regular expression pattern of words that should be ignored by this rule. If the first word of a comment matches the pattern, this rule will not report that comment.
        • Note that the following words are always ignored by this rule: ["jscs", "jshint", "eslint", "istanbul", "global", "globals", "exported"].
      • ignoreInlineComments: If this is true, the rule will not report on comments in the middle of code. By default, this is false.
      • ignoreConsecutiveComments: If this is true, the rule will not report on a comment which violates the rule, as long as the comment immediately follows another comment. By default, this is false.

      Here is an example configuration:

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "ignorePattern": "pragma|ignored",
                  "ignoreInlineComments": true
              }
          ]
      }

      "always"

      Using the "always" option means that this rule will report any comments which start with a lowercase letter. This is the default configuration for this rule.

      Note that configuration comments and comments which start with URLs are never reported.

      Examples of incorrect code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // lowercase comment

      Examples of correct code for this rule:

      /* eslint capitalized-comments: ["error", "always"] */
      
      // Capitalized comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment
      
      /* eslint semi:off */
      /* eslint-env node */
      /* eslint-disable */
      /* eslint-enable */
      /* istanbul ignore next */
      /* jscs:enable */
      /* jshint asi:true */
      /* global foo */
      /* globals foo */
      /* exported myVar */
      // eslint-disable-line
      // eslint-disable-next-line
      // https://github.com

      "never"

      Using the "never" option means that this rule will report any comments which start with an uppercase letter.

      Examples of incorrect code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // Capitalized comment

      Examples of correct code with the "never" option:

      /* eslint capitalized-comments: ["error", "never"] */
      
      // lowercase comment
      
      // 1. Non-letter at beginning of comment
      
      // 丈 Non-Latin character at beginning of comment

      ignorePattern

      The ignorePattern object takes a string value, which is used as a regular expression applied to the first word of a comment.

      Examples of correct code with the "ignorePattern" option set to "pragma":

      /* eslint capitalized-comments: ["error", "always", { "ignorePattern": "pragma" }] */
      
      function foo() {
          /* pragma wrap(true) */
      }

      ignoreInlineComments

      Setting the ignoreInlineComments option to true means that comments in the middle of code (with a token on the same line as the beginning of the comment, and another token on the same line as the end of the comment) will not be reported by this rule.

      Examples of correct code with the "ignoreInlineComments" option set to true:

      /* eslint capitalized-comments: ["error", "always", { "ignoreInlineComments": true }] */
      
      function foo(/* ignored */ a) {
      }

      ignoreConsecutiveComments

      If the ignoreConsecutiveComments option is set to true, then comments which otherwise violate the rule will not be reported as long as they immediately follow another comment. This can be applied more than once.

      Examples of correct code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // This comment is valid since it has the correct capitalization.
      // this comment is ignored since it follows another comment,
      // and this one as well because it follows yet another comment.
      
      /* Here is a block comment which has the correct capitalization, */
      /* but this one is ignored due to being consecutive; */
      /*
       * in fact, even if any of these are multi-line, that is fine too.
       */

      Examples of incorrect code with ignoreConsecutiveComments set to true:

      /* eslint capitalize-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */
      
      // this comment is invalid, but only on this line.
      // this comment does NOT get reported, since it is a consecutive comment.

      Using Different Options for Line and Block Comments

      If you wish to have a different configuration for line comments and block comments, you can do so by using two different object configurations (note that the capitalization option will be enforced consistently for line and block comments):

      {
          "capitalized-comments": [
              "error",
              "always",
              {
                  "line": {
                      "ignorePattern": "pragma|ignored",
                  },
                  "block": {
                      "ignoreInlineComments": true,
                      "ignorePattern": "ignored"
                  }
              }
          ]
      }

      Examples of incorrect code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // capitalized line comment, this is incorrect, blockignore does not help here
      /* lowercased block comment, this is incorrect too */

      Examples of correct code with different line and block comment configuration:

      /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */
      
      // Uppercase line comment, this is correct
      /* blockignore lowercase block comment, this is correct due to ignorePattern */

      When Not To Use It

      This rule can be disabled if you do not care about the grammatical style of comments in your codebase.

      Compatibility

      There are no issues that match your filters.

      Category
      Status