andreujuanc/CherryDb

View on GitHub
client/src/data/stores/IndexDbStore.ts

Summary

Maintainability
A
0 mins
Test Coverage

Forbidden 'var' keyword, use 'let' or 'const' instead
Open

            var myIndex = store.index('id');

Rule: no-var-keyword

Disallows usage of the var keyword.

Use let or const instead.

Rationale

Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-var-keyword": true

For more information see this page.

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

            let request = store.getKey(id);

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.

comment must start with a space
Open

            //this.db.createObjectStore(this._dbName)

Rule: comment-format

Enforces formatting rules for single-line comments.

Rationale

Helps maintain a consistent, readable style in your codebase.

Notes
  • Has Fix

Config

Four arguments may be optionally provided:

  • "check-space" requires that all single-line comments must begin with a space, as in // comment
    • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
    • TypeScript reference comments are ignored completely
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
    • requires "check-uppercase"
    • comments must start at the same position

Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

One of two options can be provided in this object:

  • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
  • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "check-space",
          "check-lowercase",
          "check-uppercase",
          "allow-trailing-lowercase"
        ]
      },
      {
        "type": "object",
        "properties": {
          "ignore-words": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ignore-pattern": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "maxProperties": 1
      }
    ]
  },
  "minLength": 1,
  "maxLength": 5
}

For more information see this page.

comment must start with a space
Open

        //TODO: parallel?

Rule: comment-format

Enforces formatting rules for single-line comments.

Rationale

Helps maintain a consistent, readable style in your codebase.

Notes
  • Has Fix

Config

Four arguments may be optionally provided:

  • "check-space" requires that all single-line comments must begin with a space, as in // comment
    • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
    • TypeScript reference comments are ignored completely
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
    • requires "check-uppercase"
    • comments must start at the same position

Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

One of two options can be provided in this object:

  • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
  • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "check-space",
          "check-lowercase",
          "check-uppercase",
          "allow-trailing-lowercase"
        ]
      },
      {
        "type": "object",
        "properties": {
          "ignore-words": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ignore-pattern": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "maxProperties": 1
      }
    ]
  },
  "minLength": 1,
  "maxLength": 5
}

For more information see this page.

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

                let objectStore = db.createObjectStore(this._objectStoreName, { keyPath: "id" });

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.

Unnecessary semicolon
Open

        if (!Array.isArray(records)) { records = [records] };

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

comment must start with a space
Open

                //this._push.push(record);

Rule: comment-format

Enforces formatting rules for single-line comments.

Rationale

Helps maintain a consistent, readable style in your codebase.

Notes
  • Has Fix

Config

Four arguments may be optionally provided:

  • "check-space" requires that all single-line comments must begin with a space, as in // comment
    • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
    • TypeScript reference comments are ignored completely
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
    • requires "check-uppercase"
    • comments must start at the same position

Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

One of two options can be provided in this object:

  • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
  • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "check-space",
          "check-lowercase",
          "check-uppercase",
          "allow-trailing-lowercase"
        ]
      },
      {
        "type": "object",
        "properties": {
          "ignore-words": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ignore-pattern": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "maxProperties": 1
      }
    ]
  },
  "minLength": 1,
  "maxLength": 5
}

For more information see this page.

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

            let request = indexedDB.open(this._dbName, 1);

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.

Shadowed name: 'resolve'
Open

        return new Promise<IRecord[]>((resolve, reject) => {

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.

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

            let store = this.db.transaction([this._objectStoreName])

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.

Shadowed name: 'resolve'
Open

        return new Promise<IRecord>((resolve, reject) => {

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.

Forbidden 'var' keyword, use 'let' or 'const' instead
Open

            var request = store

Rule: no-var-keyword

Disallows usage of the var keyword.

Use let or const instead.

Rationale

Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-var-keyword": true

For more information see this page.

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

            let store = this.db.transaction([this._objectStoreName])

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.

Missing semicolon
Open

            let storedRecord = await this.GetRecordById(record.id)

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

comment must start with a space
Open

//import localforage from "localforage";

Rule: comment-format

Enforces formatting rules for single-line comments.

Rationale

Helps maintain a consistent, readable style in your codebase.

Notes
  • Has Fix

Config

Four arguments may be optionally provided:

  • "check-space" requires that all single-line comments must begin with a space, as in // comment
    • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
    • TypeScript reference comments are ignored completely
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
    • requires "check-uppercase"
    • comments must start at the same position

Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

One of two options can be provided in this object:

  • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
  • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "check-space",
          "check-lowercase",
          "check-uppercase",
          "allow-trailing-lowercase"
        ]
      },
      {
        "type": "object",
        "properties": {
          "ignore-words": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ignore-pattern": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "maxProperties": 1
      }
    ]
  },
  "minLength": 1,
  "maxLength": 5
}

