From c9f18aae0fca88ec7c440e60b6153333a64d14bb Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 9 Apr 2025 15:39:12 +0800 Subject: [PATCH] chore: find code with high complexity (#17679) --- web/.vscode/extensions.json | 5 +++-- web/eslint.config.mjs | 3 +-- web/package.json | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/web/.vscode/extensions.json b/web/.vscode/extensions.json index d7680d74a5..a9afbcc640 100644 --- a/web/.vscode/extensions.json +++ b/web/.vscode/extensions.json @@ -1,6 +1,7 @@ { "recommendations": [ "bradlc.vscode-tailwindcss", - "firsttris.vscode-jest-runner" + "firsttris.vscode-jest-runner", + "kisstkondoros.vscode-codemetrics" ] -} +} \ No newline at end of file diff --git a/web/eslint.config.mjs b/web/eslint.config.mjs index 204efc4715..750cee5545 100644 --- a/web/eslint.config.mjs +++ b/web/eslint.config.mjs @@ -65,8 +65,6 @@ export default combine( // use `ESLINT_CONFIG_INSPECTOR=true pnpx @eslint/config-inspector` to check the config // ...process.env.ESLINT_CONFIG_INSPECTOR // ? [] - // TODO: remove this when upgrade to nextjs 15 - // : fixupConfigRules(compat.extends('next')), { rules: { // performance issue, and not used. @@ -87,6 +85,7 @@ export default combine( { // orignal config rules: { + 'complexity': ['warn', { max: 10 }], // orignal ts/no-var-requires 'ts/no-require-imports': 'off', 'no-console': 'off', diff --git a/web/package.json b/web/package.json index 74eead4eba..f439c03767 100644 --- a/web/package.json +++ b/web/package.json @@ -13,6 +13,7 @@ "fix": "next lint --fix", "eslint-fix": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix", "eslint-fix-only-show-error": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix --quiet", + "eslint-complexity": "eslint --rule 'complexity: [error, {max: 15}]' --quiet", "prepare": "cd ../ && node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky ./web/.husky", "gen-icons": "node ./app/components/base/icons/script.mjs", "uglify-embed": "node ./bin/uglify-embed",