RobinMalfait / prettier-eslint-code

[DEPRECATED] A vscode extension to format javascript using prettier-eslint
24 stars 7 forks source link

Add option for filePath to eslint #2

Closed guywaldman closed 7 years ago

guywaldman commented 7 years ago

Or alternatively, use eslint.nodePath in settings.json for VSCode.

P.S. Thank you for this great extension! Very much appreciated.

RobinMalfait commented 7 years ago

Q: what's the use case for this?

prettier-eslint will find the eslint config for you based on the filePath.

guywaldman commented 7 years ago

When you have eslint installed globally and don't want to add it as a local dep in a particular project.

briandipalma commented 7 years ago

Does this addon use the locally installed prettier/ESLint or does it bundle it's own?

RobinMalfait commented 7 years ago

@briandipalma I use a dependency called prettier-eslint by Kent C. Dodds https://github.com/prettier/prettier-eslint. I guess they install prettier & eslint as a dependency

RobinMalfait commented 7 years ago

You can now set the prettier-eslint.eslintPath via settings.

GollyJer commented 7 years ago

Hi again! I'm still working through getting things set up correctly and ran into this issue... I think.

I have eslint installed globally via Yarn. To get the vscode ESLint extension working I set: "eslint.nodePath": "C:\\Users\\Jeremy\\AppData\\Local\\Yarn\\config\\global\\node_modules" It works great.

However, after turning on the prettier-eslint-code extension it seems the code is being sent to prettier, but not eslint --fix. Here's what it looks like. Notice the linting errors but the checkbox next to Prettier ESLint. image

Adding the setting: "prettier-eslint.eslintPath": "C:\\Users\\Jeremy\\AppData\\Local\\Yarn\\config\\global\\node_modules" raises the error Error: Cannot find module 'C:\Users\Jeremy\AppData\Local\Yarn\config\global\node_modules'

If I run the eslint --fix command by hand, it works.

Thanks again for the help! It's so close to perfect. 😃

RobinMalfait commented 7 years ago

Hi @GollyJer

Try replacing

C:\Users\Jeremy\AppData\Local\Yarn\config\global\node_modules

with:

C:\Users\Jeremy\AppData\Local\Yarn\config\global\node_modules\eslint

Does that help?

GollyJer commented 7 years ago

Hey. Thanks again for all the help.
That doesn't work either. Same behavior. :-/ The eslint folder does exist in that path though.

RobinMalfait commented 7 years ago

And what happens if you don't set a path at all?

GollyJer commented 7 years ago

Same behavior. That's what started me looking down this path. I'm going to install eslint in the project to verify it works as expected that way.

GollyJer commented 7 years ago

Hey. Wanted to jump back on here and say that when eslint is locally installed prettier-eslint-code works poerfectly. For now, I'm just going to install eslint and eslint-airbnb (and it's 4 dependencies) in all my projects. Thanks!

RobinMalfait commented 7 years ago

Okay cool, I am not on windows so I couldn't test that. But on mac you can link the global eslint and it works. Sorry for the inconvenience...