For more information see this page.

non-arrow functions are forbidden
Open

            getAllKeysRequest.onsuccess = 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.

" should be '
Open

import StoreBase from "./StoreBase";

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.

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

            let storedRecord = await this.GetRecordById(record.id)

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.

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

            let store = this.db.transaction([this._objectStoreName], 'readwrite')

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.

missing whitespace
Open

            request.onsuccess = (event) => { resolve((typeof request.result ==='string' ? JSON.parse(request.result as string)  : request.result) as IRecord) };

Rule: whitespace

Enforces whitespace style conventions.

Rationale

Helps maintain a readable, consistent style in your codebase.

Notes
  • Has Fix

Config

Several arguments may be optionally provided:

  • "check-branch" checks branching statements (if/else/for/while) are followed by whitespace.
  • "check-decl"checks that variable declarations have whitespace around the equals token.
  • "check-operator" checks for whitespace around operator tokens.
  • "check-module" checks for whitespace in import & export statements.
  • "check-separator" checks for whitespace after separator tokens (,/;).
  • "check-rest-spread" checks that there is no whitespace after rest/spread operator (...).
  • "check-type" checks for whitespace before a variable type specification.
  • "check-typecast" checks for whitespace between a typecast and its target.
  • "check-type-operator" checks for whitespace between type operators | and &.
  • "check-preblock" checks for whitespace before the opening brace of a block.
  • "check-postbrace" checks for whitespace after an opening brace.
Examples
"whitespace": true,check-branch,check-operator,check-typecast
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "check-branch",
      "check-decl",
      "check-operator",
      "check-module",
      "check-separator",
      "check-rest-spread",
      "check-type",
      "check-typecast",
      "check-type-operator",
      "check-preblock",
      "check-postbrace"
    ]
  },
  "minLength": 0,
  "maxLength": 11
}

For more information see this page.

missing whitespace
Open

        const isArray = Array.isArray(records);//DAMN TS COMPILER.

Rule: whitespace

Enforces whitespace style conventions.

Rationale

Helps maintain a readable, consistent style in your codebase.

Notes
  • Has Fix

Config

Several arguments may be optionally provided:

  • "check-branch" checks branching statements (if/else/for/while) are followed by whitespace.
  • "check-decl"checks that variable declarations have whitespace around the equals token.
  • "check-operator" checks for whitespace around operator tokens.
  • "check-module" checks for whitespace in import & export statements.
  • "check-separator" checks for whitespace after separator tokens (,/;).
  • "check-rest-spread" checks that there is no whitespace after rest/spread operator (...).
  • "check-type" checks for whitespace before a variable type specification.
  • "check-typecast" checks for whitespace between a typecast and its target.
  • "check-type-operator" checks for whitespace between type operators | and &.
  • "check-preblock" checks for whitespace before the opening brace of a block.
  • "check-postbrace" checks for whitespace after an opening brace.
Examples
"whitespace": true,check-branch,check-operator,check-typecast
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "check-branch",
      "check-decl",
      "check-operator",
      "check-module",
      "check-separator",
      "check-rest-spread",
      "check-type",
      "check-typecast",
      "check-type-operator",
      "check-preblock",
      "check-postbrace"
    ]
  },
  "minLength": 0,
  "maxLength": 11
}

For more information see this page.

file should end with a newline
Open

}

Rule: eofline

Ensures the file ends with a newline.

Fix for single-line files is not supported.

Rationale

It is a standard convention to end files with a newline.

Notes
  • Has Fix

Config

Not configurable.

Examples
"eofline": true

For more information see this page.

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

                let db: IDBDatabase = event.target.result;

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.

" should be '
Open

import IStore from "../IStore";

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

import IRecord from "../IRecord";

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

        throw new Error("Method not implemented.");

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.

Missing semicolon
Open

            request.onsuccess = (event) => { resolve((typeof request.result ==='string' ? JSON.parse(request.result as string)  : request.result) as IRecord) };

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

