Failed to load plugin 'prettier' declared in 'CLIOptions': Cannot find module 'eslint-plugin-prettier' #505
Comments
I should also mention: I use a
|
Oh, I should also mention that this error is occurring in the latest version of prettier-atom: v0.56.6 |
This issue seems to be isolated to the use of eslint v6.x. I was able to roll back eslint to version 5.16.0 and the problem went away. Everything else stayed the same. |
Can you try running prettier directly from the command line with the 6.x version of eslint and see if you still get the problem? |
same problem here |
@robwise It works from the command-line; just not within Atom. |
Same for me |
And same for me |
I just pushed a bunch of dependency updates, can you update prettier-atom to get these changes and see if you're still having the problem? I'm crossing my fingers that it's just something related to stale deps. |
I am seeing the same issue too even after updating prettier-atom. Let me know if you need further help testing. |
Noticed these issues:
I'm definitely thinking that this is an eslint 6.0 thing as reported by @christroutner. They're reporting similar issues with VSCode and that going to eslint 5 fixes it again. Apparently in ESlint 6 they changed how the plugins get resolved. I'm not totally sure how to fix the issue if this is really the cause though, and it seems like a lot of people here are already installing everything locally in their project as opposed to globally. What's not helping is the fact that I can't reproduce locally despite bumping to eslint 6. |
Editor could'nt format the code using prettier 6.x version as there is some breaking changes in loading plugins Tracking issue: prettier/prettier-atom#505
Same happening here. |
Can you guys read through here and see if any of this applies to you? microsoft/vscode-eslint#696 They mention issues with not installing the eslint plugins per project (you used to be able to install them globally, but now eslint6 requires them to be local to the project) as well as issues with having configurations in subfolders. |
In my case, the prettier-atom failed: Failed to load plugin 'emotion' declared in 'CLIOptions': Cannot find module 'eslint-plugin-emotion' |
I have everything installed locally in the root of my project as well. package.json "devDependencies": {
"babel-eslint": "^10.0.2",
"eslint": "^6.1.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2",
"prettier-eslint": "^9.0.0"
} .eslintrc "parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
}
},
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
} Error:
|
Jeez this is weird. Can you also please verify that you've gotten the latest prettier-atom version (released yesterday). There was a bug that had to do with our read-pkg-up and I notice that some people's errors are leading to very close to their home directory to a file named |
I have same error with latest prettier-atom version . ( |
I have the latest |
Sorry for all of the questions, trying to figure out what the heck is going on here. I assume you're using the I think what's going on is that prettier-eslint is not detecting the current working directory properly for eslint 6: prettier/prettier-eslint#222 This causes eslint to be unable to find the plugin packages? |
In my case, yes, i'm using How can i help you to debug this problem ?? Should install |
Yeah that might be a good idea, see if you can reproduce with prettier-eslint. Another thing you could try just to at least workaround the problem right now is just to disable the eslinit integration and then use the linter-eslint Atom package. That's what I currently run personally and it works pretty well if you have the prettier plugin running inside of eslint and are extending eslint-config-prettier as it prevents any linter collisions. |
Well, i used const format = require('prettier-eslint');
format({ eslintConfig: './.eslintrc', filePath: './src/file.js' }); About |
There aren't differences if you use |
It worked @robwise. I disabled ESLint integration from |
I use both that way I can still use prettier for non-JS code. As long as you have |
@robwise thanks for confirming my guess that the usage of this ( |
Well I was talking about prettier-eslint not really being a recommended thing to keep using, not prettier-atom. If you want to use prettier without eslint, which many people do for JS and is required for other languages that Prettier supports (since ESLint is only for JS), then you still need prettier-atom. |
Downgrading to ESLint 5.16.0 has fixed this for me for now, but it's not an ideal solution. |
facebook/react#16531 (comment)
|
For me the issue was in Prettier's settings. If Format Files on Save is checked, make sure that ESLint Integration is unchecked. |
Yes this is a problem with prettier-eslint, so if you turn off the ESLint integration it will just work normally. I recommend people do this normally but I didn't want to have the prettier-eslint devotees get mad lol! Personally, I don't use prettier-eslint because I set up ESLint to just not touch the types of things that would disagree with prettier (using |
I would personally still love to keep using this plugin and the prettier-eslint integration, because it seems to be the only way afaik to apply eslint styling rules that don't agree with prettier's output without a bunch of permanent linting errors. Even the eslint-plugin-prettier project still points users to prettier-eslint for this use case: https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
I personally love using prettier's max-length based formatting algorithm, but prettier itself is still far too opinionated and inflexible to satisfy everybody's styling preferences, so having prettier-eslint as an escape hatch has proven to be incredibly valuable for me (fwiw one of the things I use it for currently is to change the way nested ternaries are formatted: prettier/prettier#5814). I'll see if I can find some time later this week to put up a PR to fix this, or at least set up a repo to repro this so people more familiar with the plugin can take a look. |
Yes I agree, if you actually don't like the way Prettier is doing something and want ESLint to override it, then you sort of have to use prettier-eslint. I'm totally fine with continuing to support prettier-eslint but this bug specifically I'm thinking is actually a problem with prettier-eslint and not prettier-atom AFAICT, so it really would need to be fixed there. Unless, that is, we are passing some arguments in a weird way to prettier-eslint and that's what's causing it to get confused? |
Looked into this a bit more and made a PR to prettier-eslint that seems to resolve the issue (for my setup at least): prettier/prettier-eslint#242 Will open a PR here to update when that gets merged & released so we can close this one off. :) |
You're a beast! |
@lewisl9029 Amazing work - as usual. 🙌🏽 |
So how do I get the fix? |
prettier-eslint needs to merge in his branch and then I can cut a new release of prettier-atom immediately, but they haven't merged it yet for some reason. |
this guy is a hero |
So was it merged? I see that the issue is closed. |
Using a temporary fork for prettier-eslint due to maintainer having been unresponsive. Feels warranted as this is a showstopping bug affecting many users. fix prettier#505
Using a temporary fork for prettier-eslint due to maintainer having been unresponsive. Feels warranted as this is a showstopping bug affecting many users. fix prettier#505
Hi all, since the maintainer of prettier-eslint hasn't been responsive in reviewing my upstream fix for this issue, I thought it might be a good idea to switch to a (hopefully 🤞) temporary fork of prettier-eslint here instead, and created this PR: #564 @robwise wdyt? |
Using a temporary fork for prettier-eslint due to maintainer having been unresponsive. Feels warranted as this is a showstopping bug affecting many users. fix prettier#505
Agreed, merged for now. I think I may add a deprecation notice in the README or something. Really I think using |
I updated prettier-atom and restarted Atom and it fixed the issue |
This works to me. |
I reviewed older issues, but didn't find anything that matched this issue.
Prettier is no longer working properly in Atom. I have all my dependencies updated (as far as I can tell). I've tested against older versions of the code and this issue only occurs with these updated dependencies (list below).
Here is the error I get in Atom when I try to run auto-formatting with Prettier:
Here are the dev dependencies from my package.json file:
I've rolled the dependencies above back to older versions and the error goes away, prettier functions as expected.
Running prettier on the command line seems to work fine. It's just the Atom integration/plugin that is failing.
The text was updated successfully, but these errors were encountered: