Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit f5a24c5

Browse files
no-identical-functions: fix quality flaws (#254)
1 parent 2fb7649 commit f5a24c5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/rules/no-identical-functions.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import docsUrl from '../utils/docs-url';
2828
const message = (line: string) =>
2929
`Update this function so that its implementation is not identical to the one on line ${line}.`;
3030

31-
type Function =
31+
type FunctionNode =
3232
| TSESTree.FunctionDeclaration
3333
| TSESTree.FunctionExpression
3434
| TSESTree.ArrowFunctionExpression;
@@ -49,7 +49,7 @@ const rule: Rule.RuleModule = {
4949
],
5050
},
5151
create(context: Rule.RuleContext) {
52-
const functions: Array<{ function: Function; parent: TSESTree.Node | undefined }> = [];
52+
const functions: Array<{ function: FunctionNode; parent: TSESTree.Node | undefined }> = [];
5353

5454
return {
5555
FunctionDeclaration(node: TSESTree.Node) {
@@ -67,17 +67,13 @@ const rule: Rule.RuleModule = {
6767
},
6868
};
6969

70-
function visitFunction(node: Function) {
70+
function visitFunction(node: FunctionNode) {
7171
if (isBigEnough(node.body)) {
7272
functions.push({ function: node, parent: node.parent });
7373
}
7474
}
7575

7676
function processFunctions() {
77-
if (functions.length < 2) {
78-
return;
79-
}
80-
8177
for (let i = 1; i < functions.length; i++) {
8278
const duplicatingFunction = functions[i].function;
8379

0 commit comments

Comments
 (0)