Showing 109 of 111 total issues
Missing radix parameter Open
a = b = Number.parseInt(splits[0]);
- Read upRead up
- Exclude checks
Rule: radix
Requires the radix parameter to be specified when calling parseInt
.
Rationale
From MDN:
Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.
Config
Not configurable.
Examples
"radix": true
For more information see this page.
Missing radix parameter Open
const numberValue = Number.parseInt(label.name);
- Read upRead up
- Exclude checks
Rule: radix
Requires the radix parameter to be specified when calling parseInt
.
Rationale
From MDN:
Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.
Config
Not configurable.
Examples
"radix": true
For more information see this page.
Missing radix parameter Open
.map(x => Number.parseInt(x.trim()));
- Read upRead up
- Exclude checks
Rule: radix
Requires the radix parameter to be specified when calling parseInt
.
Rationale
From MDN:
Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.
Config
Not configurable.
Examples
"radix": true
For more information see this page.
Missing radix parameter Open
a = b = -1 * Number.parseInt(splits[1]);
- Read upRead up
- Exclude checks
Rule: radix
Requires the radix parameter to be specified when calling parseInt
.
Rationale
From MDN:
Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.
Config
Not configurable.
Examples
"radix": true
For more information see this page.
Shadowed name: 'key' Open
criteriaData.labelArray = Array.from(criteriaData.labels).map(([key, value]) => value);
- Read upRead up
- Exclude checks
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.
" should be ' Open
import { ReferencesTableComponent } from "./references-table/references-table.component";
- Read upRead up
- Exclude checks
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.
The selector should be kebab-cased and include a dash (https://angular.io/guide/styleguide#style-05-02) Open
selector: 'pcheckbox',
- Read upRead up
- Exclude checks
Rule: component-selector
Component selectors should follow given naming rules.
See more at https://angular.io/guide/styleguide#style-02-07, https://angular.io/guide/styleguide#style-05-02 and https://angular.io/guide/styleguide#style-05-03.
Rationale
- Consistent conventions make it easy to quickly identify and reference assets of different types.
- Makes it easier to promote and share the component in other apps.
- Components are easy to identify in the DOM.
- Keeps the element names consistent with the specification for Custom Elements.
- Components have templates containing HTML and optional Angular template syntax.
- They display content. Developers place components on the page as they would native HTML elements and WebComponents.
- It is easier to recognize that a symbol is a component by looking at the template's HTML.
Notes
- TypeScript Only
Config
Options accept three obligatory items as an array:
1. element
or attribute
forces components to be used as either elements, attributes, or both (not recommended)
2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.
3. kebab-case
or camelCase
allows you to pick a case.
Examples
"component-selector": true,element,my-prefix,kebab-case
"component-selector": true,element,ng,ngx,kebab-case
"component-selector": true,attribute,myPrefix,camelCase
"component-selector": true,element,attribute,myPrefix,camelCase
Schema
{
"items": [
{
"enum": [
"attribute",
"element"
]
},
{
"oneOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "string"
}
]
},
{
"enum": [
"camelCase",
"kebab-case"
]
}
],
"maxLength": 3,
"minLength": 3,
"type": "array"
}
For more information see this page.
The selector should be kebab-cased and include a dash (https://angular.io/guide/styleguide#style-05-02) Open
selector: 'latextable',
- Read upRead up
- Exclude checks
Rule: component-selector
Component selectors should follow given naming rules.
See more at https://angular.io/guide/styleguide#style-02-07, https://angular.io/guide/styleguide#style-05-02 and https://angular.io/guide/styleguide#style-05-03.
Rationale
- Consistent conventions make it easy to quickly identify and reference assets of different types.
- Makes it easier to promote and share the component in other apps.
- Components are easy to identify in the DOM.
- Keeps the element names consistent with the specification for Custom Elements.
- Components have templates containing HTML and optional Angular template syntax.
- They display content. Developers place components on the page as they would native HTML elements and WebComponents.
- It is easier to recognize that a symbol is a component by looking at the template's HTML.
Notes
- TypeScript Only
Config
Options accept three obligatory items as an array:
1. element
or attribute
forces components to be used as either elements, attributes, or both (not recommended)
2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.
3. kebab-case
or camelCase
allows you to pick a case.
Examples
"component-selector": true,element,my-prefix,kebab-case
"component-selector": true,element,ng,ngx,kebab-case
"component-selector": true,attribute,myPrefix,camelCase
"component-selector": true,element,attribute,myPrefix,camelCase
Schema
{
"items": [
{
"enum": [
"attribute",
"element"
]
},
{
"oneOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "string"
}
]
},
{
"enum": [
"camelCase",
"kebab-case"
]
}
],
"maxLength": 3,
"minLength": 3,
"type": "array"
}
For more information see this page.
Identifier 'citations' is never reassigned; use 'const' instead of 'let'. Open
let citations: Array<Citation> = [];
- Read upRead up
- Exclude checks
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.
Type boolean trivially inferred from a boolean literal, remove type annotation Open
@Input() showTooltip: boolean = true;
- Read upRead up
- Exclude checks
Rule: no-inferrable-types
Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
Rationale
Explicit types where they can be easily inferred by the compiler make code more verbose.
Notes
- TypeScript Only
- Has Fix
Config
Two arguments may be optionally provided:
-
ignore-params
allows specifying an inferrable type annotation for function params. This can be useful when combining with thetypedef
rule. -
ignore-properties
allows specifying an inferrable type annotation for class properties.
Examples
"no-inferrable-types": true
"no-inferrable-types": true,ignore-params
"no-inferrable-types": true,ignore-params,ignore-properties
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"ignore-params",
"ignore-properties"
]
},
"minLength": 0,
"maxLength": 2
}
For more information see this page.
misplaced 'else' Open
else {
- Read upRead up
- Exclude checks
Rule: one-line
Requires the specified tokens to be on the same line as the expression preceding them.
Notes
- Has Fix
Config
Five arguments may be optionally provided:
-
"check-catch"
checks thatcatch
is on the same line as the closing brace fortry
. -
"check-finally"
checks thatfinally
is on the same line as the closing brace forcatch
. -
"check-else"
checks thatelse
is on the same line as the closing brace forif
. -
"check-open-brace"
checks that an open brace falls on the same line as its preceding expression. -
"check-whitespace"
checks preceding whitespace for the specified tokens.
Examples
"one-line": true,check-catch,check-finally,check-else
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"check-catch",
"check-finally",
"check-else",
"check-open-brace",
"check-whitespace"
]
},
"minLength": 0,
"maxLength": 5
}
For more information see this page.
Type boolean trivially inferred from a boolean literal, remove type annotation Open
@Input() latexDisplayTable: boolean = false;
- Read upRead up
- Exclude checks
Rule: no-inferrable-types
Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
Rationale
Explicit types where they can be easily inferred by the compiler make code more verbose.
Notes
- TypeScript Only
- Has Fix
Config
Two arguments may be optionally provided:
-
ignore-params
allows specifying an inferrable type annotation for function params. This can be useful when combining with thetypedef
rule. -
ignore-properties
allows specifying an inferrable type annotation for class properties.
Examples
"no-inferrable-types": true
"no-inferrable-types": true,ignore-params
"no-inferrable-types": true,ignore-params,ignore-properties
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"ignore-params",
"ignore-properties"
]
},
"minLength": 0,
"maxLength": 2
}
For more information see this page.
Identifier 'footnote' is never reassigned; use 'const' instead of 'let'. Open
let footnote: { ref: string, count: number } = this.footnotes.get(this.footnote);
- Read upRead up
- Exclude checks
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.
Type number trivially inferred from a number literal, remove type annotation Open
@Input() changeNum: number = 0;
- Read upRead up
- Exclude checks
Rule: no-inferrable-types
Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
Rationale
Explicit types where they can be easily inferred by the compiler make code more verbose.
Notes
- TypeScript Only
- Has Fix
Config
Two arguments may be optionally provided:
-
ignore-params
allows specifying an inferrable type annotation for function params. This can be useful when combining with thetypedef
rule. -
ignore-properties
allows specifying an inferrable type annotation for class properties.
Examples
"no-inferrable-types": true
"no-inferrable-types": true,ignore-params
"no-inferrable-types": true,ignore-params,ignore-properties
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"ignore-params",
"ignore-properties"
]
},
"minLength": 0,
"maxLength": 2
}
For more information see this page.
" should be ' Open
import { NgModule } from "@angular/core";
- Read upRead up
- Exclude checks
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.
The selector should be kebab-cased and include a dash (https://angular.io/guide/styleguide#style-05-02) Open
selector: 'myapp',
- Read upRead up
- Exclude checks
Rule: component-selector
Component selectors should follow given naming rules.
See more at https://angular.io/guide/styleguide#style-02-07, https://angular.io/guide/styleguide#style-05-02 and https://angular.io/guide/styleguide#style-05-03.
Rationale
- Consistent conventions make it easy to quickly identify and reference assets of different types.
- Makes it easier to promote and share the component in other apps.
- Components are easy to identify in the DOM.
- Keeps the element names consistent with the specification for Custom Elements.
- Components have templates containing HTML and optional Angular template syntax.
- They display content. Developers place components on the page as they would native HTML elements and WebComponents.
- It is easier to recognize that a symbol is a component by looking at the template's HTML.
Notes
- TypeScript Only
Config
Options accept three obligatory items as an array:
1. element
or attribute
forces components to be used as either elements, attributes, or both (not recommended)
2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.
3. kebab-case
or camelCase
allows you to pick a case.
Examples
"component-selector": true,element,my-prefix,kebab-case
"component-selector": true,element,ng,ngx,kebab-case
"component-selector": true,attribute,myPrefix,camelCase
"component-selector": true,element,attribute,myPrefix,camelCase
Schema
{
"items": [
{
"enum": [
"attribute",
"element"
]
},
{
"oneOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "string"
}
]
},
{
"enum": [
"camelCase",
"kebab-case"
]
}
],
"maxLength": 3,
"minLength": 3,
"type": "array"
}
For more information see this page.
comment must start with a space Open
//@Input() ratings: Array<number> = [];
- Read upRead up
- Exclude checks
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
- note that for comments starting with multiple slashes, e.g.
-
"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
- requires
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.
The selector should be prefixed by "uc" (https://angular.io/guide/styleguide#style-02-07) Open
selector: 'comparison-settings',
- Read upRead up
- Exclude checks
Rule: component-selector
Component selectors should follow given naming rules.
See more at https://angular.io/guide/styleguide#style-02-07, https://angular.io/guide/styleguide#style-05-02 and https://angular.io/guide/styleguide#style-05-03.
Rationale
- Consistent conventions make it easy to quickly identify and reference assets of different types.
- Makes it easier to promote and share the component in other apps.
- Components are easy to identify in the DOM.
- Keeps the element names consistent with the specification for Custom Elements.
- Components have templates containing HTML and optional Angular template syntax.
- They display content. Developers place components on the page as they would native HTML elements and WebComponents.
- It is easier to recognize that a symbol is a component by looking at the template's HTML.
Notes
- TypeScript Only
Config
Options accept three obligatory items as an array:
1. element
or attribute
forces components to be used as either elements, attributes, or both (not recommended)
2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.
3. kebab-case
or camelCase
allows you to pick a case.
Examples
"component-selector": true,element,my-prefix,kebab-case
"component-selector": true,element,ng,ngx,kebab-case
"component-selector": true,attribute,myPrefix,camelCase
"component-selector": true,element,attribute,myPrefix,camelCase
Schema
{
"items": [
{
"enum": [
"attribute",
"element"
]
},
{
"oneOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "string"
}
]
},
{
"enum": [
"camelCase",
"kebab-case"
]
}
],
"maxLength": 3,
"minLength": 3,
"type": "array"
}
For more information see this page.
" should be ' Open
import { NumberInputComponent } from "./number-input/number-input.component";
- Read upRead up
- Exclude checks
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.
The selector should be kebab-cased and include a dash (https://angular.io/guide/styleguide#style-05-02) Open
selector: 'select2',
- Read upRead up
- Exclude checks
Rule: component-selector
Component selectors should follow given naming rules.
See more at https://angular.io/guide/styleguide#style-02-07, https://angular.io/guide/styleguide#style-05-02 and https://angular.io/guide/styleguide#style-05-03.
Rationale
- Consistent conventions make it easy to quickly identify and reference assets of different types.
- Makes it easier to promote and share the component in other apps.
- Components are easy to identify in the DOM.
- Keeps the element names consistent with the specification for Custom Elements.
- Components have templates containing HTML and optional Angular template syntax.
- They display content. Developers place components on the page as they would native HTML elements and WebComponents.
- It is easier to recognize that a symbol is a component by looking at the template's HTML.
Notes
- TypeScript Only
Config
Options accept three obligatory items as an array:
1. element
or attribute
forces components to be used as either elements, attributes, or both (not recommended)
2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.
3. kebab-case
or camelCase
allows you to pick a case.
Examples
"component-selector": true,element,my-prefix,kebab-case
"component-selector": true,element,ng,ngx,kebab-case
"component-selector": true,attribute,myPrefix,camelCase
"component-selector": true,element,attribute,myPrefix,camelCase
Schema
{
"items": [
{
"enum": [
"attribute",
"element"
]
},
{
"oneOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "string"
}
]
},
{
"enum": [
"camelCase",
"kebab-case"
]
}
],
"maxLength": 3,
"minLength": 3,
"type": "array"
}
For more information see this page.