championswimmer/vuex-persist

View on GitHub

Showing 27 of 27 total issues

Function constructor has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
Open

  public constructor(options?: PersistOptions<S>) {
    if (typeof options === 'undefined') options = {} as PersistOptions<S>
    this.key = ((options.key != null) ? options.key : 'vuex')

    this.subscribed = false
Severity: Minor
Found in src/index.ts - About 1 day 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

Function constructor has 141 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public constructor(options?: PersistOptions<S>) {
    if (typeof options === 'undefined') options = {} as PersistOptions<S>
    this.key = ((options.key != null) ? options.key : 'vuex')

    this.subscribed = false
Severity: Major
Found in src/index.ts - About 5 hrs to fix

    block is empty
    Open

      keys() { },
    Severity: Minor
    Found in test/vuex-asyncstorage.spec.ts by tslint

    Rule: no-empty

    Disallows empty blocks.

    Blocks with a comment inside are not considered empty.

    Rationale

    Empty blocks are often indicators of missing code.

    Config

    If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

    Examples
    "no-empty": true
    "no-empty": true,allow-empty-catch
    "no-empty": true,allow-empty-functions
    "no-empty": true,allow-empty-catch,allow-empty-functions
    Schema
    {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "allow-empty-catch"
            ]
          },
          {
            "type": "string",
            "enum": [
              "allow-empty-functions"
            ]
          }
        ]
      }
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

        expect(getSavedStore().cat).to.be.undefined

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

        expect(getSavedStore().cat).to.be.undefined
    Severity: Minor
    Found in test/vuex-modules.spec.ts by tslint

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

        expect(objectStore['dafuq']).to.exist
    Severity: Minor
    Found in test/vuex-asyncstorage.spec.ts by tslint

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    " should be '
    Open

      mergeOption: "concatArrays"

    Rule: quotemark

    Enforces quote character for string literals.

    Notes
    • Has Fix

    Config

    Five arguments may be optionally provided:

    • "single" enforces single quotes.
    • "double" enforces double quotes.
    • "backtick" enforces backticks.
    • "jsx-single" enforces single quotes for JSX attributes.
    • "jsx-double" enforces double quotes for JSX attributes.
    • "avoid-template" forbids single-line untagged template strings that do not contain string interpolations. Note that backticks may still be used if "avoid-escape" is enabled and both single and double quotes are present in the string (the latter option takes precedence).
    • "avoid-escape" allows you to use the "other" quotemark in cases where escaping would normally be required. For example, [true, "double", "avoid-escape"] would not report a failure on the string literal 'Hello "World"'.
    Examples
    "quotemark": true,single,avoid-escape,avoid-template
    "quotemark": true,single,jsx-double
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "single",
          "double",
          "backtick",
          "jsx-single",
          "jsx-double",
          "avoid-escape",
          "avoid-template"
        ]
      },
      "minLength": 0,
      "maxLength": 5
    }

    For more information see this page.

    " should be '
    Open

        else { throw new Error("Neither 'window' is defined, nor 'MockStorage' is available") }
    Severity: Minor
    Found in src/index.ts by tslint

    Rule: quotemark

    Enforces quote character for string literals.

    Notes
    • Has Fix

    Config

    Five arguments may be optionally provided:

    • "single" enforces single quotes.
    • "double" enforces double quotes.
    • "backtick" enforces backticks.
    • "jsx-single" enforces single quotes for JSX attributes.
    • "jsx-double" enforces double quotes for JSX attributes.
    • "avoid-template" forbids single-line untagged template strings that do not contain string interpolations. Note that backticks may still be used if "avoid-escape" is enabled and both single and double quotes are present in the string (the latter option takes precedence).
    • "avoid-escape" allows you to use the "other" quotemark in cases where escaping would normally be required. For example, [true, "double", "avoid-escape"] would not report a failure on the string literal 'Hello "World"'.
    Examples
    "quotemark": true,single,avoid-escape,avoid-template
    "quotemark": true,single,jsx-double
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "single",
          "double",
          "backtick",
          "jsx-single",
          "jsx-double",
          "avoid-escape",
          "avoid-template"
        ]
      },
      "minLength": 0,
      "maxLength": 5
    }

    For more information see this page.

    Shadowed name: 'options'
    Open

        arrayMerge: (target, source, options) => target.concat(...source)
    Severity: Minor
    Found in src/utils.ts by tslint

    Rule: no-shadowed-variable

    Disallows shadowing variable declarations.

    Rationale

    When a variable in a local scope and a variable in the containing scope have the same name, shadowing occurs. Shadowing makes it impossible to access the variable in the containing scope and obscures to what value an identifier actually refers. Compare the following snippets:

    const a = 'no shadow';
    function print() {
        console.log(a);
    }
    print(); // logs 'no shadow'.
    const a = 'no shadow';
    function print() {
        const a = 'shadow'; // TSLint will complain here.
        console.log(a);
    }
    print(); // logs 'shadow'.

    ESLint has an equivalent rule. For more background information, refer to this MDN closure doc.

    Config

    You can optionally pass an object to disable checking for certain kinds of declarations. Possible keys are "class", "enum", "function", "import", "interface", "namespace", "typeAlias" and "typeParameter". You can also pass "underscore" to ignore variable names that begin with _. Just set the value to false for the check you want to disable. All checks default to true, i.e. are enabled by default. Note that you cannot disable variables and parameters.

    The option "temporalDeadZone" defaults to true which shows errors when shadowing block scoped declarations in their temporal dead zone. When set to false parameters, classes, enums and variables declared with let or const are not considered shadowed if the shadowing occurs within their temporal dead zone.

    The following example shows how the "temporalDeadZone" option changes the linting result:

    function fn(value) {
        if (value) {
            const tmp = value; // no error on this line if "temporalDeadZone" is false
            return tmp;
        }
        let tmp = undefined;
        if (!value) {
            const tmp = value; // this line always contains an error
            return tmp;
        }
    }
    Examples
    "no-shadowed-variable": true
    "no-shadowed-variable": true,[object Object]
    Schema
    {
      "type": "object",
      "properties": {
        "class": {
          "type": "boolean"
        },
        "enum": {
          "type": "boolean"
        },
        "function": {
          "type": "boolean"
        },
        "import": {
          "type": "boolean"
        },
        "interface": {
          "type": "boolean"
        },
        "namespace": {
          "type": "boolean"
        },
        "typeAlias": {
          "type": "boolean"
        },
        "typeParameter": {
          "type": "boolean"
        },
        "temporalDeadZone": {
          "type": "boolean"
        },
        "underscore": {
          "type": "boolean"
        }
      }
    }

    For more information see this page.

    trailing whitespace
    Open

      
    Severity: Minor
    Found in src/utils.ts by tslint

    Rule: no-trailing-whitespace

    Disallows trailing whitespace at the end of a line.

    Rationale

    Keeps version control diffs clean as it prevents accidental whitespace from being committed.

    Notes
    • Has Fix

    Config

    Possible settings are:

    • "ignore-template-strings": Allows trailing whitespace in template strings.
    • "ignore-comments": Allows trailing whitespace in comments.
    • "ignore-jsdoc": Allows trailing whitespace only in JSDoc comments.
    • "ignore-blank-lines": Allows trailing whitespace on empty lines.
    Examples
    "no-trailing-whitespace": true
    "no-trailing-whitespace": true,ignore-comments
    "no-trailing-whitespace": true,ignore-jsdoc
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "ignore-comments",
          "ignore-jsdoc",
          "ignore-template-strings",
          "ignore-blank-lines"
        ]
      }
    }

    For more information see this page.

    block is empty
    Open

      _initStorage() { },
    Severity: Minor
    Found in test/vuex-asyncstorage.spec.ts by tslint

    Rule: no-empty

    Disallows empty blocks.

    Blocks with a comment inside are not considered empty.

    Rationale

    Empty blocks are often indicators of missing code.

    Config

    If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

    Examples
    "no-empty": true
    "no-empty": true,allow-empty-catch
    "no-empty": true,allow-empty-functions
    "no-empty": true,allow-empty-catch,allow-empty-functions
    Schema
    {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "allow-empty-catch"
            ]
          },
          {
            "type": "string",
            "enum": [
              "allow-empty-functions"
            ]
          }
        ]
      }
    }

    For more information see this page.

    Identifier 'key' is never reassigned; use 'const' instead of 'let'.
    Open

          for (let key of Object.keys(this)) {
    Severity: Minor
    Found in src/MockStorage.ts by tslint

    Rule: prefer-const

    Requires that variable declarations use const instead of let and var if possible.

    If a variable is only assigned to once when it is declared, it should be declared using 'const'

    Notes
    • Has Fix

    Config

    An optional object containing the property "destructuring" with two possible values:

    • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
    • "all" - Only warns if all variables in destructuring can be const.
    Examples
    "prefer-const": true
    "prefer-const": true,[object Object]
    Schema
    {
      "type": "object",
      "properties": {
        "destructuring": {
          "type": "string",
          "enum": [
            "all",
            "any"
          ]
        }
      }
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

        expect(objectStore['dafuq'].cat).to.be.undefined
    Severity: Minor
    Found in test/vuex-asyncstorage.spec.ts by tslint

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    " should be '
    Open

    const getSavedStore = () => JSON.parse(mockStorage.getItem('vuex') || "")

    Rule: quotemark

    Enforces quote character for string literals.

    Notes
    • Has Fix

    Config

    Five arguments may be optionally provided:

    • "single" enforces single quotes.
    • "double" enforces double quotes.
    • "backtick" enforces backticks.
    • "jsx-single" enforces single quotes for JSX attributes.
    • "jsx-double" enforces double quotes for JSX attributes.
    • "avoid-template" forbids single-line untagged template strings that do not contain string interpolations. Note that backticks may still be used if "avoid-escape" is enabled and both single and double quotes are present in the string (the latter option takes precedence).
    • "avoid-escape" allows you to use the "other" quotemark in cases where escaping would normally be required. For example, [true, "double", "avoid-escape"] would not report a failure on the string literal 'Hello "World"'.
    Examples
    "quotemark": true,single,avoid-escape,avoid-template
    "quotemark": true,single,jsx-double
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "single",
          "double",
          "backtick",
          "jsx-single",
          "jsx-double",
          "avoid-escape",
          "avoid-template"
        ]
      },
      "minLength": 0,
      "maxLength": 5
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

        expect(getSavedStore().cat).to.be.undefined

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    block is empty
    Open

      key() { },
    Severity: Minor
    Found in test/vuex-asyncstorage.spec.ts by tslint

    Rule: no-empty

    Disallows empty blocks.

    Blocks with a comment inside are not considered empty.

    Rationale

    Empty blocks are often indicators of missing code.

    Config

    If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

    Examples
    "no-empty": true
    "no-empty": true,allow-empty-catch
    "no-empty": true,allow-empty-functions
    "no-empty": true,allow-empty-catch,allow-empty-functions
    Schema
    {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "allow-empty-catch"
            ]
          },
          {
            "type": "string",
            "enum": [
              "allow-empty-functions"
            ]
          }
        ]
      }
    }

    For more information see this page.

    " should be '
    Open

    const getSavedStore = () => JSON.parse(mockStorage.getItem('vuex') || "")

    Rule: quotemark

    Enforces quote character for string literals.

    Notes
    • Has Fix

    Config

    Five arguments may be optionally provided:

    • "single" enforces single quotes.
    • "double" enforces double quotes.
    • "backtick" enforces backticks.
    • "jsx-single" enforces single quotes for JSX attributes.
    • "jsx-double" enforces double quotes for JSX attributes.
    • "avoid-template" forbids single-line untagged template strings that do not contain string interpolations. Note that backticks may still be used if "avoid-escape" is enabled and both single and double quotes are present in the string (the latter option takes precedence).
    • "avoid-escape" allows you to use the "other" quotemark in cases where escaping would normally be required. For example, [true, "double", "avoid-escape"] would not report a failure on the string literal 'Hello "World"'.
    Examples
    "quotemark": true,single,avoid-escape,avoid-template
    "quotemark": true,single,jsx-double
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "single",
          "double",
          "backtick",
          "jsx-single",
          "jsx-double",
          "avoid-escape",
          "avoid-template"
        ]
      },
      "minLength": 0,
      "maxLength": 5
    }

    For more information see this page.

    Array type using 'Array<t>' is forbidden. Use 'T[]' instead.</t>
    Open

      private readonly _queue: Array<Promise<void>> = []
    Severity: Minor
    Found in src/SimplePromiseQueue.ts by tslint

    Rule: array-type

    Requires using either 'T[]' or 'Array<t>' for arrays.</t>

    Notes
    • TypeScript Only
    • Has Fix

    Config

    One of the following arguments must be provided:

    • "array" enforces use of T[] for all types T.
    • "generic" enforces use of Array<T> for all types T.
    • "array-simple" enforces use of T[] if T is a simple type (primitive or type reference).
    Examples
    "array-type": true,array
    "array-type": true,generic
    "array-type": true,array-simple
    Schema
    {
      "type": "string",
      "enum": [
        "array",
        "generic",
        "array-simple"
      ]
    }

    For more information see this page.

    block is empty
    Open

      length() { },
    Severity: Minor
    Found in test/vuex-asyncstorage.spec.ts by tslint

    Rule: no-empty

    Disallows empty blocks.

    Blocks with a comment inside are not considered empty.

    Rationale

    Empty blocks are often indicators of missing code.

    Config

    If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

    Examples
    "no-empty": true
    "no-empty": true,allow-empty-catch
    "no-empty": true,allow-empty-functions
    "no-empty": true,allow-empty-catch,allow-empty-functions
    Schema
    {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "allow-empty-catch"
            ]
          },
          {
            "type": "string",
            "enum": [
              "allow-empty-functions"
            ]
          }
        ]
      }
    }

    For more information see this page.

    Shadowed name: 'options'
    Open

        arrayMerge: (destinationArray, sourceArray, options) => sourceArray
    Severity: Minor
    Found in src/utils.ts by tslint

    Rule: no-shadowed-variable

    Disallows shadowing variable declarations.

    Rationale

    When a variable in a local scope and a variable in the containing scope have the same name, shadowing occurs. Shadowing makes it impossible to access the variable in the containing scope and obscures to what value an identifier actually refers. Compare the following snippets:

    const a = 'no shadow';
    function print() {
        console.log(a);
    }
    print(); // logs 'no shadow'.
    const a = 'no shadow';
    function print() {
        const a = 'shadow'; // TSLint will complain here.
        console.log(a);
    }
    print(); // logs 'shadow'.

    ESLint has an equivalent rule. For more background information, refer to this MDN closure doc.

    Config

    You can optionally pass an object to disable checking for certain kinds of declarations. Possible keys are "class", "enum", "function", "import", "interface", "namespace", "typeAlias" and "typeParameter". You can also pass "underscore" to ignore variable names that begin with _. Just set the value to false for the check you want to disable. All checks default to true, i.e. are enabled by default. Note that you cannot disable variables and parameters.

    The option "temporalDeadZone" defaults to true which shows errors when shadowing block scoped declarations in their temporal dead zone. When set to false parameters, classes, enums and variables declared with let or const are not considered shadowed if the shadowing occurs within their temporal dead zone.

    The following example shows how the "temporalDeadZone" option changes the linting result:

    function fn(value) {
        if (value) {
            const tmp = value; // no error on this line if "temporalDeadZone" is false
            return tmp;
        }
        let tmp = undefined;
        if (!value) {
            const tmp = value; // this line always contains an error
            return tmp;
        }
    }
    Examples
    "no-shadowed-variable": true
    "no-shadowed-variable": true,[object Object]
    Schema
    {
      "type": "object",
      "properties": {
        "class": {
          "type": "boolean"
        },
        "enum": {
          "type": "boolean"
        },
        "function": {
          "type": "boolean"
        },
        "import": {
          "type": "boolean"
        },
        "interface": {
          "type": "boolean"
        },
        "namespace": {
          "type": "boolean"
        },
        "typeAlias": {
          "type": "boolean"
        },
        "typeParameter": {
          "type": "boolean"
        },
        "temporalDeadZone": {
          "type": "boolean"
        },
        "underscore": {
          "type": "boolean"
        }
      }
    }

    For more information see this page.

    Severity
    Category
    Status
    Source
    Language