@linyjs/plugin-docs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/README.md +97 -0
  2. package/docs/api-reference/index.md +341 -0
  3. package/docs/best-practices/error-handling.md +462 -0
  4. package/docs/best-practices/naming-conventions.md +495 -0
  5. package/docs/best-practices/performance.md +532 -0
  6. package/docs/best-practices/security.md +620 -0
  7. package/docs/faq.md +323 -0
  8. package/docs/getting-started/first-plugin.md +358 -0
  9. package/docs/getting-started/installation.md +244 -0
  10. package/docs/getting-started/quick-start.md +174 -0
  11. package/docs/guides/client-module.md +598 -0
  12. package/docs/guides/data-persistence.md +536 -0
  13. package/docs/guides/permissions.md +440 -0
  14. package/docs/guides/server-module.md +371 -0
  15. package/docs/guides/ui-slots.md +475 -0
  16. package/docs/migration/v0-to-v1.md +354 -0
  17. package/examples/analytics-plugin/README.md +416 -0
  18. package/examples/analytics-plugin/dist/client/index.d.ts +36 -0
  19. package/examples/analytics-plugin/dist/client/index.js +173 -0
  20. package/examples/analytics-plugin/dist/index.d.ts +64 -0
  21. package/examples/analytics-plugin/dist/index.js +72 -0
  22. package/examples/analytics-plugin/dist/server/index.d.ts +119 -0
  23. package/examples/analytics-plugin/dist/server/index.js +313 -0
  24. package/examples/analytics-plugin/package.json +28 -0
  25. package/examples/analytics-plugin/src/client/index.tsx +410 -0
  26. package/examples/analytics-plugin/src/index.ts +71 -0
  27. package/examples/analytics-plugin/src/server/index.ts +348 -0
  28. package/examples/analytics-plugin/tsconfig.json +21 -0
  29. package/examples/blog-plugin/README.md +316 -0
  30. package/examples/blog-plugin/dist/client/index.d.ts +22 -0
  31. package/examples/blog-plugin/dist/client/index.js +197 -0
  32. package/examples/blog-plugin/dist/server/index.d.ts +5 -0
  33. package/examples/blog-plugin/dist/server/index.js +220 -0
  34. package/examples/blog-plugin/package.json +24 -0
  35. package/examples/blog-plugin/src/client/index.tsx +405 -0
  36. package/examples/blog-plugin/src/server/index.ts +240 -0
  37. package/examples/blog-plugin/tsconfig.json +16 -0
  38. package/examples/hello-world/README.md +101 -0
  39. package/examples/hello-world/dist/client/index.d.ts +5 -0
  40. package/examples/hello-world/dist/client/index.js +80 -0
  41. package/examples/hello-world/dist/server/index.d.ts +5 -0
  42. package/examples/hello-world/dist/server/index.js +38 -0
  43. package/examples/hello-world/node_modules/.package-lock.json +61 -0
  44. package/examples/hello-world/node_modules/@linyjs/client-module-interface/HOOKS_USAGE.md +281 -0
  45. package/examples/hello-world/node_modules/@linyjs/client-module-interface/IMPLEMENTATION_SUMMARY.md +166 -0
  46. package/examples/hello-world/node_modules/@linyjs/client-module-interface/QUICK_REFERENCE.md +130 -0
  47. package/examples/hello-world/node_modules/@linyjs/client-module-interface/README.md +214 -0
  48. package/examples/hello-world/node_modules/@linyjs/client-module-interface/package.json +26 -0
  49. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/application.ts +50 -0
  50. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/comparison-example.tsx +229 -0
  51. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/di.ts +127 -0
  52. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/domain.ts +52 -0
  53. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/hooks-example.tsx +275 -0
  54. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/hooks.ts +175 -0
  55. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/index.ts +87 -0
  56. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/interfaces.ts +117 -0
  57. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/router.ts +49 -0
  58. package/examples/hello-world/node_modules/@linyjs/client-module-interface/tsconfig.json +10 -0
  59. package/examples/hello-world/node_modules/@linyjs/server-module-interface/package.json +21 -0
  60. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/application.ts +21 -0
  61. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/di.ts +127 -0
  62. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/domain.ts +75 -0
  63. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/index.ts +55 -0
  64. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/interfaces.ts +58 -0
  65. package/examples/hello-world/node_modules/@linyjs/server-module-interface/tsconfig.json +8 -0
  66. package/examples/hello-world/node_modules/@types/react/LICENSE +21 -0
  67. package/examples/hello-world/node_modules/@types/react/README.md +15 -0
  68. package/examples/hello-world/node_modules/@types/react/canary.d.ts +129 -0
  69. package/examples/hello-world/node_modules/@types/react/compiler-runtime.d.ts +4 -0
  70. package/examples/hello-world/node_modules/@types/react/experimental.d.ts +184 -0
  71. package/examples/hello-world/node_modules/@types/react/global.d.ts +166 -0
  72. package/examples/hello-world/node_modules/@types/react/index.d.ts +4369 -0
  73. package/examples/hello-world/node_modules/@types/react/jsx-dev-runtime.d.ts +33 -0
  74. package/examples/hello-world/node_modules/@types/react/jsx-runtime.d.ts +24 -0
  75. package/examples/hello-world/node_modules/@types/react/package.json +210 -0
  76. package/examples/hello-world/node_modules/@types/react/ts5.0/canary.d.ts +129 -0
  77. package/examples/hello-world/node_modules/@types/react/ts5.0/experimental.d.ts +184 -0
  78. package/examples/hello-world/node_modules/@types/react/ts5.0/global.d.ts +166 -0
  79. package/examples/hello-world/node_modules/@types/react/ts5.0/index.d.ts +4356 -0
  80. package/examples/hello-world/node_modules/@types/react/ts5.0/jsx-dev-runtime.d.ts +33 -0
  81. package/examples/hello-world/node_modules/@types/react/ts5.0/jsx-runtime.d.ts +24 -0
  82. package/examples/hello-world/node_modules/csstype/LICENSE +19 -0
  83. package/examples/hello-world/node_modules/csstype/README.md +291 -0
  84. package/examples/hello-world/node_modules/csstype/index.d.ts +22569 -0
  85. package/examples/hello-world/node_modules/csstype/index.js.flow +6863 -0
  86. package/examples/hello-world/node_modules/csstype/package.json +70 -0
  87. package/examples/hello-world/node_modules/react/LICENSE +21 -0
  88. package/examples/hello-world/node_modules/react/README.md +37 -0
  89. package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.development.js +24 -0
  90. package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.production.js +16 -0
  91. package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.profiling.js +16 -0
  92. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.development.js +338 -0
  93. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.production.js +14 -0
  94. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.profiling.js +14 -0
  95. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.react-server.development.js +370 -0
  96. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.react-server.production.js +40 -0
  97. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.development.js +352 -0
  98. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.production.js +34 -0
  99. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.profiling.js +34 -0
  100. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.react-server.development.js +370 -0
  101. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.react-server.production.js +40 -0
  102. package/examples/hello-world/node_modules/react/cjs/react.development.js +1284 -0
  103. package/examples/hello-world/node_modules/react/cjs/react.production.js +542 -0
  104. package/examples/hello-world/node_modules/react/cjs/react.react-server.development.js +848 -0
  105. package/examples/hello-world/node_modules/react/cjs/react.react-server.production.js +423 -0
  106. package/examples/hello-world/node_modules/react/compiler-runtime.js +14 -0
  107. package/examples/hello-world/node_modules/react/index.js +7 -0
  108. package/examples/hello-world/node_modules/react/jsx-dev-runtime.js +7 -0
  109. package/examples/hello-world/node_modules/react/jsx-dev-runtime.react-server.js +7 -0
  110. package/examples/hello-world/node_modules/react/jsx-runtime.js +7 -0
  111. package/examples/hello-world/node_modules/react/jsx-runtime.react-server.js +7 -0
  112. package/examples/hello-world/node_modules/react/package.json +51 -0
  113. package/examples/hello-world/node_modules/react/react.react-server.js +7 -0
  114. package/examples/hello-world/node_modules/typescript/LICENSE.txt +55 -0
  115. package/examples/hello-world/node_modules/typescript/README.md +50 -0
  116. package/examples/hello-world/node_modules/typescript/SECURITY.md +41 -0
  117. package/examples/hello-world/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  118. package/examples/hello-world/node_modules/typescript/bin/tsc +2 -0
  119. package/examples/hello-world/node_modules/typescript/bin/tsserver +2 -0
  120. package/examples/hello-world/node_modules/typescript/lib/_tsc.js +133818 -0
  121. package/examples/hello-world/node_modules/typescript/lib/_tsserver.js +659 -0
  122. package/examples/hello-world/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  123. package/examples/hello-world/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
  124. package/examples/hello-world/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
  125. package/examples/hello-world/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
  126. package/examples/hello-world/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
  127. package/examples/hello-world/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
  128. package/examples/hello-world/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
  129. package/examples/hello-world/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
  130. package/examples/hello-world/node_modules/typescript/lib/lib.d.ts +22 -0
  131. package/examples/hello-world/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
  132. package/examples/hello-world/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
  133. package/examples/hello-world/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
  134. package/examples/hello-world/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
  135. package/examples/hello-world/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
  136. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
  137. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
  138. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
  139. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
  140. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
  141. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
  142. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
  143. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
  144. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
  145. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  146. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
  147. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
  148. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
  149. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
  150. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
  151. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
  152. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
  153. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
  154. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
  155. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
  156. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
  157. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
  158. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
  159. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  160. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
  161. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
  162. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
  163. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
  164. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
  165. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
  166. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
  167. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
  168. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
  169. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
  170. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
  171. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
  172. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
  173. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
  174. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
  175. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
  176. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
  177. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
  178. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
  179. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
  180. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
  181. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
  182. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  183. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
  184. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
  185. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
  186. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
  187. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
  188. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
  189. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
  190. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
  191. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
  192. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
  193. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
  194. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
  195. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
  196. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
  197. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
  198. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
  199. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
  200. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
  201. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
  202. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
  203. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
  204. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
  205. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
  206. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
  207. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
  208. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
  209. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
  210. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
  211. package/examples/hello-world/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
  212. package/examples/hello-world/node_modules/typescript/lib/lib.es6.d.ts +23 -0
  213. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
  214. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
  215. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
  216. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
  217. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
  218. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
  219. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
  220. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
  221. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
  222. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
  223. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
  224. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
  225. package/examples/hello-world/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
  226. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
  227. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
  228. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
  229. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
  230. package/examples/hello-world/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
  231. package/examples/hello-world/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
  232. package/examples/hello-world/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
  233. package/examples/hello-world/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
  234. package/examples/hello-world/node_modules/typescript/lib/tsc.js +8 -0
  235. package/examples/hello-world/node_modules/typescript/lib/tsserver.js +8 -0
  236. package/examples/hello-world/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  237. package/examples/hello-world/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  238. package/examples/hello-world/node_modules/typescript/lib/typesMap.json +497 -0
  239. package/examples/hello-world/node_modules/typescript/lib/typescript.d.ts +11437 -0
  240. package/examples/hello-world/node_modules/typescript/lib/typescript.js +200276 -0
  241. package/examples/hello-world/node_modules/typescript/lib/typingsInstaller.js +8 -0
  242. package/examples/hello-world/node_modules/typescript/lib/watchGuard.js +53 -0
  243. package/examples/hello-world/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
  244. package/examples/hello-world/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
  245. package/examples/hello-world/node_modules/typescript/package.json +120 -0
  246. package/examples/hello-world/package-lock.json +74 -0
  247. package/examples/hello-world/package.json +23 -0
  248. package/examples/hello-world/src/client/index.tsx +110 -0
  249. package/examples/hello-world/src/server/index.ts +42 -0
  250. package/examples/hello-world/tsconfig.json +16 -0
  251. package/package.json +42 -0
  252. package/src/cli.ts +321 -0
