@@ -3,12 +3,13 @@ import { getRootTypeNames } from '@graphql-tools/utils';
33import { GraphQLESTreeNode } from '../../estree-converter/index.js' ;
44import { GraphQLESLintRule , ValueOf } from '../../types.js' ;
55import {
6- ARRAY_DEFAULT_OPTIONS , eslintSelectorsTip ,
6+ ARRAY_DEFAULT_OPTIONS ,
7+ eslintSelectorsTip ,
78 getLocation ,
89 getNodeName ,
910 requireGraphQLSchema ,
10- TYPES_KINDS
11- } from " ../../utils.js" ;
11+ TYPES_KINDS ,
12+ } from ' ../../utils.js' ;
1213
1314export const RULE_ID = 'require-description' ;
1415
@@ -46,15 +47,21 @@ const schema = {
4647 } ,
4748 ignoredSelectors : {
4849 ...ARRAY_DEFAULT_OPTIONS ,
49- description : [ 'Ignore specific selectors' , eslintSelectorsTip ] . join ( '\n' )
50+ description : [ 'Ignore specific selectors' , eslintSelectorsTip ] . join ( '\n' ) ,
5051 } ,
5152 ...Object . fromEntries (
5253 [ ...ALLOWED_KINDS ] . sort ( ) . map ( kind => {
5354 let description = `> [!NOTE]
5455>
5556> Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${ kind } ).` ;
5657 if ( kind === Kind . OPERATION_DEFINITION ) {
57- description += [ '' , '' , '> [!WARNING]' , '>' , '> You must use only comment syntax `#` and not description syntax `"""` or `"`.' ] . join ( '\n' )
58+ description += [
59+ '' ,
60+ '' ,
61+ '> [!WARNING]' ,
62+ '>' ,
63+ '> You must use only comment syntax `#` and not description syntax `"""` or `"`.' ,
64+ ] . join ( '\n' ) ;
5865 }
5966 return [ kind , { type : 'boolean' , description } ] ;
6067 } ) ,
@@ -129,6 +136,33 @@ export const rule: GraphQLESLintRule<RuleOptions> = {
129136 }
130137 ` ,
131138 } ,
139+ {
140+ title : 'Correct' ,
141+ usage : [
142+ {
143+ ignoredSelectors : [
144+ '[type=ObjectTypeDefinition][name.value=PageInfo]' ,
145+ '[type=ObjectTypeDefinition][name.value=/(Connection|Edge)$/]' ,
146+ ] ,
147+ } ,
148+ ] ,
149+ code : /* GraphQL */ `
150+ type FriendConnection {
151+ edges: [FriendEdge]
152+ pageInfo: PageInfo!
153+ }
154+ type FriendEdge {
155+ cursor: String!
156+ node: Friend!
157+ }
158+ type PageInfo {
159+ hasPreviousPage: Boolean!
160+ hasNextPage: Boolean!
161+ startCursor: String
162+ endCursor: String
163+ }
164+ ` ,
165+ } ,
132166 ] ,
133167 configOptions : [
134168 {
@@ -168,7 +202,7 @@ export const rule: GraphQLESLintRule<RuleOptions> = {
168202 }
169203 let selector = `:matches(${ [ ...kinds ] } )` ;
170204 for ( const str of ignoredSelectors ) {
171- selector += `:not(${ str } )`
205+ selector += `:not(${ str } )` ;
172206 }
173207 return {
174208 [ selector ] ( node : SelectorNode ) {
0 commit comments