diff --git a/references/js&ts.base.md b/references/js&ts.base.md index d844125..368bc85 100644 --- a/references/js&ts.base.md +++ b/references/js&ts.base.md @@ -69,6 +69,26 @@ const maxCount = 100; const userStatus = "active"; ``` +## 基于 JsTs.Base.NoMagicStringsAndNumbers 抽离的静态常量需要放在对应文件里 `[JsTs.Base.ConstantsDefinition]` + +> - severity `warn` + +- 需要放在指定模块的 constants 文件里 + +### Good + +```javascript +// user.constants.js +const MAX_COUNT = 100; // 这是 user 模块需要的 +``` + +### Bad + +```javascript +// class.constants.js +const MAX_COUNT = 100; // 这是 user 模块需要的 +``` + ## class 和 interface 命名使用大驼峰命名 `[JsTs.Base.ClassUpperCamel]` > - severity `warn` diff --git a/references/js&ts.nest.md b/references/js&ts.nest.md index a5a6581..79563fc 100644 --- a/references/js&ts.nest.md +++ b/references/js&ts.nest.md @@ -1,6 +1,6 @@ # Nestjs 项目下的规范 `[JsTs.Nest]` -> - includes `*.controller.ts` `*.service.ts` `*.module.ts` `*.dto.ts` `*.pipe.ts` `*.guard.ts` `*.interceptor.ts` `*.filter.ts` `*.exception-filter.ts` `*.proxy.ts` `*.model.ts` +> - includes `*.controller.ts` `*.service.ts` `*.module.ts` `*.dto.ts` `*.pipe.ts` `*.guard.ts` `*.interceptor.ts` `*.filter.ts` `*.exception-filter.ts` `*.proxy.ts` `*.model.ts` `*.constants.ts` > - override `[JsTs.FileName]` ## 目录框架规范 `[JsTs.Nest.DirStructure]` @@ -248,3 +248,24 @@ export class UserProxy { ```typescript // proxy/user.js ``` + +## 基于 JsTs.Base.NoMagicStringsAndNumbers 抽离的静态常量需要放在对应文件里 `[JsTs.Nest.ConstantsDefinition]` + +> - severity `warn` +> - override `[JsTs.Base.ConstantsDefinition]` + +- 需要放在指定模块的 constants 文件里 + +### Good + +```typescript +// user.constants.ts +const MAX_COUNT = 100; // 这是 user 模块需要的 +``` + +### Bad + +```typescript +// class.constants.ts +const MAX_COUNT = 100; // 这是 user 模块需要的 +```