@nest-boot/eslint-plugin 7.0.4 → 7.0.5

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 (44) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +6 -0
  3. package/dist/rules/graphql/graphql-field-config-from-types.d.ts +3 -1
  4. package/dist/rules/graphql/graphql-field-config-from-types.js +36 -36
  5. package/dist/rules/graphql/graphql-field-config-from-types.js.map +1 -1
  6. package/dist/rules/graphql/graphql-field-definite-assignment.d.ts +3 -1
  7. package/dist/rules/graphql/graphql-field-definite-assignment.js +13 -13
  8. package/dist/rules/graphql/graphql-field-definite-assignment.js.map +1 -1
  9. package/dist/rules/import/import-bullmq.d.ts +3 -1
  10. package/dist/rules/import/import-bullmq.js +4 -4
  11. package/dist/rules/import/import-bullmq.js.map +1 -1
  12. package/dist/rules/import/import-graphql.d.ts +3 -1
  13. package/dist/rules/import/import-graphql.js +4 -4
  14. package/dist/rules/import/import-graphql.js.map +1 -1
  15. package/dist/rules/import/import-mikro-orm.d.ts +3 -1
  16. package/dist/rules/import/import-mikro-orm.js +4 -4
  17. package/dist/rules/import/import-mikro-orm.js.map +1 -1
  18. package/dist/rules/index.d.ts +21 -7
  19. package/dist/rules/mikro-orm/entity-field-definite-assignment.d.ts +3 -1
  20. package/dist/rules/mikro-orm/entity-field-definite-assignment.js +10 -10
  21. package/dist/rules/mikro-orm/entity-field-definite-assignment.js.map +1 -1
  22. package/dist/rules/mikro-orm/entity-property-config-from-types.d.ts +3 -1
  23. package/dist/rules/mikro-orm/entity-property-config-from-types.js +105 -105
  24. package/dist/rules/mikro-orm/entity-property-config-from-types.js.map +1 -1
  25. package/dist/tsconfig.build.tsbuildinfo +1 -1
  26. package/dist/utils/createRule.d.ts +3 -1
  27. package/dist/utils/decorators.d.ts +16 -16
  28. package/dist/utils/decorators.js +16 -16
  29. package/package.json +12 -7
  30. package/src/rules/graphql/graphql-field-config-from-types.spec.ts +18 -18
  31. package/src/rules/graphql/graphql-field-config-from-types.ts +37 -37
  32. package/src/rules/graphql/graphql-field-definite-assignment.spec.ts +11 -11
  33. package/src/rules/graphql/graphql-field-definite-assignment.ts +13 -13
  34. package/src/rules/import/import-bullmq.spec.ts +9 -9
  35. package/src/rules/import/import-bullmq.ts +5 -4
  36. package/src/rules/import/import-graphql.spec.ts +8 -8
  37. package/src/rules/import/import-graphql.ts +4 -4
  38. package/src/rules/import/import-mikro-orm.spec.ts +8 -8
  39. package/src/rules/import/import-mikro-orm.ts +4 -4
  40. package/src/rules/mikro-orm/entity-field-definite-assignment.spec.ts +18 -18
  41. package/src/rules/mikro-orm/entity-field-definite-assignment.ts +10 -10
  42. package/src/rules/mikro-orm/entity-property-config-from-types.spec.ts +22 -22
  43. package/src/rules/mikro-orm/entity-property-config-from-types.ts +110 -109
  44. package/src/utils/decorators.ts +16 -16
@@ -1,2 +1,4 @@
1
1
  import { ESLintUtils } from "@typescript-eslint/utils";
2
- export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
2
+ export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
@@ -1,29 +1,29 @@
1
1
  import { TSESTree } from "@typescript-eslint/utils";
