Prettier-vscode: prettier doesn't use eslintConfig when modules are installed globally

Created on 14 Jun 2018  路  7Comments  路  Source: prettier/prettier-vscode

i have installed prettier and eslint extensions in vscode, and enable prettier.eslintIntegration setting.
and i have installed eslint and eslint-config-airbnb-base modules globally in NPM.
but prettier used prettierOptions rather than eslintConfig when i format codes.
example codes:
image
after formating:
image
however when i installed prettier-eslint-cli module globally in NPM. then run prettier-eslint .\src\index.js. it worked as expected. see below.
image
i think there are some issues when prettier resolving eslintConfig if modules are installed globally. hope it be fixed.

locked

Most helpful comment

Unless I missed it in the docs, I didn't see anywhere that in order for _prettier.eslintIntegration:true_ to work you need to have all your eslint dependencies installed locally, not globally. It makes sense now, and I understand why they should be installed locally per project instead of globally. However when I was trying to get this to work for the first time, and happened to have everything installed globally, I've been struggling to make it work for a long time...until I came across this issue post.

Maybe in your docs where you write:

prettier.eslintIntegration (default: false) - JavaScript and TypeScript only
Use _prettier-eslint_ instead of _prettier_. Other settings will only be fallbacks in case they could not be inferred from ESLint rules.

you could add something like:

prettier-eslint already installed with extension. All other eslint dependencies need to be installed locally

Again, maybe i just missed that info, or the assumption that a dev will know to install all eslint dependencies locally is so strong that you feel it doesn't need to be stated (i'm still a bit of a newb).

And to be clear...I say none of this mockingly or sarcastically. I love the extension and all the hard work that has gone into this. Just offering up some unsolicited advice from a newish dev.

All 7 comments

We do not use your globally installed prettier-eslint and thus can't access any of your globally installed dependencies. We do however pick up your locally installed dependencies. (prettier-eslint does it)

Unless I missed it in the docs, I didn't see anywhere that in order for _prettier.eslintIntegration:true_ to work you need to have all your eslint dependencies installed locally, not globally. It makes sense now, and I understand why they should be installed locally per project instead of globally. However when I was trying to get this to work for the first time, and happened to have everything installed globally, I've been struggling to make it work for a long time...until I came across this issue post.

Maybe in your docs where you write:

prettier.eslintIntegration (default: false) - JavaScript and TypeScript only
Use _prettier-eslint_ instead of _prettier_. Other settings will only be fallbacks in case they could not be inferred from ESLint rules.

you could add something like:

prettier-eslint already installed with extension. All other eslint dependencies need to be installed locally

Again, maybe i just missed that info, or the assumption that a dev will know to install all eslint dependencies locally is so strong that you feel it doesn't need to be stated (i'm still a bit of a newb).

And to be clear...I say none of this mockingly or sarcastically. I love the extension and all the hard work that has gone into this. Just offering up some unsolicited advice from a newish dev.

@ndstephens Would you like to send a PR to clarify that part?

@ndstephens That's a great idea.

It took me a while to figure out that this extension wasn't using my local/global install of prettier-eslint.

just created pull request #629

open to all adjustments, improvements, and general verification of the text. I believe it's accurate, but not 100% certain

Thanks @ndstephens
your explanation appears in the readme.
Fixed in #629

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielHabenicht picture DanielHabenicht  路  4Comments

sebastijandumancic picture sebastijandumancic  路  4Comments

studiojms picture studiojms  路  4Comments

SkeLLLa picture SkeLLLa  路  4Comments

FlorianWendelborn picture FlorianWendelborn  路  3Comments