Extracting operations from .vue files #1670
-
Extracting queries from {
"files": [
"src/**/*.vue"
],
"processor": "eslint-plugin-vue"
} but it does not seem to work, and I have a feeling it breaks all the vue rules as I get weird eslint rule failures. Any hints on how I can get the operation rules to work in vue sfc files ? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
https://github.com/B2o5T/graphql-eslint/tree/master/examples/vue-code-file |
Beta Was this translation helpful? Give feedback.
-
So, I tried that, and, mmm, looking at |
Beta Was this translation helpful? Give feedback.
-
So, I tried Without the graphql override block, it says this:
And with the block, it says this:
I have a feeling I am missing something, but I cannot figure out how to have two processors :( |
Beta Was this translation helpful? Give feedback.
-
To be more complete, the error I get with the graphql override block is:
Which is bogus, it's like it cannot figure out it is a vue sfc. |
Beta Was this translation helpful? Give feedback.
-
Ok, so, after a few hours of trial and error, so, the vue/comment-directive rule is a placeholder to find out exports.processors = {
graphql: processor,
"graphql-vue": {
supportsAutofix: true,
preprocess: processor.preprocess,
postprocess(messages, filePath) {
if (messages.length > 0) {
const last = messages.length - 1;
messages[last] = require("eslint-plugin-vue").processors['.vue'].postprocess([messages[last]], filePath);
const result = processor.postprocess(messages, filePath);
return result;
} else {
return messages
}
},
}
}; It is kinda awful, but it works. |
Beta Was this translation helpful? Give feedback.
-
I would recommend switching the vue-code-file example to As it would break the tests, a new processor is needed, maybe something like I wrote before, keeping the |
Beta Was this translation helpful? Give feedback.
https://github.com/B2o5T/graphql-eslint/tree/master/examples/vue-code-file