-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when used with eslint-plugin-graphql in v2.5.0 #81
Comments
Could you provide the contents of your |
It's the same with any file. Example:
|
It seems like this is happening because A similar problem would probably occur when using other processors (e.g. This makes me think that maybe it wasn't a good idea to pass the filename to
Passing the filename to *GraphQL doesn't actually have embedded JavaScript, but it's handled by a processor in the same way. |
Yeah, if that's the case it seems like there could be a number of similar problems with other file types. 👍 |
@not-an-aardvark @eldh I'm running into this exact same problem and curious if there are any work arounds? |
As a workaround, you could downgrade to I'd like to solve this issue, but I'm not sure what the best solution would be. We could add a configuration option for users to avoid passing in the filename to |
Yeah I've pinned version to 2.4.0 for now. |
Good call. The work around was right there in the original issue description. Sorry for not reading more closely and thanks for the quick responses. |
Hi, I've the same issue with the 5.6.2 version. |
I haven't figured out a better solution, so I think the best way forward might just be to add an option to |
I found that its also possible to work around this problem without downgrading rules: {
'prettier/prettier': [1, {
parser: 'babylon',
}],
}, Not sure if this has any unintended side effects - I assume not, since you would not need to use anything except a javascript parser from within eslint (which only deals with javascript). |
After doing some deep pondering trying to wrangle this. I believe I understand what is going on and the best way for fix this. I don't think there needs to be a {
"rules": {},
"overrides": [
{
"files": ["*.graphql", "*.gql"],
"rules": {
"prettier/prettier": "off"
}
}
]
} This shall disable the prettier rules for graphql, instead of forcing the parser to be potentially incorrect for all files. The problem occurs because eslint-plugin-graphql registers an eslint processor that runs over I don't think there is any value in forcing the parser for graphql files as the processor is not considered autofixable and the processor currently swallows up all linting issues that aren't their own rules. Thus issues raised by the prettier/prettier rule would never be visible and would never be autofixed. There is no point in running prettier over these files if the results will never be exposed. If eslint-plugin-graphql fixes their code to expose rule violations other than their own then it would be straightforward to enable prettier, but forcing the 'babylon' parser, for graphql and gql: {
"rules": {},
"overrides": [
{
"files": ["*.graphql", "*.gql"],
"rules": {
"prettier/prettier": ["error", {"parser": "babylon"}]
}
}
]
} |
* Ignore files in .prettierignore Fixes #88 * Force the babylon parser when parsing not-js files Forcing the parser stops errors that are caused by trying to run a JS fragment through the graphql / markdown parsers. The 'html' parser has not yet been released yet, but will be in Prettier 1.15. This uses a block list over an allow list because I expect the list of "file types with a prettier parser that could contain javascript fragments" will grow at a slower pace than "file types with a prettier parser that are variations of the javascript language". Fixes #98, Fixes #81
What version of
eslint
are you using?4.15.0
What version of
prettier
are you using?1.10.2
What version of
eslint-plugin-prettier
are you using?2.5.0
Please paste any applicable config files that you're using (e.g.
.prettierrc
or.eslintrc
files)Relevant rules:
What source code are you linting?
This seems to happen for any
.graphql
file while usingeslint-plugin-graphql
(I'm on version 1.4.1).What did you expect to happen?
It should lint correctly.
What actually happened?
In
eslint-plugin-prettier
2.4.0
everything works, but since2.5.0
I get the following error:Assuming this has to do with the plugin now passing the filename to prettier, and eslint-plugin-graphql causes graphql files to have a weird filename reported somehow?
The text was updated successfully, but these errors were encountered: