fbredius/storybook

View on GitHub
lib/core-common/src/utils/load-custom-babel-config.ts

Summary

Maintainability
A
2 hrs
Test Coverage

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

function loadFromPath(babelConfigPath: string): TransformOptions {
  let config: TransformOptions;
  const error: {
    js?: Error;
    json?: Error;
Severity: Minor
Found in lib/core-common/src/utils/load-custom-babel-config.ts - About 1 hr to fix

    Function loadFromPath has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function loadFromPath(babelConfigPath: string): TransformOptions {
      let config: TransformOptions;
      const error: {
        js?: Error;
        json?: Error;
    Severity: Minor
    Found in lib/core-common/src/utils/load-custom-babel-config.ts - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    non-arrow functions are forbidden
    Open

    export const loadCustomBabelConfig = async function (

    Rule: only-arrow-functions

    Disallows traditional (non-arrow) function expressions.

    Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).

    Rationale

    Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.

    Config

    Two arguments may be optionally provided:

    • "allow-declarations" allows standalone function declarations.
    • "allow-named-functions" allows the expression function foo() {} but not function() {}.
    Examples
    "only-arrow-functions": true
    "only-arrow-functions": true,allow-declarations,allow-named-functions
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-declarations",
          "allow-named-functions"
        ]
      },
      "minLength": 0,
      "maxLength": 1
    }

    For more information see this page.

    There are no issues that match your filters.

    Category
    Status