File tree Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module.exports = {
8
8
{
9
9
files : [ '*.js' , '*.vue' ] ,
10
10
parser : 'vue-eslint-parser' ,
11
- processor : '@graphql-eslint/graphql' ,
11
+ processor : '@graphql-eslint/graphql-vue ' ,
12
12
extends : [ 'eslint:recommended' , 'plugin:vue/base' ] ,
13
13
env : {
14
14
es6 : true ,
Original file line number Diff line number Diff line change 32
32
" graphql"
33
33
],
34
34
"peerDependencies" : {
35
+ "eslint-plugin-vue" : " 9.14.1" ,
35
36
"graphql" : " ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
36
37
},
37
38
"dependencies" : {
Original file line number Diff line number Diff line change 1
- import { processor } from './processor.js' ;
1
+ import { processor , processorWithVue } from './processor.js' ;
2
2
3
3
export { parseForESLint } from './parser.js' ;
4
4
export { rules } from './rules/index.js' ;
5
5
export * from './testkit.js' ;
6
6
export * from './types.js' ;
7
7
export { requireGraphQLSchemaFromContext , requireSiblingsOperations } from './utils.js' ;
8
8
9
- export const processors = { graphql : processor } ;
9
+ export const processors = { graphql : processor , 'graphql-vue' : processorWithVue } ;
10
10
11
11
export { configs } from './configs/index.js' ;
12
12
export { flatConfigs } from './flat-configs.js' ;
Original file line number Diff line number Diff line change @@ -124,3 +124,37 @@ export const processor: Linter.Processor<Block | string> = {
124
124
return result . sort ( ( a , b ) => a . line - b . line || a . column - b . column ) ;
125
125
} ,
126
126
} ;
127
+
128
+ let vueProcessors : Record < string , Linter . Processor < Block | string > > ;
129
+
130
+ export const processorWithVue : Linter . Processor < Block | string > = {
131
+ // Get supportsAutofix and preprocess from the normal processor
132
+ ...processor ,
133
+
134
+ postprocess ( messages , filePath ) {
135
+ if ( messages . length > 0 ) {
136
+ // try to load the vue plugin
137
+ if ( vueProcessors === undefined ) {
138
+ try {
139
+ vueProcessors = require ( 'eslint-plugin-vue' ) . processors ;
140
+ } catch ( error ) {
141
+ // eslint-disable-next-line no-console
142
+ console . error ( error ) ;
143
+ vueProcessors = { } ;
144
+ }
145
+ }
146
+
147
+ // If we have a vue processor, pass it the last element that contains the
148
+ // full SFC code for processing
149
+ if ( vueProcessors [ '.vue' ] ?. postprocess !== undefined ) {
150
+ const last = messages . length - 1 ;
151
+ messages [ last ] = vueProcessors [ '.vue' ] . postprocess ( [ messages [ last ] ] , filePath ) ;
152
+ }
153
+
154
+ // And pass everything to the graphql processor
155
+ return processor . postprocess ! ( messages , filePath ) ;
156
+ } else {
157
+ return messages . flat ( ) ;
158
+ }
159
+ } ,
160
+ } ;
You can’t perform that action at this time.
0 commit comments