@nest-boot/eslint-plugin 7.0.4 → 7.0.6

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 (45) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +14 -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 +39 -41
  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 +106 -106
  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 +14 -9
  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 +40 -44
  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 +111 -110
  44. package/src/utils/decorators.ts +16 -16
  45. package/tsconfig.json +0 -1
@@ -50,10 +50,10 @@ export default createRule({
50
50
  const isOptionalProperty = (
51
51
  member: TSESTree.PropertyDefinition,
52
52
  ): boolean => {
53
- // 检查 AST 节点的 optional 标记
53
+ // Check the AST node's optional flag
54
54
  if (member.optional) return true;
55
55
 
56
- // 检查源代码中是否有 ? 符号(在属性名和冒号之间)
56
+ // Check if there is a ? symbol in the source code (between property name and colon)
57
57
  const keyEnd = member.key.range[1];
58
58
  const text = source.text;
59
59
  for (let i = keyEnd; i < member.range[1]; i++) {
@@ -87,13 +87,13 @@ export default createRule({
87
87
  const propertyName = getPropertyName(member);
88
88
  if (!propertyName) return;
89
89
 
90
- // 可选属性(?:)不需要 definite assignment assertion
90
+ // Optional properties (?:) do not need a definite assignment assertion
91
91
  if (isOptionalProperty(member)) return;
92
92
 
93
93
  const hasInit = hasInitializer(member);
94
94
  const hasDefinite = hasDefiniteAssignment(member);
95
95
 
96
- // 情况1: 没有初始化值,但也没有 definite assignment assertion
96
+ // Case 1: No initializer and no definite assignment assertion
97
97
  if (!hasInit && !hasDefinite) {
98
98
  context.report({
99
99
  node: member,
@@ -102,15 +102,15 @@ export default createRule({
102
102
  propertyName,
103
103
  },
104
104
  fix: (fixer) => {
105
- // 找到属性名称的结束位置
105
+ // Find the end position of the property name
106
106
  const keyEnd = member.key.range[1];
107
- // 在属性名称后添加 !
107
+ // Insert ! after the property name
108
108
  return fixer.insertTextAfterRange([keyEnd, keyEnd], "!");
109
109
  },
110
110
  });
111
111
  }
112
112
 
113
- // 情况2: 有初始化值,但也有 definite assignment assertion
113
+ // Case 2: Has initializer but also has definite assignment assertion
114
114
  if (hasInit && hasDefinite) {
115
115
  context.report({
116
116
  node: member,
@@ -119,18 +119,18 @@ export default createRule({
119
119
  propertyName,
120
120
  },
121
121
  fix: (fixer) => {
122
- // 找到 ! 的位置并移除
122
+ // Find and remove the ! position
123
123
  const keyEnd = member.key.range[1];
124
124
  const text = source.text;
125
125
 
126
- // 查找 ! 的位置(在属性名称和冒号之间)
126
+ // Find the ! position (between the property name and the colon)
127
127
  let exclamationPos = -1;
128
128
  for (let i = keyEnd; i < member.range[1]; i++) {
129
129
  if (text[i] === "!") {
130
130
  exclamationPos = i;
131
131
  break;
132
132
  }
133
- // 如果遇到冒号,说明没有 !
133
+ // If we encounter a colon, there is no !
134
134
  if (text[i] === ":") {
135
135
  break;
136
136
  }
@@ -3,7 +3,7 @@ import rule from "./entity-property-config-from-types";
3
3
 
4
4
  tester.run("entity-property-config-from-types", rule, {
5
5
  valid: [
6
- // 正确的 string 类型
6
+ // Correct string type
7
7
  /* typescript */ `
8
8
  import { Entity, Property } from "@mikro-orm/core";
9
9
 
@@ -13,7 +13,7 @@ tester.run("entity-property-config-from-types", rule, {
13
13
  name!: string;
14
14
  }
15
15
  `,
16
- // 正确的 nullable 配置
16
+ // Correct nullable configuration
17
17
  /* typescript */ `
18
18
  import { Entity, Property } from "@mikro-orm/core";
19
19
 
@@ -23,7 +23,7 @@ tester.run("entity-property-config-from-types", rule, {
23
23
  name?: string;
24
24
  }
25
25
  `,
26
- // 使用 Opt<T> 类型且有初始化值
26
+ // Using Opt<T> type with initializer
27
27
  /* typescript */ `
28
28
  import { Entity, Property, Opt } from "@mikro-orm/core";
29
29
 
@@ -33,7 +33,7 @@ tester.run("entity-property-config-from-types", rule, {
33
33
  isActive: Opt<boolean> = false;
34
34
  }
35
35
  `,
36
- // 关系装饰器不需要 @Property
36
+ // Relation decorators don't need @Property
37
37
  /* typescript */ `
38
38
  import { Entity, ManyToOne } from "@mikro-orm/core";
39
39
 
@@ -43,7 +43,7 @@ tester.run("entity-property-config-from-types", rule, {
43
43
  author!: User;
44
44
  }
45
45
  `,
46
- // PrimaryKey 需要 type 配置
46
+ // PrimaryKey needs type configuration
47
47
  /* typescript */ `
48
48
  import { Entity, PrimaryKey, t } from "@mikro-orm/core";
49
49
 
@@ -53,7 +53,7 @@ tester.run("entity-property-config-from-types", rule, {
53
53
  id!: number;
54
54
  }
55
55
  `,
56
- // 枚举类型使用 @Enum
56
+ // Enum type uses @Enum
57
57
  /* typescript */ `
58
58
  import { Entity, Enum } from "@mikro-orm/core";
59
59
 
@@ -68,7 +68,7 @@ tester.run("entity-property-config-from-types", rule, {
68
68
  role!: Role;
69
69
  }
70
70
  `,
71
- // 数组类型
71
+ // Array type
72
72
  /* typescript */ `
73
73
  import { Entity, Property } from "@mikro-orm/core";
74
74
 
@@ -78,7 +78,7 @@ tester.run("entity-property-config-from-types", rule, {
78
78
  tags!: number[];
79
79
  }
80
80
  `,
81
- // boolean 类型
81
+ // boolean type
82
82
  /* typescript */ `
83
83
  import { Entity, Property } from "@mikro-orm/core";
84
84
 
@@ -88,7 +88,7 @@ tester.run("entity-property-config-from-types", rule, {
88
88
  isActive!: boolean;
89
89
  }
90
90
  `,
91
- // Date 类型使用 t.datetime
91
+ // Date type using t.datetime
92
92
  /* typescript */ `
93
93
  import { Entity, Property, Opt } from "@mikro-orm/core";
94
94
 
@@ -98,7 +98,7 @@ tester.run("entity-property-config-from-types", rule, {
98
98
  createdAt: Opt<Date> = new Date();
99
99
  }
100
100
  `,
101
- // Date 类型使用 t.date(有效的 Date 类型配置)
101
+ // Date type using t.date (valid Date type configuration)
102
102
  /* typescript */ `
103
103
  import { Entity, Property } from "@mikro-orm/core";
104
104
 
@@ -108,7 +108,7 @@ tester.run("entity-property-config-from-types", rule, {
108
108
  birthDate!: Date;
109
109
  }
110
110
  `,
111
- // Date 类型使用 t.time(有效的 Date 类型配置)
111
+ // Date type using t.time (valid Date type configuration)
112
112
  /* typescript */ `
113
113
  import { Entity, Property } from "@mikro-orm/core";
114
114
 
@@ -118,7 +118,7 @@ tester.run("entity-property-config-from-types", rule, {
118
118
  workTime!: Date;
119
119
  }
120
120
  `,
121
- // 使用 t.text 代替 t.string(有效的 string 类型配置)
121
+ // Using t.text instead of t.string (valid string type configuration)
122
122
  /* typescript */ `
123
123
  import { Entity, Property } from "@mikro-orm/core";
124
124
 
@@ -128,7 +128,7 @@ tester.run("entity-property-config-from-types", rule, {
128
128
  description!: string;
129
129
  }
130
130
  `,
131
- // Entity 类不检查
131
+ // Non-Entity class is not checked
132
132
  /* typescript */ `
133
133
  class NotAnEntity {
134
134
  field: string;
@@ -136,7 +136,7 @@ tester.run("entity-property-config-from-types", rule, {
136
136
  `,
137
137
  ],
138
138
  invalid: [
139
- // type 配置不匹配
139
+ // type configuration mismatch
140
140
  {
141
141
  code: /* typescript */ `
142
142
  import { Entity, Property } from "@mikro-orm/core";
@@ -158,7 +158,7 @@ tester.run("entity-property-config-from-types", rule, {
158
158
  `,
159
159
  errors: [{ messageId: "alignPropertyDecoratorWithTsType" }],
160
160
  },
161
- // nullable 配置不匹配
161
+ // nullable configuration mismatch
162
162
  {
163
163
  code: /* typescript */ `
164
164
  import { Entity, Property } from "@mikro-orm/core";
@@ -180,7 +180,7 @@ tester.run("entity-property-config-from-types", rule, {
180
180
  `,
181
181
  errors: [{ messageId: "alignPropertyDecoratorWithTsType" }],
182
182
  },
183
- // 有初始化值但没有使用 Opt<T>
183
+ // Has initializer but not using Opt<T>
184
184
  {
185
185
  code: /* typescript */ `
186
186
  import { Entity, Property } from "@mikro-orm/core";
@@ -202,7 +202,7 @@ tester.run("entity-property-config-from-types", rule, {
202
202
  `,
203
203
  errors: [{ messageId: "useOptTypeForInitializedProperty" }],
204
204
  },
205
- // 枚举类型应该使用 @Enum 装饰器
205
+ // Enum type should use @Enum decorator
206
206
  {
207
207
  code: /* typescript */ `
208
208
  import { Entity, Property } from "@mikro-orm/core";
@@ -234,7 +234,7 @@ tester.run("entity-property-config-from-types", rule, {
234
234
  `,
235
235
  errors: [{ messageId: "useEnumDecorator" }],
236
236
  },
237
- // @Enum nullable 配置不匹配
237
+ // @Enum nullable configuration mismatch
238
238
  {
239
239
  code: /* typescript */ `
240
240
  import { Entity, Enum } from "@mikro-orm/core";
@@ -266,7 +266,7 @@ tester.run("entity-property-config-from-types", rule, {
266
266
  `,
267
267
  errors: [{ messageId: "alignPropertyDecoratorWithTsType" }],
268
268
  },
269
- // 数组类型配置不匹配
269
+ // Array type configuration mismatch
270
270
  {
271
271
  code: /* typescript */ `
272
272
  import { Entity, Property } from "@mikro-orm/core";
@@ -288,7 +288,7 @@ tester.run("entity-property-config-from-types", rule, {
288
288
  `,
289
289
  errors: [{ messageId: "alignPropertyDecoratorWithTsType" }],
290
290
  },
291
- // 空的 @Property() 应该添加 type: t.boolean
291
+ // Empty @Property() should add type: t.boolean
292
292
  {
293
293
  code: /* typescript */ `
294
294
  import { Entity, Property } from "@mikro-orm/core";
@@ -310,7 +310,7 @@ tester.run("entity-property-config-from-types", rule, {
310
310
  `,
311
311
  errors: [{ messageId: "alignPropertyDecoratorWithTsType" }],
312
312
  },
313
- // 空的 @Property() 应该添加 type: t.datetimeDate 类型)
313
+ // Empty @Property() should add type: t.datetime (Date type)
314
314
  {
315
315
  code: /* typescript */ `
316
316
  import { Entity, Property } from "@mikro-orm/core";
@@ -332,7 +332,7 @@ tester.run("entity-property-config-from-types", rule, {
332
332
  `,
333
333
  errors: [{ messageId: "alignPropertyDecoratorWithTsType" }],
334
334
  },
335
- // Date 类型配置错误应该修正为 t.datetime
335
+ // Date type with wrong configuration should be fixed to t.datetime
336
336
  {
337
337
  code: /* typescript */ `
338
338
  import { Entity, Property } from "@mikro-orm/core";