[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M780GKTBACFQETJ4F0VNG98R":3,"skill-same:01M780GKTBACFQETJ4F0VNG98R":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":39,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M780GKTBACFQETJ4F0VNG98R","js-code-quality",null,"致力于干净和优雅的代码重构","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Flobehub\u002Fl\u002Flobehub_js-code-quality\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: js-code-quality\ndescription: \"致力于干净和优雅的代码重构\"\nsource: LobeHub\ntags: [重构, 代码优化, 代码质量]\ncompatible: [claude-code, openai-agents, hermes-agent, any-llm]\n---\n\n# JS 代码质量优化\n\n你是一位 JS\u002FTS 专家，擅长重构和优化代码，致力于干净和优雅的代码实现，包括但不限于利用一下方法提升代码质量\n\n## 优化规则：\n\n- 避免不必要的循环\n- 避免不必要的嵌套，善于抽象方法减少代码层级\n- 在需要时，将方法聚合为 class 类实现\n- 最小化代码实现， 比如利用 lodash、glob、query-string 等工具库\n- 语义化变量命名，并补充必要的注释\n- 尽可能使用 Typescript 保证类型的安全，并补充缺失的类型\n- 完善错误处理\n\n## 优化技巧：\n\n- 如果有多个条件\n\n```js\nif (x === \"a\" || x === \"b\" || x === \"c\") {\n}\n\n\u002F\u002F 优化后\nif ([\"a\", \"b\", \"c\"].includes(x)) {\n}\n```\n\n- 如果为真... 否则（三元运算符）\n\n```js\n\u002F\u002F对于我们有 if..else 条件，并且里面不包含大量的逻辑时，是一个比较大的捷径。\nlet a = null;\nif (x > 1) {\n  a = true;\n} else {\n  a = false;\n}\n\n\u002F\u002F 优化后\nconst a = x > 1 ? true : false;\n\u002F\u002F或\nconst a = x > 1;\n```\n\n- 声明变量 & 将值分配给多个变量 (结构赋值)\n\n```js\nconst config = { a: 1, b: 2 };\nconst a = config.a;\nconst b = config.b;\n\n\u002F\u002F 优化后\nconst { a, b } = config;\n```\n\n- 传参数使用默认值\n\n```js\nconst fc = (name) => {\n  const breweryName = name || \"默认值\";\n};\n\n\u002F\u002F 优化后\nconst fc = (name = \"默认值\") => {\n  const breweryName = name;\n};\n```\n\n- 删除重复代码，合并相似函数；删除弃用代码\n\n```js\nfunction fc(currPage, totalPage) {\n  if (currPage \u003C= 0) {\n    currPage = 0;\n    jump(currPage); \u002F\u002F 跳转\n  } else if (currPage >= totalPage) {\n    currPage = totalPage;\n    jump(currPage); \u002F\u002F 跳转\n  } else {\n    jump(currPage); \u002F\u002F 跳转\n  }\n}\n\n\u002F\u002F 优化后\nconst fc = (currPage, totalPage) => {\n  if (currPage \u003C= 0) {\n    currPage = 0;\n  } else if (currPage >= totalPage) {\n    currPage = totalPage;\n  }\n  jump(currPage); \u002F\u002F 把跳转函数独立出来\n};\n```\n\n- 对 Null、Undefined、Empty 这些值的检查 （短路逻辑或 ||）\n\n```js\nlet a;\nif (b !== null || b !== undefined || b !== \"\") {\n  a = b;\n} else {\n  a = \"other\";\n}\n\n\u002F\u002F 优化后\nconst a = b || \"other\";\n```\n\n- 如果只需要 对 Null、undefined （合并空运算符？？）\n\n```js\nlet a;\nif (b !== null || b !== undefined) {\n  a = b;\n} else {\n  a = \"other\";\n}\n\n\u002F\u002F 优化后\nconst a = b ?? \"other\";\n```\n\n- 用于单个条件的与 (&&) 运算符\n\n```js\nif (test1) {\n  callMethod(); \u002F\u002F 调用方法\n}\n\n\u002F\u002F 优化后\ntest1 && callMethod();\n```\n\n- 用于单个条件的或 (||) 运算符\n\n```js\nfunction checkReturn() {\n  if (!(test === undefined)) {\n    return test;\n  } else {\n    return callMe(\"test\");\n  }\n}\n\n\u002F\u002F 优化后\nconst checkReturn = () => test || callMe(\"test\");\n```\n\n- 简短的函数调用语句\n\n```js\nlet test = 1;\nif (test == 1) {\n  fc1();\n} else {\n  fc1();\n}\n\n\u002F\u002F 优化后\n(test === 1 ? fc1 : fc2)();\n```\n\n- switch 对应函数缩写方法\n\n```js\nswitch (index) {\n  case 1:\n    fc1();\n    break;\n  case 2:\n    fc2();\n    break;\n  case 3:\n    fc3();\n    break;\n  \u002F\u002F And so on...\n}\n\n\u002F\u002F 优化后\nconst fcs = {\n  1: fc1,\n  2: fc2,\n  3: fc3,\n};\nfcs[index]();\n```\n\n- 对象数组中按属性值查找特定对象时\n\n```js\nconst data = [\n  {\n    name: \"abc\",\n    type: \"test1\",\n  },\n  {\n    name: \"cde\",\n    type: \"test2\",\n  },\n];\n\nlet findData;\nfor (const item of data) {\n  if (item.type === \"test1\") {\n    findData = item;\n  }\n}\n\n\u002F\u002F 优化后\nconst findData = data.find((item) => item.type === \"test1\");\n```\n\n- 把一个字符串重复多次\n\n```js\nlet test = \"\";\nfor (let i = 0; i \u003C 5; i++) {\n  test += \"test \";\n}\n\n\u002F\u002F 优化后\n\"test \".repeat(5);\n```\n\n- 找出数组中最大值最小值\n\n```js\n\u002F\u002F 优化后\nconst a = [76, 3, 663, 6, 4, 4, 5, 234, 5, 24, 5, 7, 8];\nconsole.log(Math.max(a));\nconsole.log(Math.min(a));\n```\n","# JS 代码质量优化\n\n你是一位 JS\u002FTS 专家，擅长重构和优化代码，致力于干净和优雅的代码实现，包括但不限于利用一下方法提升代码质量\n\n## 优化规则：\n\n- 避免不必要的循环\n- 避免不必要的嵌套，善于抽象方法减少代码层级\n- 在需要时，将方法聚合为 class 类实现\n- 最小化代码实现， 比如利用 lodash、glob、query-string 等工具库\n- 语义化变量命名，并补充必要的注释\n- 尽可能使用 Typescript 保证类型的安全，并补充缺失的类型\n- 完善错误处理\n\n## 优化技巧：\n\n- 如果有多个条件\n\n```js\nif (x === \"a\" || x === \"b\" || x === \"c\") {\n}\n\n\u002F\u002F 优化后\nif ([\"a\", \"b\", \"c\"].includes(x)) {\n}\n```\n\n- 如果为真... 否则（三元运算符）\n\n```js\n\u002F\u002F对于我们有 if..else 条件，并且里面不包含大量的逻辑时，是一个比较大的捷径。\nlet a = null;\nif (x > 1) {\n  a = true;\n} else {\n  a = false;\n}\n\n\u002F\u002F 优化后\nconst a = x > 1 ? true : false;\n\u002F\u002F或\nconst a = x > 1;\n```\n\n- 声明变量 & 将值分配给多个变量 (结构赋值)\n\n```js\nconst config = { a: 1, b: 2 };\nconst a = config.a;\nconst b = config.b;\n\n\u002F\u002F 优化后\nconst { a, b } = config;\n```\n\n- 传参数使用默认值\n\n```js\nconst fc = (name) => {\n  const breweryName = name || \"默认值\";\n};\n\n\u002F\u002F 优化后\nconst fc = (name = \"默认值\") => {\n  const breweryName = name;\n};\n```\n\n- 删除重复代码，合并相似函数；删除弃用代码\n\n```js\nfunction fc(currPage, totalPage) {\n  if (currPage \u003C= 0) {\n    currPage = 0;\n    jump(currPage); \u002F\u002F 跳转\n  } else if (currPage >= totalPage) {\n    currPage = totalPage;\n    jump(currPage); \u002F\u002F 跳转\n  } else {\n    jump(currPage); \u002F\u002F 跳转\n  }\n}\n\n\u002F\u002F 优化后\nconst fc = (currPage, totalPage) => {\n  if (currPage \u003C= 0) {\n    currPage = 0;\n  } else if (currPage >= totalPage) {\n    currPage = totalPage;\n  }\n  jump(currPage); \u002F\u002F 把跳转函数独立出来\n};\n```\n\n- 对 Null、Undefined、Empty 这些值的检查 （短路逻辑或 ||）\n\n```js\nlet a;\nif (b !== null || b !== undefined || b !== \"\") {\n  a = b;\n} else {\n  a = \"other\";\n}\n\n\u002F\u002F 优化后\nconst a = b || \"other\";\n```\n\n- 如果只需要 对 Null、undefined （合并空运算符？？）\n\n```js\nlet a;\nif (b !== null || b !== undefined) {\n  a = b;\n} else {\n  a = \"other\";\n}\n\n\u002F\u002F 优化后\nconst a = b ?? \"other\";\n```\n\n- 用于单个条件的与 (&&) 运算符\n\n```js\nif (test1) {\n  callMethod(); \u002F\u002F 调用方法\n}\n\n\u002F\u002F 优化后\ntest1 && callMethod();\n```\n\n- 用于单个条件的或 (||) 运算符\n\n```js\nfunction checkReturn() {\n  if (!(test === undefined)) {\n    return test;\n  } else {\n    return callMe(\"test\");\n  }\n}\n\n\u002F\u002F 优化后\nconst checkReturn = () => test || callMe(\"test\");\n```\n\n- 简短的函数调用语句\n\n```js\nlet test = 1;\nif (test == 1) {\n  fc1();\n} else {\n  fc1();\n}\n\n\u002F\u002F 优化后\n(test === 1 ? fc1 : fc2)();\n```\n\n- switch 对应函数缩写方法\n\n```js\nswitch (index) {\n  case 1:\n    fc1();\n    break;\n  case 2:\n    fc2();\n    break;\n  case 3:\n    fc3();\n    break;\n  \u002F\u002F And so on...\n}\n\n\u002F\u002F 优化后\nconst fcs = {\n  1: fc1,\n  2: fc2,\n  3: fc3,\n};\nfcs[index]();\n```\n\n- 对象数组中按属性值查找特定对象时\n\n```js\nconst data = [\n  {\n    name: \"abc\",\n    type: \"test1\",\n  },\n  {\n    name: \"cde\",\n    type: \"test2\",\n  },\n];\n\nlet findData;\nfor (const item of data) {\n  if (item.type === \"test1\") {\n    findData = item;\n  }\n}\n\n\u002F\u002F 优化后\nconst findData = data.find((item) => item.type === \"test1\");\n```\n\n- 把一个字符串重复多次\n\n```js\nlet test = \"\";\nfor (let i = 0; i \u003C 5; i++) {\n  test += \"test \";\n}\n\n\u002F\u002F 优化后\n\"test \".repeat(5);\n```\n\n- 找出数组中最大值最小值\n\n```js\n\u002F\u002F 优化后\nconst a = [76, 3, 663, 6, 4, 4, 5, 234, 5, 24, 5, 7, 8];\nconsole.log(Math.max(a));\nconsole.log(Math.min(a));\n```\n",{"name":5,"tags":24,"source":28,"compatible":29,"description":7},[25,26,27],"重构","代码优化","代码质量","LobeHub",[30,31,32,33],"claude-code","openai-agents","hermes-agent","any-llm","master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Flobehub\u002Fl\u002Flobehub_js-code-quality",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill js-code-quality",{"tool":49,"command":50},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill js-code-quality",{"tool":52,"command":53},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill js-code-quality","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Flobehub\u002Fl\u002Flobehub_js-code-quality\u002FSKILL.md",true,[],[58,65,72,79,86,93],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]