Function hidePanel
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
hidePanel(isArrowTowardsLeft) {
this.mentionPanel.classList.remove(`medium-editor-mention-panel-active`);
const extraActivePanelClassName = this.extraActivePanelClassName || this.extraActiveClassName;
if (extraActivePanelClassName) {
- 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 index.js
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
default as MediumEditor,
} from "medium-editor";
function last(text) {
Function hidePanel
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
hidePanel(isArrowTowardsLeft) {
this.mentionPanel.classList.remove(`medium-editor-mention-panel-active`);
const extraActivePanelClassName = this.extraActivePanelClassName || this.extraActiveClassName;
if (extraActivePanelClassName) {
Function wrapWordInMentionAt
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
wrapWordInMentionAt() {
const selection = this.document.getSelection();
if (!selection.rangeCount) {
return;
}
Function getWordFromSelection
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
getWordFromSelection(target, initialDiff) {
const {
startContainer,
startOffset,
endContainer,
Function getWordFromSelection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getWordFromSelection(target, initialDiff) {
const {
startContainer,
startOffset,
endContainer,
- 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
Function wrapWordInMentionAt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
wrapWordInMentionAt() {
const selection = this.document.getSelection();
if (!selection.rangeCount) {
return;
}
- 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
Unexpected if as the only statement in an else block. Open
if (textNode.textContent.length === 0 && firstChild.textContent.length > 1) {
- Read upRead up
- Exclude checks
disallow if
statements as the only statement in else
blocks (no-lonely-if)
If an if
statement is the only statement in the else
block, it is often clearer to use an else if
form.
if (foo) {
// ...
} else {
if (bar) {
// ...
}
}
should be rewritten as
if (foo) {
// ...
} else if (bar) {
// ...
}
Rule Details
This rule disallows if
statements as the only statement in else
blocks.
Examples of incorrect code for this rule:
/*eslint no-lonely-if: "error"*/
if (condition) {
// ...
} else {
if (anotherCondition) {
// ...
}
}
if (condition) {
// ...
} else {
if (anotherCondition) {
// ...
} else {
// ...
}
}
Examples of correct code for this rule:
/*eslint no-lonely-if: "error"*/
if (condition) {
// ...
} else if (anotherCondition) {
// ...
}
if (condition) {
// ...
} else if (anotherCondition) {
// ...
} else {
// ...
}
if (condition) {
// ...
} else {
if (anotherCondition) {
// ...
}
doSomething();
}
When Not To Use It
Disable this rule if the code is clearer without requiring the else if
form.
Source: http://eslint.org/docs/rules/
Use default import syntax to import 'MediumEditor'. Open
default as MediumEditor,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/