Skip to content

Commit 50dd335

Browse files
authored
chore: turn off eslint complexity rule (#445)
1 parent e8453d4 commit 50dd335

File tree

5 files changed

+46
-57
lines changed

5 files changed

+46
-57
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = {
2121
"no-shadow": "off",
2222
"no-warning-comments": "warn",
2323
"require-jsdoc": "off",
24+
complexity: "off",
2425
"prettier/prettier": [
2526
"error",
2627
{},

src/parser/converts/element.ts

-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ import type { ScriptLetBlockParam } from "../../context/script-let";
5252
import { ParseError } from "../..";
5353
import { convertRenderTag } from "./render";
5454

55-
/* eslint-disable complexity -- X */
5655
/** Convert for Fragment or Element or ... */
5756
export function* convertChildren(
58-
/* eslint-enable complexity -- X */
5957
fragment: { children?: SvAST.TemplateNode[] },
6058
parent:
6159
| SvelteProgram

src/parser/typescript/analyze/index.ts

+44-47
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ function transformForDeclareReactiveVar(
647647
ctx.appendOriginal(statement.range[1]);
648648
ctx.appendVirtualScript(`}`);
649649

650-
// eslint-disable-next-line complexity -- ignore X(
651650
ctx.restoreContext.addRestoreStatementProcess((node, result) => {
652651
if ((node as any).type !== "SvelteReactiveStatement") {
653652
return false;
@@ -818,55 +817,53 @@ function transformForDollarDerived(
818817

819818
ctx.restoreContext.addRestoreExpressionProcess<TSESTree.CallExpression>({
820819
target: "CallExpression" as TSESTree.AST_NODE_TYPES.CallExpression,
821-
restore:
822-
// eslint-disable-next-line complexity -- ignore
823-
(node, result) => {
824-
if (
825-
node.callee.type !== "Identifier" ||
826-
node.callee.name !== "$derived"
827-
) {
828-
return false;
829-
}
830-
const arg = node.arguments[0];
831-
if (
832-
!arg ||
833-
arg.type !== "CallExpression" ||
834-
arg.arguments.length !== 0 ||
835-
arg.callee.type !== "ArrowFunctionExpression" ||
836-
arg.callee.body.type !== "BlockStatement" ||
837-
arg.callee.body.body.length !== 2 ||
838-
arg.callee.body.body[0].type !== "ReturnStatement" ||
839-
arg.callee.body.body[0].argument?.type !== "CallExpression" ||
840-
arg.callee.body.body[0].argument.callee.type !== "Identifier" ||
841-
arg.callee.body.body[0].argument.callee.name !== functionId ||
842-
arg.callee.body.body[1].type !== "FunctionDeclaration" ||
843-
arg.callee.body.body[1].id.name !== functionId
844-
) {
845-
return false;
846-
}
847-
const fnNode = arg.callee.body.body[1];
848-
if (
849-
fnNode.body.body.length !== 1 ||
850-
fnNode.body.body[0].type !== "ReturnStatement" ||
851-
!fnNode.body.body[0].argument
852-
) {
853-
return false;
854-
}
820+
restore: (node, result) => {
821+
if (
822+
node.callee.type !== "Identifier" ||
823+
node.callee.name !== "$derived"
824+
) {
825+
return false;
826+
}
827+
const arg = node.arguments[0];
828+
if (
829+
!arg ||
830+
arg.type !== "CallExpression" ||
831+
arg.arguments.length !== 0 ||
832+
arg.callee.type !== "ArrowFunctionExpression" ||
833+
arg.callee.body.type !== "BlockStatement" ||
834+
arg.callee.body.body.length !== 2 ||
835+
arg.callee.body.body[0].type !== "ReturnStatement" ||
836+
arg.callee.body.body[0].argument?.type !== "CallExpression" ||
837+
arg.callee.body.body[0].argument.callee.type !== "Identifier" ||
838+
arg.callee.body.body[0].argument.callee.name !== functionId ||
839+
arg.callee.body.body[1].type !== "FunctionDeclaration" ||
840+
arg.callee.body.body[1].id.name !== functionId
841+
) {
842+
return false;
843+
}
844+
const fnNode = arg.callee.body.body[1];
845+
if (
846+
fnNode.body.body.length !== 1 ||
847+
fnNode.body.body[0].type !== "ReturnStatement" ||
848+
!fnNode.body.body[0].argument
849+
) {
850+
return false;
851+
}
855852

856-
const expr = fnNode.body.body[0].argument;
853+
const expr = fnNode.body.body[0].argument;
857854

858-
node.arguments[0] = expr;
859-
expr.parent = node;
855+
node.arguments[0] = expr;
856+
expr.parent = node;
860857

861-
const scopeManager = result.scopeManager as ScopeManager;
862-
removeFunctionScope(arg.callee.body.body[1], scopeManager);
863-
removeIdentifierReference(
864-
arg.callee.body.body[0].argument.callee,
865-
scopeManager.acquire(arg.callee)!,
866-
);
867-
removeFunctionScope(arg.callee, scopeManager);
868-
return true;
869-
},
858+
const scopeManager = result.scopeManager as ScopeManager;
859+
removeFunctionScope(arg.callee.body.body[1], scopeManager);
860+
removeIdentifierReference(
861+
arg.callee.body.body[0].argument.callee,
862+
scopeManager.acquire(arg.callee)!,
863+
);
864+
removeFunctionScope(arg.callee, scopeManager);
865+
return true;
866+
},
870867
});
871868
}
872869

src/scope/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ export function getProgramScope(scopeManager: ScopeManager): Scope {
9090
);
9191
}
9292

93-
/* eslint-disable complexity -- ignore X( */
9493
/** Remove variable */
9594
export function removeIdentifierVariable(
96-
/* eslint-enable complexity -- ignore X( */
9795
node:
9896
| ESTree.Pattern
9997
| TSESTree.BindingName

tests/src/parser/test-utils.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,10 @@ export function normalizeError(error: any): any {
513513
};
514514
}
515515

516-
/* eslint-disable complexity -- ignore */
517516
/**
518517
* Remove `parent` properties from the given AST.
519518
*/
520-
function nodeReplacer(
521-
/* eslint-enable complexity -- ignore */
522-
key: string,
523-
value: any,
524-
): any {
519+
function nodeReplacer(key: string, value: any): any {
525520
if (key === "parent") {
526521
return undefined;
527522
}

0 commit comments

Comments
 (0)