Skip to content

Commit ff1cb29

Browse files
committed
yoyo
1 parent f92a366 commit ff1cb29

File tree

1 file changed

+23
-24
lines changed
  • packages/plugin/src/rules/require-selections

1 file changed

+23
-24
lines changed

packages/plugin/src/rules/require-selections/index.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -218,34 +218,33 @@ export const rule: GraphQLESLintRule<RuleOptions, true> = {
218218
}
219219
}
220220

221-
function hasIdField({ selections }: typeof node, idNames: string[]): boolean {
222-
return selections.some(selection => {
223-
if (selection.kind === Kind.FIELD) {
224-
if (selection.alias && idNames.includes(selection.alias.value)) {
225-
return true;
226-
}
227-
228-
return idNames.includes(selection.name.value);
229-
}
221+
function report(idNames: string[]) {
222+
function hasIdField({ selections }: typeof node): boolean {
223+
return selections.some(selection => {
224+
if (selection.kind === Kind.FIELD) {
225+
if (selection.alias && idNames.includes(selection.alias.value)) {
226+
return true;
227+
}
230228

231-
if (selection.kind === Kind.INLINE_FRAGMENT) {
232-
return hasIdField(selection.selectionSet, idNames);
233-
}
229+
return idNames.includes(selection.name.value);
230+
}
234231

235-
if (selection.kind === Kind.FRAGMENT_SPREAD) {
236-
const [foundSpread] = siblings.getFragment(selection.name.value);
237-
if (foundSpread) {
238-
const fragmentSpread = foundSpread.document;
239-
checkedFragmentSpreads.add(fragmentSpread.name.value);
240-
return hasIdField(fragmentSpread.selectionSet, idNames);
232+
if (selection.kind === Kind.INLINE_FRAGMENT) {
233+
return hasIdField(selection.selectionSet);
241234
}
242-
}
243-
return false;
244-
});
245-
}
246235

247-
function report(idNames: string[]) {
248-
const hasId = hasIdField(node, idNames);
236+
if (selection.kind === Kind.FRAGMENT_SPREAD) {
237+
const [foundSpread] = siblings.getFragment(selection.name.value);
238+
if (foundSpread) {
239+
const fragmentSpread = foundSpread.document;
240+
checkedFragmentSpreads.add(fragmentSpread.name.value);
241+
return hasIdField(fragmentSpread.selectionSet);
242+
}
243+
}
244+
return false;
245+
});
246+
}
247+
const hasId = hasIdField(node);
249248
if (hasId) {
250249
return;
251250
}

0 commit comments

Comments
 (0)