lib/components/Visibility.ts
Function watchVisibility
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
watchVisibility() {
if (!this.document) return;
// hidden プロパティおよび可視性の変更イベントの名前を設定
// tslint:disable-next-line strict-type-predicates
if (typeof this.document.hidden !== "undefined") { // Opera 12.10 や Firefox 18 以降でサポート
- Read upRead up
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
File name must be camelCase Open
Open
import { EventEmitter } from "events";
- Read upRead up
- Exclude checks
Rule: file-name-casing
Enforces a consistent file naming convention
Rationale
Helps maintain a consistent style across a file hierarchy
Config
One of the following arguments must be provided:
-
camel-case
: File names must be camel-cased:fileName.ts
. -
pascal-case
: File names must be Pascal-cased:FileName.ts
. -
kebab-case
: File names must be kebab-cased:file-name.ts
. -
snake-case
: File names must be snake-cased:file_name.ts
. -
ignore
: File names are ignored (useful for the object configuration).
Or an object, where the key represents a regular expression that matches the file name, and the value is the file name rule from the previous list.
- { ".tsx": "pascal-case", ".ts": "camel-case" }
Examples
"file-name-casing": true,camel-case
"file-name-casing": true,pascal-case
"file-name-casing": true,kebab-case
"file-name-casing": true,snake-case
"file-name-casing": true,[object Object]
"file-name-casing": true,[object Object]
"file-name-casing": true,[object Object]
Schema
{
"type": "array",
"items": {
"anyOf": [
{
"type": "array",
"items": [
{
"type": "string",
"enum": [
"camel-case",
"ignore",
"pascal-case",
"kebab-case",
"snake-case"
]
}
]
},
{
"type": "object",
"additionalProperties": {
"type": "string",
"enum": [
"camel-case",
"ignore",
"pascal-case",
"kebab-case",
"snake-case"
]
},
"minProperties": 1
}
]
}
}
For more information see this page.