Shadowed name: 'resolve'
Open

        return new Promise<IRecord>(async (resolve, reject) => {

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.

Missing semicolon
Open

                resolve(event)

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

comment must start with a space
Open

        if (records == null) return null; //TODO: throw?

Rule: comment-format

Enforces formatting rules for single-line comments.

Rationale

Helps maintain a consistent, readable style in your codebase.

Notes
  • Has Fix

Config

Four arguments may be optionally provided:

  • "check-space" requires that all single-line comments must begin with a space, as in // comment
    • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
    • TypeScript reference comments are ignored completely
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
    • requires "check-uppercase"
    • comments must start at the same position

Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

One of two options can be provided in this object:

  • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
  • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "check-space",
          "check-lowercase",
          "check-uppercase",
          "allow-trailing-lowercase"
        ]
      },
      {
        "type": "object",
        "properties": {
          "ignore-words": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ignore-pattern": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "maxProperties": 1
      }
    ]
  },
  "minLength": 1,
  "maxLength": 5
}

For more information see this page.

Missing semicolon
Open

        if (!Array.isArray(records)) { records = [records] };

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

comment must start with a space
Open

        const isArray = Array.isArray(records);//DAMN TS COMPILER.

Rule: comment-format

Enforces formatting rules for single-line comments.

Rationale

Helps maintain a consistent, readable style in your codebase.

Notes
  • Has Fix

Config

Four arguments may be optionally provided:

  • "check-space" requires that all single-line comments must begin with a space, as in // comment
    • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
    • TypeScript reference comments are ignored completely
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
    • requires "check-uppercase"
    • comments must start at the same position

Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

One of two options can be provided in this object:

  • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
  • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "check-space",
          "check-lowercase",
          "check-uppercase",
          "allow-trailing-lowercase"
        ]
      },
      {
        "type": "object",
        "properties": {
          "ignore-words": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ignore-pattern": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "maxProperties": 1
      }
    ]
  },
  "minLength": 1,
  "maxLength": 5
}

For more information see this page.

Identifier 'request' is never reassigned; use 'const' instead of 'var'.
Open

            var request = store

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.

comment must start with a space
Open

                //@ts-ignore

Rule: comment-format

Enforces formatting rules for single-line comments.

Rationale

Helps maintain a consistent, readable style in your codebase.

Notes
  • Has Fix

Config

Four arguments may be optionally provided:

  • "check-space" requires that all single-line comments must begin with a space, as in // comment
    • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
    • TypeScript reference comments are ignored completely
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
    • requires "check-uppercase"
    • comments must start at the same position

Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

One of two options can be provided in this object:

  • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
  • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "check-space",
          "check-lowercase",
          "check-uppercase",
          "allow-trailing-lowercase"
        ]
      },
      {
        "type": "object",
        "properties": {
          "ignore-words": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ignore-pattern": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "maxProperties": 1
      }
    ]
  },
  "minLength": 1,
  "maxLength": 5
}

For more information see this page.

Shadowed name: 'resolve'
Open

        return new Promise<any>((resolve, reject) => {

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.

Identifier 'myIndex' is never reassigned; use 'const' instead of 'var'.
Open

            var myIndex = store.index('id');

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.

Identifier 'getAllKeysRequest' is never reassigned; use 'const' instead of 'var'.
Open

            var getAllKeysRequest = myIndex.getAll();

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.

" should be '
Open

                let objectStore = db.createObjectStore(this._objectStoreName, { keyPath: "id" });

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.

Forbidden 'var' keyword, use 'let' or 'const' instead
Open

            var getAllKeysRequest = myIndex.getAll();

Rule: no-var-keyword

Disallows usage of the var keyword.

Use let or const instead.

Rationale

Declaring variables using var has several edge case behaviors that make var unsuitable for modern code. Variables declared by var have their parent function block as their scope, ignoring other control flow statements. vars have declaration "hoisting" (similar to functions) and can appear to be used before declaration.

Variables declared by const and let instead have as their scope the block in which they are defined, and are not allowed to used before declaration or be re-declared with another const or let.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-var-keyword": true

For more information see this page.

Missing semicolon
Open

            }

Rule: semicolon

Enforces consistent semicolon usage at the end of every statement.

Notes
  • Has Fix

Config

One of the following arguments must be provided:

  • "always" enforces semicolons at the end of every statement.
  • "never" disallows semicolons at the end of every statement except for when they are necessary.

The following arguments may be optionally provided:

  • "ignore-interfaces" skips checking semicolons at the end of interface members.
  • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
  • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
Examples
"semicolon": true,always
"semicolon": true,never
"semicolon": true,always,ignore-interfaces
"semicolon": true,always,ignore-bound-class-methods
Schema
{
  "type": "array",
  "items": [
    {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "string",
      "enum": [
        "ignore-interfaces"
      ]
    }
  ],
  "additionalItems": false
}

For more information see this page.

There are no issues that match your filters.

Category
Status