2
2
  /**
3
- * 检查类是否有指定的装饰器
4
- * @param classDeclaration 类声明节点
5
- * @param decoratorNames 装饰器名称(可以是字符串或字符串数组)
6
- * @returns 是否有指定的装饰器
3
+ * Checks whether a class has the specified decorator(s).
4
+ * @param classDeclaration - The class declaration node.
5
+ * @param decoratorNames - Decorator name(s) (can be a string or an array of strings).
6
+ * @returns Whether the class has the specified decorator(s).
7
7
  */
8
8
  export declare function hasClassDecorator(classDeclaration: TSESTree.ClassDeclaration, decoratorNames: string | string[]): boolean;
9
9
  /**
10
- * 检查属性是否有指定的装饰器
11
- * @param propertyDefinition 属性定义节点
12
- * @param decoratorNames 装饰器名称(可以是字符串或字符串数组)
13
- * @returns 是否有指定的装饰器
10
+ * Checks whether a property has the specified decorator(s).
11
+ * @param propertyDefinition - The property definition node.
12
+ * @param decoratorNames - Decorator name(s) (can be a string or an array of strings).
13
+ * @returns Whether the property has the specified decorator(s).
14
14
  */
15
15
  export declare function hasPropertyDecorator(propertyDefinition: TSESTree.PropertyDefinition, decoratorNames: string | string[]): boolean;
16
16
  /**
17
- * 获取类的装饰器
18
- * @param classDeclaration 类声明节点
19
- * @param decoratorName 装饰器名称
20
- * @returns 装饰器节点,如果不存在则返回 null
17
+ * Gets a decorator from a class declaration.
18
+ * @param classDeclaration - The class declaration node.
19
+ * @param decoratorName - The decorator name.
20
+ * @returns The decorator node, or null if not found.
21
21
  */
22
22
  export declare function getClassDecorator(classDeclaration: TSESTree.ClassDeclaration, decoratorName: string): TSESTree.Decorator | null;
23
23
  /**
24
- * 获取属性的装饰器
25
- * @param propertyDefinition 属性定义节点
26
- * @param decoratorName 装饰器名称
27
- * @returns 装饰器节点,如果不存在则返回 null
24
+ * Gets a decorator from a property definition.
25
+ * @param propertyDefinition - The property definition node.
26
+ * @param decoratorName - The decorator name.
27
+ * @returns The decorator node, or null if not found.
28
28
  */
29
29
  export declare function getPropertyDecorator(propertyDefinition: TSESTree.PropertyDefinition, decoratorName: string): TSESTree.Decorator | null;
@@ -6,10 +6,10 @@ exports.getClassDecorator = getClassDecorator;
6
6
  exports.getPropertyDecorator = getPropertyDecorator;
7
7
  const utils_1 = require("@typescript-eslint/utils");
8
8
  /**
9
- * 检查类是否有指定的装饰器
10
- * @param classDeclaration 类声明节点
11
- * @param decoratorNames 装饰器名称(可以是字符串或字符串数组)
12
- * @returns 是否有指定的装饰器
9
+ * Checks whether a class has the specified decorator(s).
10
+ * @param classDeclaration - The class declaration node.
11
+ * @param decoratorNames - Decorator name(s) (can be a string or an array of strings).
12
+ * @returns Whether the class has the specified decorator(s).
13
13
  */
14
14
  function hasClassDecorator(classDeclaration, decoratorNames) {
15
15
  const names = Array.isArray(decoratorNames)
@@ -26,10 +26,10 @@ function hasClassDecorator(classDeclaration, decoratorNames) {
26
26
  });
27
27
  }
28
28
  /**
29
- * 检查属性是否有指定的装饰器
30
- * @param propertyDefinition 属性定义节点
31
- * @param decoratorNames 装饰器名称(可以是字符串或字符串数组)
32
- * @returns 是否有指定的装饰器
29
+ * Checks whether a property has the specified decorator(s).
30
+ * @param propertyDefinition - The property definition node.
31
+ * @param decoratorNames - Decorator name(s) (can be a string or an array of strings).
32
+ * @returns Whether the property has the specified decorator(s).
33
33
  */
