@cedarjs/eslint-plugin 6.0.0-canary.2893 → 6.0.0-canary.2895
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-type-annotations.d.ts","sourceRoot":"","sources":["../src/cell-type-annotations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"cell-type-annotations.d.ts","sourceRoot":"","sources":["../src/cell-type-annotations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAA;AAwHlE,eAAO,MAAM,mBAAmB,8GAiZ9B,CAAA"}
|
|
@@ -143,14 +143,12 @@ const cellTypeAnnotations = createRule({
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
function checkAfterQuery(fn, reportNode) {
|
|
146
|
-
const missingReturn = !fn.returnType;
|
|
147
146
|
const firstParam = fn.params[0];
|
|
148
147
|
const missingParam = !!firstParam && !paramHasTypeAnnotation(firstParam);
|
|
149
|
-
if (!
|
|
148
|
+
if (!missingParam) {
|
|
150
149
|
return;
|
|
151
150
|
}
|
|
152
151
|
const shouldImport = needsImportEdit("DataObject");
|
|
153
|
-
const location = missingReturn && missingParam ? "parameter and return type" : missingReturn ? "return type" : "parameter";
|
|
154
152
|
context.report({
|
|
155
153
|
node: reportNode,
|
|
156
154
|
messageId: "needsTypeAnnotation",
|
|
@@ -158,29 +156,21 @@ const cellTypeAnnotations = createRule({
|
|
|
158
156
|
name: "afterQuery",
|
|
159
157
|
typeName: "DataObject",
|
|
160
158
|
kind: "function",
|
|
161
|
-
location
|
|
159
|
+
location: "parameter"
|
|
162
160
|
},
|
|
163
161
|
*fix(fixer) {
|
|
164
162
|
if (firstParam && isUnparenthesizedArrowParam(fn, firstParam, sourceCode)) {
|
|
165
163
|
yield* insertWrappedAnnotations(
|
|
166
164
|
fixer,
|
|
167
165
|
firstParam,
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
"DataObject",
|
|
167
|
+
null
|
|
168
|
+
);
|
|
169
|
+
} else if (firstParam) {
|
|
170
|
+
yield fixer.insertTextAfter(
|
|
171
|
+
getParamPattern(firstParam),
|
|
172
|
+
": DataObject"
|
|
170
173
|
);
|
|
171
|
-
} else {
|
|
172
|
-
if (missingParam && firstParam) {
|
|
173
|
-
yield fixer.insertTextAfter(
|
|
174
|
-
getParamPattern(firstParam),
|
|
175
|
-
": DataObject"
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
if (missingReturn) {
|
|
179
|
-
const closingParen = getParamsClosingParen(sourceCode, fn);
|
|
180
|
-
if (closingParen) {
|
|
181
|
-
yield fixer.insertTextAfter(closingParen, ": DataObject");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
174
|
}
|
|
185
175
|
if (shouldImport) {
|
|
186
176
|
yield* importEdit(fixer, "DataObject");
|
|
@@ -189,24 +179,21 @@ const cellTypeAnnotations = createRule({
|
|
|
189
179
|
});
|
|
190
180
|
}
|
|
191
181
|
function checkIsEmpty(fn, reportNode) {
|
|
192
|
-
const missingReturn = !fn.returnType;
|
|
193
182
|
const [responseParam, optionsParam] = fn.params;
|
|
194
183
|
const missingResponseType = !!responseParam && !paramHasTypeAnnotation(responseParam);
|
|
195
184
|
const missingOptionsType = !!optionsParam && !paramHasTypeAnnotation(optionsParam);
|
|
196
|
-
if (!
|
|
185
|
+
if (!missingResponseType && !missingOptionsType) {
|
|
197
186
|
return;
|
|
198
187
|
}
|
|
199
|
-
const
|
|
200
|
-
const shouldImport = missingParams && needsImportEdit("DataObject");
|
|
201
|
-
const location = missingReturn && missingParams ? "parameters and return type" : missingReturn ? "return type" : "parameters";
|
|
188
|
+
const shouldImport = needsImportEdit("DataObject");
|
|
202
189
|
context.report({
|
|
203
190
|
node: reportNode,
|
|
204
191
|
messageId: "needsTypeAnnotation",
|
|
205
192
|
data: {
|
|
206
193
|
name: "isEmpty",
|
|
207
|
-
typeName:
|
|
194
|
+
typeName: "DataObject",
|
|
208
195
|
kind: "function",
|
|
209
|
-
location
|
|
196
|
+
location: "parameters"
|
|
210
197
|
},
|
|
211
198
|
*fix(fixer) {
|
|
212
199
|
if (responseParam && isUnparenthesizedArrowParam(fn, responseParam, sourceCode)) {
|
|
@@ -214,7 +201,7 @@ const cellTypeAnnotations = createRule({
|
|
|
214
201
|
fixer,
|
|
215
202
|
responseParam,
|
|
216
203
|
missingResponseType ? "DataObject" : null,
|
|
217
|
-
|
|
204
|
+
null
|
|
218
205
|
);
|
|
219
206
|
} else {
|
|
220
207
|
if (missingResponseType && responseParam) {
|
|
@@ -229,12 +216,6 @@ const cellTypeAnnotations = createRule({
|
|
|
229
216
|
": { isDataEmpty: (data: DataObject) => boolean }"
|
|
230
217
|
);
|
|
231
218
|
}
|
|
232
|
-
if (missingReturn) {
|
|
233
|
-
const closingParen = getParamsClosingParen(sourceCode, fn);
|
|
234
|
-
if (closingParen) {
|
|
235
|
-
yield fixer.insertTextAfter(closingParen, ": boolean");
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
219
|
}
|
|
239
220
|
if (shouldImport) {
|
|
240
221
|
yield* importEdit(fixer, "DataObject");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/eslint-plugin",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2895",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"eslint": "8.57.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
30
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2895",
|
|
31
31
|
"@types/eslint": "8.56.12",
|
|
32
32
|
"@types/estree": "1.0.9",
|
|
33
33
|
"@typescript-eslint/parser": "8.60.1",
|