@@ -0,0 +1,495 @@
1
+ # 命名规范
2
+
3
+ 本指南提供 linyjs 插件开发的命名规范和最佳实践。
4
+
5
+ ## 为什么需要命名规范?
6
+
7
+ - 📖 **提高可读性** - 其他开发者能快速理解代码
8
+ - 🔍 **便于搜索** - 统一的命名让查找更容易
9
+ - 🛠️ **减少错误** - 避免命名冲突和混淆
10
+ - 🤝 **团队协作** - 保持代码风格一致
11
+
12
+ ## 插件名称
13
+
14
+ ### 规则
15
+
16
+ - 使用小写字母和连字符(`-`)
17
+ - 以 `-plugin` 或 `-extension` 结尾(可选)
18
+ - 描述性强,体现功能
19
+
20
+ ### 示例
21
+
22
+ ```typescript
23
+ // ✅ 推荐
24
+ name: 'blog-plugin'
25
+ name: 'analytics-extension'
26
+ name: 'payment-gateway'
27
+ name: 'user-management'
28
+
29
+ // ❌ 避免
30
+ name: 'BlogPlugin' // 使用驼峰
31
+ name: 'my_plugin' // 使用下划线
32
+ name: 'plugin1' // 不明确
33
+ name: 'bp' // 缩写不清
34
+ ```
35
+
36
+ ### package.json 中的命名
37
+
38
+ ```json
39
+ {
40
+ "name": "@my-org/blog-plugin",
41
+ "version": "1.0.0"
42
+ }
43
+ ```
44
+
45
+ 使用 scope(`@my-org/`)可以避免命名冲突。
46
+
47
+ ## Service Tag 命名
48
+
49
+ ### 规则
50
+
51
+ - 使用 camelCase(小驼峰)
52
+ - 体现服务类型和功能
53
+ - 保持唯一性
54
+
55
+ ### 示例
56
+
57
+ ```typescript
58
+ // ✅ 推荐 - 控制器
59
+ serviceTag: 'articleController'
60
+ serviceTag: 'userController'
61
+ serviceTag: 'paymentController'
62
+
63
+ // ✅ 推荐 - 中间件
64
+ serviceTag: 'authMiddleware'
65
+ serviceTag: 'loggingMiddleware'
66
+ serviceTag: 'rateLimitMiddleware'
67
+
68
+ // ✅ 推荐 - 服务
69
+ serviceTag: 'articleService'
70
+ serviceTag: 'emailService'
71
+ serviceTag: 'cacheService'
72
+
73
+ // ✅ 推荐 - 定时任务
74
+ serviceTag: 'cleanupCron'
75
+ serviceTag: 'reportCron'
76
+
77
+ // ✅ 推荐 - 路由
78
+ serviceTag: 'blogRoute'
79
+ serviceTag: 'adminRoute'
80
+
81
+ // ✅ 推荐 - 状态
82
+ serviceTag: 'userState'
83
+ serviceTag: 'appState'
84
+
85
+ // ✅ 推荐 - 组件
86
+ serviceTag: 'uiComponents'
87
+ serviceTag: 'formComponents'
88
+
89
+ // ✅ 推荐 - Hooks
90
+ serviceTag: 'dataHooks'
91
+ serviceTag: 'authHooks'
92
+
93
+ // ❌ 避免
94
+ serviceTag: 'ctrl' // 缩写不清
95
+ serviceTag: 's1' // 无意义
96
+ serviceTag: 'myService' // 太通用
97
+ serviceTag: 'Controller' // 缺少具体功能
98
+ ```
99
+
100
+ ## 模块名称
101
+
102
+ ### 规则
103
+
104
+ - 使用 camelCase
105
+ - 区分服务端和客户端
106
+ - 体现模块功能
107
+
108
+ ### 示例
109
+
110
+ ```typescript
111
+ // ✅ 推荐 - 服务端模块
112
+ export const blogServerModule: IModule = {
113
+ name: 'blogServer',
114
+ // ...
115
+ };
116
+
117
+ export const authServerModule: IModule = {
118
+ name: 'authServer',
119
+ // ...
120
+ };
121
+
122
+ // ✅ 推荐 - 客户端模块
123
+ export const blogClientModule: IModule = {
124
+ name: 'blogClient',
125
+ // ...
126
+ };
127
+
128
+ export const adminClientModule: IModule = {
129
+ name: 'adminClient',
130
+ // ...
131
+ };
132
+
133
+ // ❌ 避免
134
+ name: 'server' // 太通用
135
+ name: 'module1' // 无意义
136
+ name: 'BlogServerModule' // 太长
137
+ ```
138
+
139
+ ## 路由路径
140
+
141
+ ### 规则
142
+
143
+ - 使用小写字母和连字符
144
+ - RESTful 风格
145
+ - 资源名词复数形式
146
+
147
+ ### 示例
148
+
149
+ ```typescript
150
+ // ✅ 推荐 - RESTful 风格
151
+ path: '/api/articles' // 获取文章列表
152
+ path: '/api/articles/:id' // 获取单篇文章
153
+ path: '/api/users' // 获取用户列表
154
+ path: '/api/users/:id/posts' // 获取用户的文章
155
+
156
+ // ✅ 推荐 - 管理后台
157
+ path: '/admin/dashboard'
158
+ path: '/admin/settings'
159
+ path: '/admin/users'
160
+
161
+ // ❌ 避免
162
+ path: '/api/getArticles' // 动词在路径中
163
+ path: '/api/Article' // 大写
164
+ path: '/api/article_list' // 下划线
165
+ path: '/api/articles123' // 数字后缀
166
+ ```
167
+
168
+ ## 组件命名
169
+
170
+ ### 规则
171
+
172
+ - 使用 PascalCase(大驼峰)
173
+ - 描述性强
174
+ - 体现组件用途
175
+
176
+ ### 示例
177
+
178
+ ```typescript
179
+ // ✅ 推荐 - 页面组件
180
+ function ArticleList() { }
181
+ function ArticleDetail() { }
182
+ function UserDashboard() { }
183
+ function AdminSettings() { }
184
+
185
+ // ✅ 推荐 - UI 组件
186
+ function SubmitButton() { }
187
+ function SearchInput() { }
188
+ function LoadingSpinner() { }
189
+ function ErrorMessage() { }
190
+
191
+ // ✅ 推荐 - 布局组件
192
+ function MainLayout() { }
193
+ function SidebarMenu() { }
194
+ function HeaderNav() { }
195
+
196
+ // ❌ 避免
197
+ function List() { } // 太通用
198
+ function Comp1() { } // 无意义
199
+ function articleList() { } // 小写开头
200
+ function Btn() { } // 缩写不清
201
+ ```
202
+
203
+ ## 变量和函数命名
204
+
205
+ ### 规则
206
+
207
+ - 使用 camelCase
208
+ - 描述性强
209
+ - 布尔值用 is/has/can 前缀
210
+
211
+ ### 示例
212
+
213
+ ```typescript
214
+ // ✅ 推荐 - 变量
215
+ const userName = 'John';
216
+ const articleCount = 10;
217
+ const isLoading = true;
218
+ const hasPermission = false;
219
+ const canEdit = true;
220
+
221
+ // ✅ 推荐 - 函数
222
+ function getUserById(id: number) { }
223
+ function createArticle(data: any) { }
224
+ function isValidEmail(email: string) { }
225
+ function shouldUpdateCache() { }
226
+
227
+ // ✅ 推荐 - 常量
228
+ const MAX_RETRY_COUNT = 3;
229
+ const API_BASE_URL = 'https://api.example.com';
230
+ const DEFAULT_PAGE_SIZE = 10;
231
+
232
+ // ❌ 避免
233
+ const name = 'John'; // 不明确
234
+ const cnt = 10; // 缩写
235
+ const flag = true; // 无意义
236
+ function getData() { } // 太通用
237
+ function check() { } // 不清楚检查什么
238
+ ```
239
+
240
+ ## 文件名
241
+
242
+ ### 规则
243
+
244
+ - 使用 kebab-case(短横线)
245
+ - 描述性强
246
+ - 与导出内容对应
247
+
248
+ ### 示例
249
+
250
+ ```
251
+ src/
252
+ ├── server/
253
+ │ ├── controllers/
254
+ │ │ ├── article-controller.ts # ✅ 推荐
255
+ │ │ └── user-controller.ts
256
+ │ ├── services/
257
+ │ │ ├── article-service.ts
258
+ │ │ └── email-service.ts
259
+ │ └── middlewares/
260
+ │ ├── auth-middleware.ts
261
+ │ └── logging-middleware.ts
262
+ ├── client/
263
+ │ ├── pages/
264
+ │ │ ├── article-list.tsx
265
+ │ │ └── article-detail.tsx
266
+ │ ├── components/
267
+ │ │ ├── submit-button.tsx
268
+ │ │ └── search-input.tsx
269
+ │ └── hooks/
270
+ │ ├── use-fetch-data.ts
271
+ │ └── use-local-storage.ts
272
+ └── shared/
273
+ └── types.ts
274
+
275
+ // ❌ 避免
276
+ articleController.ts // 驼峰
277
+ article_controller.ts // 下划线
278
+ ArticleController.ts // 大写开头
279
+ ctrl.ts // 缩写
280
+ ```
281
+
282
+ ## TypeScript 类型命名
283
+
284
+ ### 规则
285
+
286
+ - 接口使用 PascalCase,以 `I` 开头(可选)
287
+ - 类型别名使用 PascalCase
288
+ - 枚举使用 PascalCase,成员全大写
289
+
290
+ ### 示例
291
+
292
+ ```typescript
293
+ // ✅ 推荐 - 接口
294
+ interface Article {
295
+ id: number;
296
+ title: string;
297
+ }
298
+
299
+ interface IUser {
300
+ id: number;
301
+ name: string;
302
+ }
303
+
304
+ // ✅ 推荐 - 类型别名
305
+ type ArticleStatus = 'draft' | 'published' | 'archived';
306
+ type UserRole = 'admin' | 'editor' | 'viewer';
307
+
308
+ // ✅ 推荐 - 枚举
309
+ enum HttpStatus {
310
+ OK = 200,
311
+ NOT_FOUND = 404,
312
+ INTERNAL_ERROR = 500
313
+ }
314
+
315
+ // ❌ 避免
316
+ interface article { } // 小写
317
+ type article_status = ...; // 下划线
318
+ enum status { } // 小写
319
+ ```
320
+
321
+ ## CSS 类名
322
+
323
+ ### 规则
324
+
325
+ - 使用 kebab-case
326
+ - BEM 命名法(可选)
327
+ - 描述性强
328
+
329
+ ### 示例
330
+
331
+ ```css
332
+ /* ✅ 推荐 - kebab-case */
333
+ .article-list { }
334
+ .article-item { }
335
+ .submit-button { }
336
+
337
+ /* ✅ 推荐 - BEM */
338
+ .article-list { }
339
+ .article-list__item { }
340
+ .article-list__item--active { }
341
+ .submit-button--disabled { }
342
+
343
+ /* ❌ 避免 */
344
+ .articleList { } // 驼峰
345
+ .article_list { } // 下划线
346
+ .item1 { } // 数字
347
+ .red { } // 样式而非语义
348
+ ```
349
+
350
+ ## 环境变量
351
+
352
+ ### 规则
353
+
354
+ - 全大写
355
+ - 使用下划线分隔
356
+ - 以插件名作为前缀
357
+
358
+ ### 示例
359
+
360
+ ```bash
361
+ # ✅ 推荐
362
+ BLOG_PLUGIN_API_KEY=xxx
363
+ ANALYTICS_TRACKING_ID=xxx
364
+ PAYMENT_STRIPE_SECRET=xxx
365
+
366
+ # ❌ 避免
367
+ apiKey=xxx # 小写
368
+ API_KEY=xxx # 缺少前缀
369
+ blog_plugin_apiKey=xxx # 混合大小写
370
+ ```
371
+
372
+ ## 数据库集合名
373
+
374
+ ### 规则
375
+
376
+ - 使用小写复数形式
377
+ - 描述性强
378
+
379
+ ### 示例
380
+
381
+ ```typescript
382
+ // ✅ 推荐
383
+ db.collection('articles')
384
+ db.collection('users')
385
+ db.collection('comments')
386
+
387
+ // ❌ 避免
388
+ db.collection('Article') // 大写
389
+ db.collection('article') // 单数
390
+ db.collection('art') // 缩写
391
+ ```
392
+
393
+ ## Git 分支命名
394
+
395
+ ### 规则
396
+
397
+ - 使用 kebab-case
398
+ - 前缀表明类型
399
+ - 描述性强
400
+
401
+ ### 示例
402
+
403
+ ```bash
404
+ # ✅ 推荐
405
+ git checkout -b feature/add-blog-plugin
406
+ git checkout -b fix/permission-bug
407
+ git checkout -b docs/update-readme
408
+ git checkout -b refactor/simplify-auth
409
+
410
+ # ❌ 避免
411
+ git checkout -b my-branch # 不明确
412
+ git checkout -b Feature_Blog # 混合格式
413
+ git checkout -b f1 # 缩写
414
+ ```
415
+
416
+ ## Commit 消息
417
+
418
+ ### 规则
419
+
420
+ - 使用祈使句
421
+ - 首字母大写
422
+ - 不超过 72 字符
423
+
424
+ ### 示例
425
+
426
+ ```bash
427
+ # ✅ 推荐
428
+ git commit -m "Add article CRUD operations"
429
+ git commit -m "Fix permission check bug"
430
+ git commit -m "Update documentation for slots"
431
+
432
+ # ❌ 避免
433
+ git commit -m "fixed bug" # 过去式
434
+ git commit -m "add stuff" # 不明确
435
+ git commit -m "Update the documentation for the slot feature" # 太长
436
+ ```
437
+
438
+ ## 完整示例
439
+
440
+ 查看示例项目中的命名实践:
441
+
442
+ - 📁 [Hello World 示例](../../examples/hello-world/)
443
+ - 📁 [Blog Plugin 示例](../../examples/blog-plugin/)
444
+
445
+ ## 工具支持
446
+
447
+ ### ESLint 规则
448
+
449
+ ```json
450
+ {
451
+ "rules": {
452
+ "@typescript-eslint/naming-convention": [
453
+ "error",
454
+ {
455
+ "selector": "variable",
456
+ "format": ["camelCase"]
457
+ },
458
+ {
459
+ "selector": "function",
460
+ "format": ["camelCase"]
461
+ },
462
+ {
463
+ "selector": "class",
464
+ "format": ["PascalCase"]
465
+ },
466
+ {
467
+ "selector": "interface",
468
+ "format": ["PascalCase"],
469
+ "prefix": ["I"]
470
+ }
471
+ ]
472
+ }
473
+ }
474
+ ```
475
+
476
+ ### Prettier 配置
477
+
478
+ ```json
479
+ {
480
+ "semi": true,
481
+ "trailingComma": "es5",
482
+ "singleQuote": true,
483
+ "printWidth": 80
484
+ }
485
+ ```
486
+
487
+ ## 相关文档
488
+
489
+ - ⚠️ [错误处理](./error-handling.md)
490
+ - ⚡ [性能优化](./performance.md)
491
+ - 🔒 [安全性](./security.md)
492
+
493
+ ---
494
+
495
+ **上一篇**: [数据持久化](../guides/data-persistence.md) | **下一篇**: [错误处理](./error-handling.md)