34
34
  function hasPropertyDecorator(propertyDefinition, decoratorNames) {
35
35
  const names = Array.isArray(decoratorNames)
@@ -46,10 +46,10 @@ function hasPropertyDecorator(propertyDefinition, decoratorNames) {
46
46
  });
47
47
  }
48
48
  /**
49
- * 获取类的装饰器
50
- * @param classDeclaration 类声明节点
51
- * @param decoratorName 装饰器名称
52
- * @returns 装饰器节点,如果不存在则返回 null
49
+ * Gets a decorator from a class declaration.
50
+ * @param classDeclaration - The class declaration node.
51
+ * @param decoratorName - The decorator name.
52
+ * @returns The decorator node, or null if not found.
53
53
  */
54
54
  function getClassDecorator(classDeclaration, decoratorName) {
55
55
  return (classDeclaration.decorators.find((decorator) => {
@@ -59,10 +59,10 @@ function getClassDecorator(classDeclaration, decoratorName) {
59
59
  }) ?? null);
60
60
  }
61
61
  /**
62
- * 获取属性的装饰器
63
- * @param propertyDefinition 属性定义节点
64
- * @param decoratorName 装饰器名称
65
- * @returns 装饰器节点,如果不存在则返回 null
62
+ * Gets a decorator from a property definition.
63
+ * @param propertyDefinition - The property definition node.
64
+ * @param decoratorName - The decorator name.
65
+ * @returns The decorator node, or null if not found.
66
66
  */
67
67
  function getPropertyDecorator(propertyDefinition, decoratorName) {
68
68
  return (propertyDefinition.decorators.find((decorator) => {
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@nest-boot/eslint-plugin",
3
- "version": "7.0.4",
3
+ "version": "7.0.5",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/nest-boot/nest-boot.git",
7
+ "directory": "packages/eslint-plugin"
8
+ },
4
9
  "license": "MIT",
5
10
  "main": "./dist/index.js",
6
11
  "exports": "./dist/index.js",
7
12
  "dependencies": {
8
- "@typescript-eslint/utils": "^8.44.1"
13
+ "@typescript-eslint/utils": "^8.51.0"
9
14
  },
10
15
  "peerDependencies": {
11
16
  "@typescript-eslint/parser": "^8.0.0",
@@ -13,13 +18,13 @@
13
18
  "typescript": "^5.0.0"
14
19
  },
15
20
  "devDependencies": {
16
- "@eslint/eslintrc": "^3.3.1",
17
- "@eslint/js": "^9.36.0",
21
+ "@eslint/eslintrc": "^3.3.3",
22
+ "@eslint/js": "^9.39.2",
18
23
  "@jest/globals": "^30.2.0",
19
24
  "@types/node": "^22.18.6",
20
- "@typescript-eslint/parser": "^8.44.1",
21
- "@typescript-eslint/rule-tester": "^8.44.1",
22
- "eslint": "^9.36.0",
25
+ "@typescript-eslint/parser": "^8.51.0",
26
+ "@typescript-eslint/rule-tester": "^8.51.0",
27
+ "eslint": "^9.39.2",
23
28
  "eslint-config-prettier": "^10.1.8",
24
29
  "eslint-plugin-simple-import-sort": "^12.1.1",
25
30
  "jest": "^29.7.0",
@@ -3,7 +3,7 @@ import rule from "./graphql-field-config-from-types";
3
3
 
4
4
  tester.run("graphql-field-config-from-types", rule, {
5
5
  valid: [
6
- // 正确的 string 类型
6
+ // Correct string type
7
7
  /* typescript */ `
8
8
  @ObjectType()
9
9
  class User {
@@ -11,7 +11,7 @@ tester.run("graphql-field-config-from-types", rule, {
11
11
  name!: string;
12
12
  }
13
13
  `,
14
- // 正确的 number 类型(Float
14
+ // Correct number type (Float)
15
15
  /* typescript */ `
16
16
  @ObjectType()
17
17
  class User {
@@ -19,7 +19,7 @@ tester.run("graphql-field-config-from-types", rule, {
19
19
  score!: number;
20
20
  }
21
21
  `,
22
- // 正确的 number 类型(Int
22
+ // Correct number type (Int)
23
23
  /* typescript */ `
24
24
  @ObjectType()
25
25
  class User {
@@ -27,7 +27,7 @@ tester.run("graphql-field-config-from-types", rule, {
27
27
  age!: number;
28
28
  }
29
29
  `,
30
- // 正确的 boolean 类型
30
+ // Correct boolean type
31
31
  /* typescript */ `
32
32
  @ObjectType()
33
33
  class User {
@@ -35,7 +35,7 @@ tester.run("graphql-field-config-from-types", rule, {
35
35
  isActive!: boolean;
36
36
  }
37
37
  `,
38
- // 正确的 nullable 配置
38
+ // Correct nullable configuration
39
39
  /* typescript */ `
40
40
  @ObjectType()
41
41
  class User {
@@ -43,7 +43,7 @@ tester.run("graphql-field-config-from-types", rule, {
43
43
  name?: string;
44
44
  }
45
45
  `,
46
- // 正确的数组类型
46
+ // Correct array type
47
47
  /* typescript */ `
48
48
  @ObjectType()
49
49
  class User {
@@ -51,7 +51,7 @@ tester.run("graphql-field-config-from-types", rule, {
51
51
  tags!: string[];
52
52
  }
53
53
  `,
54
- // ID 类型
54
+ // ID type
55
55
  /* typescript */ `
56
56
  @ObjectType()
57
57
  class User {
@@ -59,7 +59,7 @@ tester.run("graphql-field-config-from-types", rule, {
59
59
  id!: string;
60
60
  }
61
61
  `,
62
- // 自定义类型
62
+ // Custom type
63
63
  /* typescript */ `
64
64
  @ObjectType()
65
65
  class User {
@@ -67,7 +67,7 @@ tester.run("graphql-field-config-from-types", rule, {
67
67
  profile!: Profile;
68
68
  }
69
69
  `,
70
- // 带有 HideField 装饰器的属性不需要 @Field
70
+ // Property with @HideField decorator does not need @Field
71
71
  /* typescript */ `
72
72
  @ObjectType()
73
73
  class User {
@@ -75,13 +75,13 @@ tester.run("graphql-field-config-from-types", rule, {
75
75
  password!: string;
76
76
  }
77
77
  `,
78
- // GraphQL 模型类不检查
78
+ // Non-GraphQL model class is not checked
79
79
  /* typescript */ `
80
80
  class NotAGraphQLModel {
81
81
  field: string;
82
82
  }
83
83
  `,
84
- // 复杂的配置对象(包含展开运算符和条件表达式)
84
+ // Complex config object (with spread operator and conditional expression)
85
85
  /* typescript */ `
86
86
  @ObjectType()
87
87
  class Connection {
@@ -98,7 +98,7 @@ tester.run("graphql-field-config-from-types", rule, {
98
98
  `,
99
99
  ],
100
100
  invalid: [
101
- // @Field 类型不匹配
101
+ // @Field type mismatch
102
102
  {
103
103
  code: /* typescript */ `
104
104
  @ObjectType()
@@ -116,7 +116,7 @@ tester.run("graphql-field-config-from-types", rule, {
116
116
  `,
117
117
  errors: [{ messageId: "alignFieldDecoratorWithTsType" }],
118
118
  },
119
- // nullable 配置不匹配
119
+ // nullable configuration mismatch
120
120
  {
121
121
  code: /* typescript */ `
122
122
  @ObjectType()
@@ -134,7 +134,7 @@ tester.run("graphql-field-config-from-types", rule, {
134
134
  `,
135
135
  errors: [{ messageId: "alignFieldDecoratorWithTsType" }],
136
136
  },
137
- // 不应该有 nullable 但设置了
137
+ // Should not have nullable but it is set
138
138
  {
139
139
  code: /* typescript */ `
140
140
  @ObjectType()
@@ -152,7 +152,7 @@ tester.run("graphql-field-config-from-types", rule, {
152
152
  `,
153
153
  errors: [{ messageId: "alignFieldDecoratorWithTsType" }],
154
154
  },
155
- // 数组类型不匹配
155
+ // Array type mismatch
156
156
  {
157
157
  code: /* typescript */ `
158
158
  @ObjectType()
@@ -170,7 +170,7 @@ tester.run("graphql-field-config-from-types", rule, {
170
170
  `,
171
171
  errors: [{ messageId: "alignFieldDecoratorWithTsType" }],
172
172
  },
173
- // 缺少 type function 但有其他配置选项(应保留)
173
+ // Missing type function but has other config options (should be preserved)
174
174
  {
175
175
  code: /* typescript */ `
176
176
  @ObjectType()
@@ -191,7 +191,7 @@ tester.run("graphql-field-config-from-types", rule, {
191
191
  `,
192
192
  errors: [{ messageId: "alignFieldDecoratorWithTsType" }],
193
193
  },
194
- // 配置 nullable 时保留其他选项
194
+ // nullable config should preserve other options
195
195
  {
196
196
  code: /* typescript */ `
197
197
  @ObjectType()
@@ -209,7 +209,7 @@ tester.run("graphql-field-config-from-types", rule, {
209
209
  `,
210
210
  errors: [{ messageId: "alignFieldDecoratorWithTsType" }],
211
211
  },
212
- // 复杂配置对象(包含展开运算符)缺少 type function
212
+ // Complex config object (with spread operator) missing type function
213
213
  {
214
214
  code: /* typescript */ `
215
215
  @ObjectType()
@@ -7,7 +7,7 @@ import {
7
7
  hasClassDecorator,
8
8
  } from "../../utils/decorators";
9
9
 
10
- // 自定义 Fix 对象类型,用于延迟应用修复
10
+ // Custom Fix object type for deferred fix application
11
11
  interface CustomFix {
12
12
  type: "insert" | "replace";
13
13
  range: readonly [number, number];
@@ -35,7 +35,7 @@ export default createRule<
35
35
  type: "problem",
36
36
  docs: {
37
37
  description:
38
- "根据 TypeScript 类型自动生成或修正 @Field 装饰器的类型与 nullable 配置(支持数组)。",
38
+ "Automatically generate or fix @Field decorator type and nullable configuration based on TypeScript types (with array support).",
39
39
  },
40
40
  fixable: "code",
41
41
  schema: [
@@ -49,7 +49,7 @@ export default createRule<
49
49
  enum: ["ignore", "remove"],
50
50
  },
51
51
  description:
52
- "配置每个装饰器的行为。ignore: 跳过检查;remove: 移除 @Field。默认:{ HideField: 'remove', OneToOne: 'remove', OneToMany: 'remove', ManyToOne: 'remove', ManyToMany: 'remove' }",
52
+ "Configure behavior for each decorator. ignore: skip checks; remove: remove @Field. Default: { HideField: 'remove', OneToOne: 'remove', OneToMany: 'remove', ManyToOne: 'remove', ManyToMany: 'remove' }",
53
53
  },
54
54
  },
55
55
  additionalProperties: false,
@@ -57,9 +57,9 @@ export default createRule<
57
57
  ],
58
58
  messages: {
59
59
  alignFieldDecoratorWithTsType:
60
- "@Field 装饰器应与 TypeScript 类型保持一致(类型与 nullable)。",
60
+ "@Field decorator should align with the TypeScript type (type and nullable).",
61
61
  removeFieldDecorator:
62
- "属性带有 @{{decoratorName}} 装饰器,应移除 @Field 装饰器。",
62
+ "Property has a @{{decoratorName}} decorator, @Field decorator should be removed.",
63
63
  },
64
64
  },
65
65
  defaultOptions: [
@@ -85,7 +85,7 @@ export default createRule<
85
85
  case AST_NODE_TYPES.TSStringKeyword:
86
86
  return "String";
87
87
  case AST_NODE_TYPES.TSNumberKeyword:
88
- // 默认 number → FloatGraphQL 默认也是 FloatInt 需显式声明)
88
+ // Default number → Float (GraphQL default is also Float; Int must be declared explicitly)
89
89
  return "Float";
90
90
  default:
91
91
  return null;
@@ -129,12 +129,12 @@ export default createRule<
129
129
  ? property.typeAnnotation.typeAnnotation
130
130
  : null;
131
131
 
132
- // 可选属性(?)视为可空
132
+ // Optional property (?) is treated as nullable
133
133
  if (property.optional) {
134
134
  isNullable = true;
135
135
  }
136
136
 
137
- // 处理联合类型中的 null/undefined
137
+ // Handle null/undefined in union types
138
138
  if (baseTypeNode?.type === AST_NODE_TYPES.TSUnionType) {
139
139
  const hasNullish = baseTypeNode.types.some((t: TSESTree.TypeNode) => {
140
140
  return (
@@ -153,7 +153,7 @@ export default createRule<
153
153
  }) ?? null;
154
154
  }
155
155
 
156
- // 先解包 Ref<T> Opt<T> → T,并在内部再次处理 null/undefined
156
+ // First unwrap Ref<T> and Opt<T> → T, and handle null/undefined within
157
157
  if (
158
158
  baseTypeNode?.type === AST_NODE_TYPES.TSTypeReference &&
159
159
  baseTypeNode.typeName.type === AST_NODE_TYPES.Identifier &&
@@ -180,7 +180,7 @@ export default createRule<
180
180
  baseTypeNode = inner ?? baseTypeNode;
181
181
  }
182
182
 
183
- // 数组类型(T[] Array<T>)- 在解包 Opt/Ref 之后检查
183
+ // Array type (T[] or Array<T>) - checked after unwrapping Opt/Ref
184
184
  const elementTypeNode = baseTypeNode
185
185
  ? extractArrayElementType(baseTypeNode)
186
186
  : null;
@@ -191,7 +191,7 @@ export default createRule<
191
191
  const targetTypeNode: TSESTree.TypeNode | null =
192
192
  elementTypeNode ?? baseTypeNode;
193
193
 
194
- // 无显式类型时,尝试从字面量初始值推断
194
+ // When no explicit type, try to infer from literal initializer
195
195
  if (!targetTypeNode) {
196
196
  if (property.value?.type === AST_NODE_TYPES.Literal) {
197
197
  const value = property.value.value;
@@ -206,7 +206,7 @@ export default createRule<
206
206
  return null;
207
207
  }
208
208
 
209
- // id 字段优先使用 GraphQL 标量 ID
209
+ // id field prefers GraphQL scalar ID
210
210
  const propertyName =
211
211
  property.key.type === AST_NODE_TYPES.Identifier
212
212
  ? property.key.name
@@ -220,7 +220,7 @@ export default createRule<
220
220
  return { typeName: "ID", isArray, isNullable };
221
221
  }
222
222
 
223
- // Record<*, *> → GraphQLJSONObject(不限制键值类型)
223
+ // Record<*, *> → GraphQLJSONObject (no restriction on key/value types)
224
224
  if (
225
225
  targetTypeNode.type === AST_NODE_TYPES.TSTypeReference &&
226
226
  targetTypeNode.typeName.type === AST_NODE_TYPES.Identifier &&
@@ -229,13 +229,13 @@ export default createRule<
229
229
  return { typeName: "GraphQLJSONObject", isArray, isNullable };
230
230
  }
231
231
 
232
- // 关键字类型 → GraphQL 标量
232
+ // Keyword types → GraphQL scalars
233
233
  const scalar = scalarFromTsKeyword(targetTypeNode.type);
234
234
  if (scalar) {
235
235
  return { typeName: scalar, isArray, isNullable };
236
236
  }
237
237
 
238
- // 标识符(类/自定义类型)
238
+ // Identifier (class/custom type)
239
239
  const ident = getIdentifierName(targetTypeNode);
240
240
  if (ident) {
241
241
  return { typeName: ident, isArray, isNullable };
@@ -313,24 +313,24 @@ export default createRule<
313
313
  ? `() => [${typeName}]`
314
314
  : `() => ${typeName}`;
315
315
 
316
- // 提取现有的配置选项(除了 nullable
316
+ // Extract existing config options (except nullable)
317
317
  const callExpr = fieldDecorator.expression;
318
318
  const existingOptions: string[] = [];
319
319
 
320
- // 检查是否有现有的配置对象
320
+ // Check if there is an existing config object
321
321
  let optionsArg: TSESTree.ObjectExpression | null = null;
322
322
  if (
323
323
  callExpr.type === AST_NODE_TYPES.CallExpression &&
324
324
  callExpr.arguments.length > 0
325
325
  ) {
326
- // 如果第一个参数是对象表达式(没有 type function
326
+ // If the first argument is an object expression (no type function)
327
327
  if (
328
328
  callExpr.arguments[0] &&
329
329
  callExpr.arguments[0].type === AST_NODE_TYPES.ObjectExpression
330
330
  ) {
331
331
  optionsArg = callExpr.arguments[0];
332
332
  }
333
- // 如果第二个参数是对象表达式(有 type function
333
+ // If the second argument is an object expression (has type function)
334
334
  else if (
335
335
  callExpr.arguments[1] &&
336
336
  callExpr.arguments[1].type === AST_NODE_TYPES.ObjectExpression
@@ -339,42 +339,42 @@ export default createRule<
339
339
  }
340
340
  }
341
341
 
342
- // 提取现有选项,同时处理 nullable
342
+ // Extract existing options, while handling nullable
343
343
  let hasNullableProperty = false;
344
344
  if (optionsArg) {
345
345
  optionsArg.properties.forEach((prop: TSESTree.ObjectLiteralElement) => {
346
- // 处理展开运算符 (SpreadElement)
346
+ // Handle spread elements (SpreadElement)
347
347
  if (prop.type === AST_NODE_TYPES.SpreadElement) {
348
348
  const propText = source.getText(prop);
349
349
  existingOptions.push(propText);
350
350
  return;
351
351
  }
352
- // 处理普通属性 (Property)
352
+ // Handle regular properties (Property)
353
353
  if (
354
354
  prop.key.type === AST_NODE_TYPES.Identifier &&
355
355
  prop.key.name === "nullable"
356
356
  ) {
357
357
  hasNullableProperty = true;
358
- // 根据类型决定是否保留或更新 nullable
358
+ // Decide whether to keep or update nullable based on type
359
359
  if (info.isNullable) {
360
360
  existingOptions.push("nullable: true");
361
361
  }
362
- // 如果不需要 nullable,则跳过(不保留)
362
+ // If nullable is not needed, skip (don't keep)
363
363
  } else {
364
- // 保留原有的其他配置
364
+ // Keep other existing config options
365
365
  const propText = source.getText(prop);
366
366
  existingOptions.push(propText);
367
367
  }
368
368
  });
369
369
  }
370
370
 
371
- // 如果需要 nullable 但原配置中没有,则添加到最前面
371
+ // If nullable is needed but not in original config, prepend it
372
372
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
373
373
  if (info.isNullable && !hasNullableProperty) {
374
374
  existingOptions.unshift("nullable: true");
375
375
  }
376
376
 
377
- // 构建新的装饰器文本
377
+ // Build the new decorator text
378
378
  const optionsExpr =
379
379
  existingOptions.length > 0 ? `, { ${existingOptions.join(", ")} }` : "";
380
380
  const newDecoratorText = `@Field(${typeExpr}${optionsExpr})`;
@@ -422,7 +422,7 @@ export default createRule<
422
422
  ManyToMany: "remove",
423
423
  };
424
424
 
425
- // 检查是否有配置的装饰器
425
+ // Check if the property has a configured decorator
426
426
  let foundDecoratorName: string | null = null;
427
427
  let foundBehavior: DecoratorBehavior | null = null;
428
428
 
@@ -440,12 +440,12 @@ export default createRule<
440
440
  }
441
441
  }
442
442
 
443
- // 如果是 ignore 行为,直接跳过
443
+ // If behavior is "ignore", skip directly
444
444
  if (foundBehavior === "ignore") return;
445
445
 
446
446
  const fieldDecorator = getPropertyDecorator(member, "Field");
447
447
 
448
- // 如果是 remove 行为且有 @Field,则移除 @Field
448
+ // If behavior is "remove" and has @Field, remove @Field
449
449
  if (foundBehavior === "remove" && fieldDecorator) {
450
450
  context.report({
451
451
  node: fieldDecorator,
@@ -454,11 +454,11 @@ export default createRule<
454
454
  decoratorName: foundDecoratorName ?? "unknown",
455
455
  },
456
456
  fix: (fixer) => {
457
- // 移除整个装饰器行(包括换行)
457
+ // Remove the entire decorator line (including newline)
458
458
  const decoratorStart = fieldDecorator.range[0];
459
459
  const decoratorEnd = fieldDecorator.range[1];
460
460
 
461
- // 查找装饰器后的换行符和空格
461
+ // Find the newline and whitespace after the decorator
462
462
  const textAfter = source.text.slice(
463
463
  decoratorEnd,
464
464
  decoratorEnd + 10,
@@ -474,13 +474,13 @@ export default createRule<
474
474
  return;
475
475
  }
476
476
 
477
- // 如果是 remove 行为但没有 @Field,跳过
477
+ // If behavior is "remove" but no @Field, skip
478
478
  if (foundBehavior === "remove") return;
479
479
 
480
480
  const typeInfo = computeTypeInfo(member);
481
481
  if (!typeInfo?.typeName) return;
482
482
 
483
- // 如果没有 @Field 装饰器,添加它
483
+ // If there is no @Field decorator, add one
484
484
  if (!fieldDecorator) {
485
485
  context.report({
486
486
  node: member,
@@ -493,7 +493,7 @@ export default createRule<
493
493
  return;
494
494
  }
495
495
 
496
- // 若已有 ArrowFunction 但与期望不一致,也进行修正
496
+ // If there is an existing ArrowFunction but it doesn't match expectations, fix it
497
497
  const callExpr = fieldDecorator.expression;
498
498
  if (callExpr.type !== AST_NODE_TYPES.CallExpression) return;
499
499
 
@@ -525,9 +525,9 @@ export default createRule<
525
525
  },
526
526
  );
527
527
 
528
- // 对于 number 类型,Int Float 都是合法的
528
+ // For number types, both Int and Float are valid
529
529
  const isNumberType = typeInfo.typeName === "Float";
530
- const actualTypeText = calleeText.replace(/^\[|\]$/g, ""); // 移除数组括号
530
+ const actualTypeText = calleeText.replace(/^\[|\]$/g, ""); // Remove array brackets
531
531
  const isValidNumberType =
532
532
  isNumberType &&
533
533
  (actualTypeText === "Int" || actualTypeText === "Float");