@@ -8,30 +8,34 @@ export type Block = Linter.ProcessorFile & {
88 offset : number ;
99} ;
1010
11- const graphQLTagPluckOptions : GraphQLTagPluckOptions =
12- loadGraphQLConfig ( ) . getDefault ( ) ?. extensions ?. graphqlTagPluck ;
13-
14- const {
15- modules = [ ] ,
16- globalGqlIdentifierName = [ 'gql' , 'graphql' ] ,
17- gqlMagicComment = 'GraphQL' ,
18- } = graphQLTagPluckOptions || { } ;
19-
20- const RELEVANT_KEYWORDS = [
21- ...new Set (
22- [
23- ...modules . map ( ( { identifier } ) => identifier ) ,
24- ...asArray ( globalGqlIdentifierName ) ,
25- gqlMagicComment ,
26- ] . filter ( Boolean )
27- ) ,
28- ] ;
11+ let RELEVANT_KEYWORDS : string [ ] ;
12+ let graphQLTagPluckOptions : GraphQLTagPluckOptions ;
2913
3014const blocksMap = new Map < string , Block [ ] > ( ) ;
3115
3216export const processor : Linter . Processor < Block | string > = {
3317 supportsAutofix : true ,
3418 preprocess ( code , filePath ) {
19+ if ( ! RELEVANT_KEYWORDS ) {
20+ graphQLTagPluckOptions = loadGraphQLConfig ( ) . getDefault ( ) ?. extensions ?. graphqlTagPluck ;
21+
22+ const {
23+ modules = [ ] ,
24+ globalGqlIdentifierName = [ 'gql' , 'graphql' ] ,
25+ gqlMagicComment = 'GraphQL' ,
26+ } = graphQLTagPluckOptions || { } ;
27+
28+ RELEVANT_KEYWORDS = [
29+ ...new Set (
30+ [
31+ ...modules . map ( ( { identifier } ) => identifier ) ,
32+ ...asArray ( globalGqlIdentifierName ) ,
33+ gqlMagicComment ,
34+ ] . filter ( Boolean )
35+ ) ,
36+ ] ;
37+ }
38+
3539 if ( RELEVANT_KEYWORDS . every ( keyword => ! code . includes ( keyword ) ) ) {
3640 return [ code ] ;
3741 }
0 commit comments