reactioncommerce/redoc

View on GitHub
packages/redoc-core/lib/plugins/api.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function APIParser has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function APIParser(md) {
  function addSections(state) {
    let tokens = [];  // output
    const Token = state.Token;
    let sectionTokens = [];
Severity: Major
Found in packages/redoc-core/lib/plugins/api.js - About 4 hrs to fix

    Function addSections has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function addSections(state) {
        let tokens = [];  // output
        const Token = state.Token;
        let sectionTokens = [];
    
    
    Severity: Major
    Found in packages/redoc-core/lib/plugins/api.js - About 3 hrs to fix

      Unexpected console statement.
      Open

            console.log(token);

      disallow the use of console (no-console)

      In JavaScript that is designed to be executed in the browser, it's considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

      console.log("Made it here.");
      console.error("That shouldn't have happened.");

      Rule Details

      This rule disallows calls to methods of the console object.

      Examples of incorrect code for this rule:

      /*eslint no-console: "error"*/
      
      console.log("Log a debug level message.");
      console.warn("Log a warn level message.");
      console.error("Log an error level message.");

      Examples of correct code for this rule:

      /*eslint no-console: "error"*/
      
      // custom console
      Console.log("Hello world!");

      Options

      This rule has an object option for exceptions:

      • "allow" has an array of strings which are allowed methods of the console object

      Examples of additional correct code for this rule with a sample { "allow": ["warn", "error"] } option:

      /*eslint no-console: ["error", { allow: ["warn", "error"] }] */
      
      console.warn("Log a warn level message.");
      console.error("Log an error level message.");

      When Not To Use It

      If you're using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

      Related Rules

      There are no issues that match your filters.

      Category
      Status