@@ -8,30 +8,34 @@ export type Block = Linter.ProcessorFile & {
8
8
offset : number ;
9
9
} ;
10
10
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 ;
29
13
30
14
const blocksMap = new Map < string , Block [ ] > ( ) ;
31
15
32
16
export const processor : Linter . Processor < Block | string > = {
33
17
supportsAutofix : true ,
34
18
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
+
35
39
if ( RELEVANT_KEYWORDS . every ( keyword => ! code . includes ( keyword ) ) ) {
36
40
return [ code ] ;
37
41
}
0 commit comments