Skip to content

Commit 7badcf6

Browse files
authored
DRY in lone-executable-definition rule (#1325)
1 parent d5ac377 commit 7badcf6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/plugin/src/rules/lone-executable-definition.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import { FromSchema } from 'json-schema-to-ts';
66

77
const RULE_ID = 'lone-executable-definition';
88

9-
type Definition = 'fragment' | 'query' | 'mutation' | 'subscription';
9+
const definitionTypes = ['fragment', 'query', 'mutation', 'subscription'] as const;
1010

11+
type Definition = (typeof definitionTypes)[number];
1112
type DefinitionESTreeNode = GraphQLESTreeNode<ExecutableDefinitionNode>;
1213

1314
const schema = {
@@ -22,7 +23,7 @@ const schema = {
2223
...ARRAY_DEFAULT_OPTIONS,
2324
maxItems: 3, // ignore all 4 types is redundant
2425
items: {
25-
enum: ['fragment', 'query', 'mutation', 'subscription'],
26+
enum: definitionTypes,
2627
},
2728
description: 'Allow certain definitions to be placed alongside others.',
2829
},

0 commit comments

Comments
 (0)