@nest-boot/eslint-plugin 7.0.0-beta.0 → 7.0.0-beta.2
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.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +2 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/rules/graphql/graphql-field-config-from-types.d.ts +6 -0
- package/dist/rules/graphql/graphql-field-config-from-types.js +417 -0
- package/dist/rules/graphql/graphql-field-config-from-types.js.map +1 -0
- package/dist/rules/graphql/graphql-field-definite-assignment.d.ts +2 -0
- package/dist/rules/graphql/graphql-field-definite-assignment.js +125 -0
- package/dist/rules/graphql/graphql-field-definite-assignment.js.map +1 -0
- package/dist/rules/import/import-bullmq.d.ts +2 -0
- package/dist/rules/import/import-bullmq.js +36 -0
- package/dist/rules/import/import-bullmq.js.map +1 -0
- package/dist/rules/import/import-graphql.d.ts +2 -0
- package/dist/rules/import/import-graphql.js +36 -0
- package/dist/rules/import/import-graphql.js.map +1 -0
- package/dist/rules/import/import-mikro-orm.d.ts +2 -0
- package/dist/rules/import/import-mikro-orm.js +36 -0
- package/dist/rules/import/import-mikro-orm.js.map +1 -0
- package/dist/rules/index.d.ts +9 -0
- package/dist/rules/index.js +16 -11
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/mikro-orm/entity-field-definite-assignment.d.ts +2 -0
- package/dist/rules/mikro-orm/entity-field-definite-assignment.js +125 -0
- package/dist/rules/mikro-orm/entity-field-definite-assignment.js.map +1 -0
- package/dist/rules/mikro-orm/entity-property-config-from-types.d.ts +3 -0
- package/dist/rules/mikro-orm/entity-property-config-from-types.js +881 -0
- package/dist/rules/mikro-orm/entity-property-config-from-types.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utils/createRule.d.ts +2 -0
- package/dist/utils/createRule.js +1 -1
- package/dist/utils/createRule.js.map +1 -1
- package/dist/utils/decorators.d.ts +29 -0
- package/dist/utils/decorators.js +74 -0
- package/dist/utils/decorators.js.map +1 -0
- package/dist/utils/tester.d.ts +2 -0
- package/dist/utils/tester.js +27 -0
- package/dist/utils/tester.js.map +1 -0
- package/eslint.config.mjs +38 -2
- package/jest.config.ts +12 -0
- package/package.json +22 -14
- package/src/index.ts +1 -1
- package/src/rules/graphql/graphql-field-config-from-types.spec.ts +242 -0
- package/src/rules/graphql/graphql-field-config-from-types.ts +557 -0
- package/src/rules/graphql/graphql-field-definite-assignment.spec.ts +135 -0
- package/src/rules/graphql/graphql-field-definite-assignment.ts +147 -0
- package/src/rules/import/import-bullmq.spec.ts +69 -0
- package/src/rules/import/import-bullmq.ts +35 -0
- package/src/rules/import/import-graphql.spec.ts +65 -0
- package/src/rules/import/import-graphql.ts +36 -0
- package/src/rules/import/import-mikro-orm.spec.ts +65 -0
- package/src/rules/import/import-mikro-orm.ts +36 -0
- package/src/rules/index.ts +15 -13
- package/src/rules/mikro-orm/entity-field-definite-assignment.spec.ts +91 -0
- package/src/rules/mikro-orm/entity-field-definite-assignment.ts +141 -0
- package/src/rules/mikro-orm/entity-property-config-from-types.spec.ts +262 -0
- package/src/rules/mikro-orm/entity-property-config-from-types.ts +1111 -0
- package/src/utils/createRule.ts +3 -1
- package/src/utils/decorators.spec.ts +214 -0
- package/src/utils/decorators.ts +93 -0
- package/src/utils/tester.ts +22 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +6 -7
- package/dist/rules/entity-constructor.js +0 -78
- package/dist/rules/entity-constructor.js.map +0 -1
- package/dist/rules/entity-property-no-optional-or-non-null-assertion.js +0 -63
- package/dist/rules/entity-property-no-optional-or-non-null-assertion.js.map +0 -1
- package/dist/rules/entity-property-nullable.js +0 -81
- package/dist/rules/entity-property-nullable.js.map +0 -1
- package/dist/rules/graphql-field-arguments-match-property-type.js +0 -118
- package/dist/rules/graphql-field-arguments-match-property-type.js.map +0 -1
- package/dist/rules/graphql-resolver-method-return-type.js +0 -145
- package/dist/rules/graphql-resolver-method-return-type.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/rules/entity-constructor.ts +0 -97
- package/src/rules/entity-property-no-optional-or-non-null-assertion.ts +0 -81
- package/src/rules/entity-property-nullable.ts +0 -112
- package/src/rules/graphql-field-arguments-match-property-type.ts +0 -186
- package/src/rules/graphql-resolver-method-return-type.ts +0 -207
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
# @nest-boot/eslint-plugin
|
|
2
2
|
|
|
3
|
-
## 7.0.0-beta.
|
|
4
|
-
|
|
5
|
-
### Major Changes
|
|
6
|
-
|
|
7
|
-
- 14895ac: ESLint 升级到 v9
|
|
8
|
-
|
|
9
|
-
## 6.10.2
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- bcd62cb: fix: Update dependencies across multiple packages to latest versions.
|
|
14
|
-
|
|
15
|
-
## 6.10.1
|
|
3
|
+
## 7.0.0-beta.2
|
|
16
4
|
|
|
17
5
|
### Patch Changes
|
|
18
6
|
|
|
19
|
-
-
|
|
7
|
+
- 20f3262: fix: 重构 eslint-plugin 和移除 queue 模块
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.rules = void 0;
|
|
7
|
-
const rules_1 =
|
|
8
|
-
exports
|
|
4
|
+
const rules_1 = require("./rules");
|
|
5
|
+
Object.defineProperty(exports, "rules", { enumerable: true, get: function () { return rules_1.rules; } });
|
|
9
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEvB,sFAFA,aAAK,OAEA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type DecoratorBehavior = "ignore" | "remove";
|
|
2
|
+
export interface Options {
|
|
3
|
+
decorators?: Record<string, DecoratorBehavior>;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"alignFieldDecoratorWithTsType" | "removeFieldDecorator", [Options], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
const createRule_1 = require("../../utils/createRule");
|
|
5
|
+
const decorators_1 = require("../../utils/decorators");
|
|
6
|
+
exports.default = (0, createRule_1.createRule)({
|
|
7
|
+
name: "graphql-field-config-from-types",
|
|
8
|
+
meta: {
|
|
9
|
+
type: "problem",
|
|
10
|
+
docs: {
|
|
11
|
+
description: "根据 TypeScript 类型自动生成或修正 @Field 装饰器的类型与 nullable 配置(支持数组)。",
|
|
12
|
+
},
|
|
13
|
+
fixable: "code",
|
|
14
|
+
schema: [
|
|
15
|
+
{
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
decorators: {
|
|
19
|
+
type: "object",
|
|
20
|
+
additionalProperties: {
|
|
21
|
+
type: "string",
|
|
22
|
+
enum: ["ignore", "remove"],
|
|
23
|
+
},
|
|
24
|
+
description: "配置每个装饰器的行为。ignore: 跳过检查;remove: 移除 @Field。默认:{ HideField: 'remove', OneToOne: 'remove', OneToMany: 'remove', ManyToOne: 'remove', ManyToMany: 'remove' }",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
messages: {
|
|
31
|
+
alignFieldDecoratorWithTsType: "@Field 装饰器应与 TypeScript 类型保持一致(类型与 nullable)。",
|
|
32
|
+
removeFieldDecorator: "属性带有 @{{decoratorName}} 装饰器,应移除 @Field 装饰器。",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
defaultOptions: [
|
|
36
|
+
{
|
|
37
|
+
decorators: {
|
|
38
|
+
HideField: "remove",
|
|
39
|
+
OneToOne: "remove",
|
|
40
|
+
OneToMany: "remove",
|
|
41
|
+
ManyToOne: "remove",
|
|
42
|
+
ManyToMany: "remove",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
create(context, [options]) {
|
|
47
|
+
const source = context.sourceCode;
|
|
48
|
+
const scalarFromTsKeyword = (typeNodeType) => {
|
|
49
|
+
switch (typeNodeType) {
|
|
50
|
+
case utils_1.AST_NODE_TYPES.TSBooleanKeyword:
|
|
51
|
+
return "Boolean";
|
|
52
|
+
case utils_1.AST_NODE_TYPES.TSStringKeyword:
|
|
53
|
+
return "String";
|
|
54
|
+
case utils_1.AST_NODE_TYPES.TSNumberKeyword:
|
|
55
|
+
// 默认 number → Float(GraphQL 默认也是 Float;Int 需显式声明)
|
|
56
|
+
return "Float";
|
|
57
|
+
default:
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const getIdentifierName = (node) => {
|
|
62
|
+
if (node.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
|
|
63
|
+
node.typeName.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
64
|
+
return node.typeName.name;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
};
|
|
68
|
+
const extractArrayElementType = (node) => {
|
|
69
|
+
if (node.type === utils_1.AST_NODE_TYPES.TSArrayType) {
|
|
70
|
+
return node.elementType;
|
|
71
|
+
}
|
|
72
|
+
if (node.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
|
|
73
|
+
node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
74
|
+
node.typeName.name === "Array") {
|
|
75
|
+
return node.typeArguments?.params[0] ?? null;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
const computeTypeInfo = (property) => {
|
|
80
|
+
let isNullable = false;
|
|
81
|
+
let isArray = false;
|
|
82
|
+
let baseTypeNode = property.typeAnnotation?.type === utils_1.AST_NODE_TYPES.TSTypeAnnotation
|
|
83
|
+
? property.typeAnnotation.typeAnnotation
|
|
84
|
+
: null;
|
|
85
|
+
// 可选属性(?)视为可空
|
|
86
|
+
if (property.optional) {
|
|
87
|
+
isNullable = true;
|
|
88
|
+
}
|
|
89
|
+
// 处理联合类型中的 null/undefined
|
|
90
|
+
if (baseTypeNode?.type === utils_1.AST_NODE_TYPES.TSUnionType) {
|
|
91
|
+
const hasNullish = baseTypeNode.types.some((t) => {
|
|
92
|
+
return (t.type === utils_1.AST_NODE_TYPES.TSNullKeyword ||
|
|
93
|
+
t.type === utils_1.AST_NODE_TYPES.TSUndefinedKeyword);
|
|
94
|
+
});
|
|
95
|
+
if (hasNullish)
|
|
96
|
+
isNullable = true;
|
|
97
|
+
baseTypeNode =
|
|
98
|
+
baseTypeNode.types.find((t) => {
|
|
99
|
+
return (t.type !== utils_1.AST_NODE_TYPES.TSNullKeyword &&
|
|
100
|
+
t.type !== utils_1.AST_NODE_TYPES.TSUndefinedKeyword);
|
|
101
|
+
}) ?? null;
|
|
102
|
+
}
|
|
103
|
+
// 先解包 Ref<T> 和 Opt<T> → T,并在内部再次处理 null/undefined
|
|
104
|
+
if (baseTypeNode?.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
|
|
105
|
+
baseTypeNode.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
106
|
+
(baseTypeNode.typeName.name === "Ref" ||
|
|
107
|
+
baseTypeNode.typeName.name === "Opt")) {
|
|
108
|
+
let inner = baseTypeNode.typeArguments?.params[0] ?? null;
|
|
109
|
+
if (inner && inner.type === utils_1.AST_NODE_TYPES.TSUnionType) {
|
|
110
|
+
const hasNullish = inner.types.some((t) => {
|
|
111
|
+
return (t.type === utils_1.AST_NODE_TYPES.TSNullKeyword ||
|
|
112
|
+
t.type === utils_1.AST_NODE_TYPES.TSUndefinedKeyword);
|
|
113
|
+
});
|
|
114
|
+
if (hasNullish)
|
|
115
|
+
isNullable = true;
|
|
116
|
+
inner =
|
|
117
|
+
inner.types.find((t) => {
|
|
118
|
+
return (t.type !== utils_1.AST_NODE_TYPES.TSNullKeyword &&
|
|
119
|
+
t.type !== utils_1.AST_NODE_TYPES.TSUndefinedKeyword);
|
|
120
|
+
}) ?? inner;
|
|
121
|
+
}
|
|
122
|
+
baseTypeNode = inner ?? baseTypeNode;
|
|
123
|
+
}
|
|
124
|
+
// 数组类型(T[] 或 Array<T>)- 在解包 Opt/Ref 之后检查
|
|
125
|
+
const elementTypeNode = baseTypeNode
|
|
126
|
+
? extractArrayElementType(baseTypeNode)
|
|
127
|
+
: null;
|
|
128
|
+
if (elementTypeNode) {
|
|
129
|
+
isArray = true;
|
|
130
|
+
}
|
|
131
|
+
const targetTypeNode = elementTypeNode ?? baseTypeNode;
|
|
132
|
+
// 无显式类型时,尝试从字面量初始值推断
|
|
133
|
+
if (!targetTypeNode) {
|
|
134
|
+
if (property.value?.type === utils_1.AST_NODE_TYPES.Literal) {
|
|
135
|
+
const value = property.value.value;
|
|
136
|
+
const typeOf = typeof value;
|
|
137
|
+
if (typeOf === "boolean")
|
|
138
|
+
return { typeName: "Boolean", isArray, isNullable };
|
|
139
|
+
if (typeOf === "number")
|
|
140
|
+
return { typeName: "Float", isArray, isNullable };
|
|
141
|
+
if (typeOf === "string")
|
|
142
|
+
return { typeName: "String", isArray, isNullable };
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
// id 字段优先使用 GraphQL 标量 ID
|
|
147
|
+
const propertyName = property.key.type === utils_1.AST_NODE_TYPES.Identifier
|
|
148
|
+
? property.key.name
|
|
149
|
+
: null;
|
|
150
|
+
if (propertyName === "id" ||
|
|
151
|
+
(typeof propertyName === "string" &&
|
|
152
|
+
(propertyName.endsWith("Id") || propertyName.endsWith("ID")))) {
|
|
153
|
+
return { typeName: "ID", isArray, isNullable };
|
|
154
|
+
}
|
|
155
|
+
// Record<*, *> → GraphQLJSONObject(不限制键值类型)
|
|
156
|
+
if (targetTypeNode.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
|
|
157
|
+
targetTypeNode.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
158
|
+
targetTypeNode.typeName.name === "Record") {
|
|
159
|
+
return { typeName: "GraphQLJSONObject", isArray, isNullable };
|
|
160
|
+
}
|
|
161
|
+
// 关键字类型 → GraphQL 标量
|
|
162
|
+
const scalar = scalarFromTsKeyword(targetTypeNode.type);
|
|
163
|
+
if (scalar) {
|
|
164
|
+
return { typeName: scalar, isArray, isNullable };
|
|
165
|
+
}
|
|
166
|
+
// 标识符(类/自定义类型)
|
|
167
|
+
const ident = getIdentifierName(targetTypeNode);
|
|
168
|
+
if (ident) {
|
|
169
|
+
return { typeName: ident, isArray, isNullable };
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
};
|
|
173
|
+
const ensureScalarImport = (fixes, expected) => {
|
|
174
|
+
if (["Int", "Float", "ID"].includes(expected)) {
|
|
175
|
+
if (!context.sourceCode.text.includes(`import { ${expected} } from "@nestjs/graphql"`)) {
|
|
176
|
+
fixes.push({
|
|
177
|
+
type: "insert",
|
|
178
|
+
range: [0, 0],
|
|
179
|
+
text: `import { ${expected} } from "@nestjs/graphql";\n`,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const ensureJSONObjectImport = (fixes) => {
|
|
185
|
+
const hasImport = context.sourceCode.text.includes(`from "graphql-type-json"`) &&
|
|
186
|
+
context.sourceCode.text.includes("GraphQLJSONObject");
|
|
187
|
+
if (!hasImport) {
|
|
188
|
+
fixes.push({
|
|
189
|
+
type: "insert",
|
|
190
|
+
range: [0, 0],
|
|
191
|
+
text: `import { GraphQLJSONObject } from "graphql-type-json";\n`,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const addFieldDecorator = (property, info) => {
|
|
196
|
+
const fixes = [];
|
|
197
|
+
const typeName = info.typeName ?? "";
|
|
198
|
+
const typeExpr = info.isArray
|
|
199
|
+
? `() => [${typeName}]`
|
|
200
|
+
: `() => ${typeName}`;
|
|
201
|
+
const optionsExpr = info.isNullable ? ", { nullable: true }" : "";
|
|
202
|
+
const newDecoratorText = `@Field(${typeExpr}${optionsExpr})`;
|
|
203
|
+
ensureScalarImport(fixes, info.typeName ?? "");
|
|
204
|
+
if (info.typeName === "GraphQLJSONObject") {
|
|
205
|
+
ensureJSONObjectImport(fixes);
|
|
206
|
+
}
|
|
207
|
+
fixes.push({
|
|
208
|
+
type: "insert",
|
|
209
|
+
range: property.range,
|
|
210
|
+
text: newDecoratorText + "\n ",
|
|
211
|
+
});
|
|
212
|
+
return fixes;
|
|
213
|
+
};
|
|
214
|
+
const fixWithTypeInfo = (property, fieldDecorator, info) => {
|
|
215
|
+
const fixes = [];
|
|
216
|
+
const typeName = info.typeName ?? "";
|
|
217
|
+
const typeExpr = info.isArray
|
|
218
|
+
? `() => [${typeName}]`
|
|
219
|
+
: `() => ${typeName}`;
|
|
220
|
+
// 提取现有的配置选项(除了 nullable)
|
|
221
|
+
const callExpr = fieldDecorator.expression;
|
|
222
|
+
const existingOptions = [];
|
|
223
|
+
// 检查是否有现有的配置对象
|
|
224
|
+
let optionsArg = null;
|
|
225
|
+
if (callExpr.type === utils_1.AST_NODE_TYPES.CallExpression &&
|
|
226
|
+
callExpr.arguments.length > 0) {
|
|
227
|
+
// 如果第一个参数是对象表达式(没有 type function)
|
|
228
|
+
if (callExpr.arguments[0] &&
|
|
229
|
+
callExpr.arguments[0].type === utils_1.AST_NODE_TYPES.ObjectExpression) {
|
|
230
|
+
optionsArg = callExpr.arguments[0];
|
|
231
|
+
}
|
|
232
|
+
// 如果第二个参数是对象表达式(有 type function)
|
|
233
|
+
else if (callExpr.arguments[1] &&
|
|
234
|
+
callExpr.arguments[1].type === utils_1.AST_NODE_TYPES.ObjectExpression) {
|
|
235
|
+
optionsArg = callExpr.arguments[1];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// 提取现有选项,同时处理 nullable
|
|
239
|
+
let hasNullableProperty = false;
|
|
240
|
+
if (optionsArg) {
|
|
241
|
+
optionsArg.properties.forEach((prop) => {
|
|
242
|
+
// 处理展开运算符 (SpreadElement)
|
|
243
|
+
if (prop.type === utils_1.AST_NODE_TYPES.SpreadElement) {
|
|
244
|
+
const propText = source.getText(prop);
|
|
245
|
+
existingOptions.push(propText);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
// 处理普通属性 (Property)
|
|
249
|
+
if (prop.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
250
|
+
prop.key.name === "nullable") {
|
|
251
|
+
hasNullableProperty = true;
|
|
252
|
+
// 根据类型决定是否保留或更新 nullable
|
|
253
|
+
if (info.isNullable) {
|
|
254
|
+
existingOptions.push("nullable: true");
|
|
255
|
+
}
|
|
256
|
+
// 如果不需要 nullable,则跳过(不保留)
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// 保留原有的其他配置
|
|
260
|
+
const propText = source.getText(prop);
|
|
261
|
+
existingOptions.push(propText);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
// 如果需要 nullable 但原配置中没有,则添加到最前面
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
267
|
+
if (info.isNullable && !hasNullableProperty) {
|
|
268
|
+
existingOptions.unshift("nullable: true");
|
|
269
|
+
}
|
|
270
|
+
// 构建新的装饰器文本
|
|
271
|
+
const optionsExpr = existingOptions.length > 0 ? `, { ${existingOptions.join(", ")} }` : "";
|
|
272
|
+
const newDecoratorText = `@Field(${typeExpr}${optionsExpr})`;
|
|
273
|
+
ensureScalarImport(fixes, info.typeName ?? "");
|
|
274
|
+
if (info.typeName === "GraphQLJSONObject") {
|
|
275
|
+
ensureJSONObjectImport(fixes);
|
|
276
|
+
}
|
|
277
|
+
fixes.push({
|
|
278
|
+
type: "replace",
|
|
279
|
+
range: fieldDecorator.range,
|
|
280
|
+
text: newDecoratorText,
|
|
281
|
+
});
|
|
282
|
+
return fixes;
|
|
283
|
+
};
|
|
284
|
+
const applyFixes = (fixer, fixes) => {
|
|
285
|
+
return fixes.map((fix) => {
|
|
286
|
+
if (fix.type === "replace") {
|
|
287
|
+
return fixer.replaceTextRange(fix.range, fix.text);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
return fixer.insertTextBeforeRange(fix.range, fix.text);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
const isGraphqlModelClass = (node) => {
|
|
295
|
+
return (0, decorators_1.hasClassDecorator)(node, ["ObjectType", "InputType", "ArgsType"]);
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
ClassDeclaration(node) {
|
|
299
|
+
if (!isGraphqlModelClass(node))
|
|
300
|
+
return;
|
|
301
|
+
node.body.body.forEach((member) => {
|
|
302
|
+
if (member.type !== utils_1.AST_NODE_TYPES.PropertyDefinition)
|
|
303
|
+
return;
|
|
304
|
+
const decoratorConfig = options.decorators ?? {
|
|
305
|
+
HideField: "remove",
|
|
306
|
+
OneToOne: "remove",
|
|
307
|
+
OneToMany: "remove",
|
|
308
|
+
ManyToOne: "remove",
|
|
309
|
+
ManyToMany: "remove",
|
|
310
|
+
};
|
|
311
|
+
// 检查是否有配置的装饰器
|
|
312
|
+
let foundDecoratorName = null;
|
|
313
|
+
let foundBehavior = null;
|
|
314
|
+
for (const decorator of member.decorators) {
|
|
315
|
+
if (decorator.expression.type === utils_1.AST_NODE_TYPES.CallExpression &&
|
|
316
|
+
decorator.expression.callee.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
317
|
+
const decoratorName = decorator.expression.callee.name;
|
|
318
|
+
if (decoratorName in decoratorConfig) {
|
|
319
|
+
foundDecoratorName = decoratorName;
|
|
320
|
+
foundBehavior = decoratorConfig[decoratorName];
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
// 如果是 ignore 行为,直接跳过
|
|
326
|
+
if (foundBehavior === "ignore")
|
|
327
|
+
return;
|
|
328
|
+
const fieldDecorator = (0, decorators_1.getPropertyDecorator)(member, "Field");
|
|
329
|
+
// 如果是 remove 行为且有 @Field,则移除 @Field
|
|
330
|
+
if (foundBehavior === "remove" && fieldDecorator) {
|
|
331
|
+
context.report({
|
|
332
|
+
node: fieldDecorator,
|
|
333
|
+
messageId: "removeFieldDecorator",
|
|
334
|
+
data: {
|
|
335
|
+
decoratorName: foundDecoratorName ?? "unknown",
|
|
336
|
+
},
|
|
337
|
+
fix: (fixer) => {
|
|
338
|
+
// 移除整个装饰器行(包括换行)
|
|
339
|
+
const decoratorStart = fieldDecorator.range[0];
|
|
340
|
+
const decoratorEnd = fieldDecorator.range[1];
|
|
341
|
+
// 查找装饰器后的换行符和空格
|
|
342
|
+
const textAfter = source.text.slice(decoratorEnd, decoratorEnd + 10);
|
|
343
|
+
const matchNewline = /^(\r?\n\s*)/.exec(textAfter);
|
|
344
|
+
const endPos = matchNewline
|
|
345
|
+
? decoratorEnd + matchNewline[0].length
|
|
346
|
+
: decoratorEnd;
|
|
347
|
+
return fixer.removeRange([decoratorStart, endPos]);
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
// 如果是 remove 行为但没有 @Field,跳过
|
|
353
|
+
if (foundBehavior === "remove")
|
|
354
|
+
return;
|
|
355
|
+
const typeInfo = computeTypeInfo(member);
|
|
356
|
+
if (!typeInfo?.typeName)
|
|
357
|
+
return;
|
|
358
|
+
// 如果没有 @Field 装饰器,添加它
|
|
359
|
+
if (!fieldDecorator) {
|
|
360
|
+
context.report({
|
|
361
|
+
node: member,
|
|
362
|
+
messageId: "alignFieldDecoratorWithTsType",
|
|
363
|
+
fix: (fixer) => {
|
|
364
|
+
const fixes = addFieldDecorator(member, typeInfo);
|
|
365
|
+
return applyFixes(fixer, fixes);
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
// 若已有 ArrowFunction 但与期望不一致,也进行修正
|
|
371
|
+
const callExpr = fieldDecorator.expression;
|
|
372
|
+
if (callExpr.type !== utils_1.AST_NODE_TYPES.CallExpression)
|
|
373
|
+
return;
|
|
374
|
+
let needReport = true;
|
|
375
|
+
if (callExpr.arguments.length > 0 &&
|
|
376
|
+
callExpr.arguments[0].type ===
|
|
377
|
+
utils_1.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
378
|
+
const firstArg = callExpr.arguments[0];
|
|
379
|
+
const calleeText = source.getText(firstArg.body);
|
|
380
|
+
const expectedTypeText = typeInfo.isArray
|
|
381
|
+
? `[${typeInfo.typeName}]`
|
|
382
|
+
: typeInfo.typeName;
|
|
383
|
+
const hasNullableOption = callExpr.arguments.length > 1 &&
|
|
384
|
+
callExpr.arguments[1].type === utils_1.AST_NODE_TYPES.ObjectExpression &&
|
|
385
|
+
callExpr.arguments[1].properties.some((prop) => {
|
|
386
|
+
return (prop.type === utils_1.AST_NODE_TYPES.Property &&
|
|
387
|
+
prop.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
388
|
+
prop.key.name === "nullable" &&
|
|
389
|
+
prop.value.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
390
|
+
prop.value.value === true);
|
|
391
|
+
});
|
|
392
|
+
// 对于 number 类型,Int 和 Float 都是合法的
|
|
393
|
+
const isNumberType = typeInfo.typeName === "Float";
|
|
394
|
+
const actualTypeText = calleeText.replace(/^\[|\]$/g, ""); // 移除数组括号
|
|
395
|
+
const isValidNumberType = isNumberType &&
|
|
396
|
+
(actualTypeText === "Int" || actualTypeText === "Float");
|
|
397
|
+
const typeMatches = calleeText === expectedTypeText || isValidNumberType;
|
|
398
|
+
if (typeMatches && hasNullableOption === typeInfo.isNullable) {
|
|
399
|
+
needReport = false;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (!needReport)
|
|
403
|
+
return;
|
|
404
|
+
context.report({
|
|
405
|
+
node: member,
|
|
406
|
+
messageId: "alignFieldDecoratorWithTsType",
|
|
407
|
+
fix: (fixer) => {
|
|
408
|
+
const fixes = fixWithTypeInfo(member, fieldDecorator, typeInfo);
|
|
409
|
+
return applyFixes(fixer, fixes);
|
|
410
|
+
},
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
//# sourceMappingURL=graphql-field-config-from-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-field-config-from-types.js","sourceRoot":"","sources":["../../../src/rules/graphql/graphql-field-config-from-types.ts"],"names":[],"mappings":";;AAAA,oDAAoE;AAGpE,uDAAoD;AACpD,uDAGgC;AAqBhC,kBAAe,IAAA,uBAAU,EAGvB;IACA,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,2DAA2D;SAC9D;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,UAAU,EAAE;wBACV,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE;4BACpB,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;yBAC3B;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AAI,iBAAiB,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;4BAC7D,UAAU,GAAG,KAAK,CAAC;wBACrB,CAAC;oBACH,CAAC;oBAED,IAAI,CAAC,UAAU;wBAAE,OAAO;oBAExB,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,MAAM;wBACZ,SAAS,EAAE,+BAA+B;wBAC1C,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;4BACb,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;4BAChE,OAAO,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;wBAClC,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
const createRule_1 = require("../../utils/createRule");
|
|
5
|
+
const decorators_1 = require("../../utils/decorators");
|
|
6
|
+
exports.default = (0, createRule_1.createRule)({
|
|
7
|
+
name: "graphql-field-definite-assignment",
|
|
8
|
+
meta: {
|
|
9
|
+
type: "problem",
|
|
10
|
+
docs: {
|
|
11
|
+
description: "确保 GraphQL @Field 装饰器的属性正确使用 definite assignment assertion (!)。没有初始化值的属性应添加 !,有初始化值的属性应移除 !。",
|
|
12
|
+
},
|
|
13
|
+
fixable: "code",
|
|
14
|
+
schema: [],
|
|
15
|
+
messages: {
|
|
16
|
+
addDefiniteAssignment: "属性 '{{propertyName}}' 使用了 @Field 装饰器但没有初始化值,应添加 definite assignment assertion (!)。",
|
|
17
|
+
removeDefiniteAssignment: "属性 '{{propertyName}}' 使用了 @Field 装饰器且有初始化值,应移除 definite assignment assertion (!)。",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultOptions: [],
|
|
21
|
+
create(context) {
|
|
22
|
+
const source = context.sourceCode;
|
|
23
|
+
const isGraphqlModelClass = (node) => {
|
|
24
|
+
return (0, decorators_1.hasClassDecorator)(node, ["ObjectType", "InputType", "ArgsType"]);
|
|
25
|
+
};
|
|
26
|
+
const getPropertyName = (member) => {
|
|
27
|
+
if (member.key.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
28
|
+
return member.key.name;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
const hasInitializer = (member) => {
|
|
33
|
+
return !!member.value;
|
|
34
|
+
};
|
|
35
|
+
const hasDefiniteAssignment = (member) => {
|
|
36
|
+
return member.definite;
|
|
37
|
+
};
|
|
38
|
+
const isOptionalProperty = (member) => {
|
|
39
|
+
// 检查 AST 节点的 optional 标记
|
|
40
|
+
if (member.optional)
|
|
41
|
+
return true;
|
|
42
|
+
// 检查源代码中是否有 ? 符号(在属性名和冒号之间)
|
|
43
|
+
const keyEnd = member.key.range[1];
|
|
44
|
+
const text = source.text;
|
|
45
|
+
for (let i = keyEnd; i < member.range[1]; i++) {
|
|
46
|
+
if (text[i] === "?")
|
|
47
|
+
return true;
|
|
48
|
+
if (text[i] === ":" || text[i] === "!")
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
ClassDeclaration(node) {
|
|
55
|
+
if (!isGraphqlModelClass(node))
|
|
56
|
+
return;
|
|
57
|
+
node.body.body.forEach((member) => {
|
|
58
|
+
if (member.type !== utils_1.AST_NODE_TYPES.PropertyDefinition)
|
|
59
|
+
return;
|
|
60
|
+
if (!(0, decorators_1.hasPropertyDecorator)(member, "Field"))
|
|
61
|
+
return;
|
|
62
|
+
const propertyName = getPropertyName(member);
|
|
63
|
+
if (!propertyName)
|
|
64
|
+
return;
|
|
65
|
+
// 可选属性(?:)不需要 definite assignment assertion
|
|
66
|
+
if (isOptionalProperty(member))
|
|
67
|
+
return;
|
|
68
|
+
const hasInit = hasInitializer(member);
|
|
69
|
+
const hasDefinite = hasDefiniteAssignment(member);
|
|
70
|
+
// 情况1: 没有初始化值,但也没有 definite assignment assertion
|
|
71
|
+
if (!hasInit && !hasDefinite) {
|
|
72
|
+
context.report({
|
|
73
|
+
node: member,
|
|
74
|
+
messageId: "addDefiniteAssignment",
|
|
75
|
+
data: {
|
|
76
|
+
propertyName,
|
|
77
|
+
},
|
|
78
|
+
fix: (fixer) => {
|
|
79
|
+
// 找到属性名称的结束位置
|
|
80
|
+
const keyEnd = member.key.range[1];
|
|
81
|
+
// 在属性名称后添加 !
|
|
82
|
+
return fixer.insertTextAfterRange([keyEnd, keyEnd], "!");
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// 情况2: 有初始化值,但也有 definite assignment assertion
|
|
87
|
+
if (hasInit && hasDefinite) {
|
|
88
|
+
context.report({
|
|
89
|
+
node: member,
|
|
90
|
+
messageId: "removeDefiniteAssignment",
|
|
91
|
+
data: {
|
|
92
|
+
propertyName,
|
|
93
|
+
},
|
|
94
|
+
fix: (fixer) => {
|
|
95
|
+
// 找到 ! 的位置并移除
|
|
96
|
+
const keyEnd = member.key.range[1];
|
|
97
|
+
const text = source.text;
|
|
98
|
+
// 查找 ! 的位置(在属性名称和冒号之间)
|
|
99
|
+
let exclamationPos = -1;
|
|
100
|
+
for (let i = keyEnd; i < member.range[1]; i++) {
|
|
101
|
+
if (text[i] === "!") {
|
|
102
|
+
exclamationPos = i;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
// 如果遇到冒号,说明没有 !
|
|
106
|
+
if (text[i] === ":") {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (exclamationPos !== -1) {
|
|
111
|
+
return fixer.removeRange([
|
|
112
|
+
exclamationPos,
|
|
113
|
+
exclamationPos + 1,
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=graphql-field-definite-assignment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-field-definite-assignment.js","sourceRoot":"","sources":["../../../src/rules/graphql/graphql-field-definite-assignment.ts"],"names":[],"mappings":";;AAAA,oDAAoE;AAEpE,uDAAoD;AACpD,uDAGgC;AAEhC,kBAAe,IAAA,uBAAU,EAGvB;IACA,IAAI,EAAE,mCAAmC;IACzC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8FAA8F;SACjG;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,qBAAqB,EACnB,oFAAoF;YACtF,wBAAwB,EACtB,mFAAmF;SACtF;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;QAElC,MAAM,mBAAmB,GAAG,CAAC,IAA+B,EAAW,EAAE;YACvE,OAAO,IAAA,8BAAiB,EAAC,IAAI,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,CACtB,MAAmC,EACpB,EAAE;YACjB,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU,EAAE,CAAC;gBAClD,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;YACzB,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEF,MAAM,cAAc,GAAG,CAAC,MAAmC,EAAW,EAAE;YACtE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACxB,CAAC,CAAC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