Skip to content
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

Add prettier-eslint integration #70

Closed
kentcdodds opened this issue Apr 10, 2017 · 24 comments · Fixed by #92
Closed

Add prettier-eslint integration #70

kentcdodds opened this issue Apr 10, 2017 · 24 comments · Fixed by #92
Labels
enhancement locked Please open a new issue and fill out the template instead of commenting.

Comments

@kentcdodds
Copy link
Member

The atom plugin has added this (maybe @robwise can give some tips). This way you and @RobinMalfait (who created prettier-eslint-vscode) could join forces to make this package even better!

@RobinMalfait
Copy link
Contributor

Maybe it is an idea to join forces and also move prettier-vscode+prettier-eslint-vscode to the prettier namespace on GitHub?

@CiGit
Copy link
Member

CiGit commented Apr 11, 2017

I've closed #14 lately.
What's the advantage over running text -> prettier -> text -> eslint --fix -> text ?

This is already possible with 2 extensions (this one and Eslint) while saving:

{
  "editor.formatOnSave": true,
  "eslint.autoFixOnSave": true
}

Maybe luckily because the formatter runs before onsave events

It's also possible to setup a keybinding for those steps (not out of the box for now) microsoft/vscode#871

Moving to the prettier org is tracked in #41 and prettier/prettier#781

@RobinMalfait won't mind having more contributors ;-)

@kentcdodds
Copy link
Member Author

I don't know how things are handled in VSCode, but I know in Atom if you tried to use Prettier and the ESLint plugin together you'd get a pretty bad experience:

f6c19130-d8ba-11e6-9538-b4b4a788f63b

Also, I'm certain that it doesn't perform nearly as well.

@CiGit
Copy link
Member

CiGit commented Apr 11, 2017

In code you also have those blinking change due to the intermediate changes being printed.
That's the only bad thing I noticed. It may be a vscode bug/improvement.

I've seen something really nice in your plugin: you infer prettier's settings from eslint's one avoiding duplication and having config in your workspace. 👍

We will have to think about how we handle settings precedence in our case.

@kentcdodds
Copy link
Member Author

Perhaps @robwise can give some tips in that regard 👍

Thanks for taking this under consideration @CiGit :)

@robwise
Copy link

robwise commented Apr 11, 2017

Let me know if you have a speciifc question about what we're doing in prettier-atom. Currently, users can either choose to enable the eslint integration (i.e., use prettier-eslint under the hood) or not (i.e., use regular prettier). In the former case, we basically ignore every setting you've set for prettier because we let prettier-eslint pick it up entirely from the eslint configuration.

@CiGit
Copy link
Member

CiGit commented Apr 15, 2017

@robwise Thanks for the info. What's happening if there is no configuration available for eslint?
IMHO it should then fallback to prettier's provided settings but it seems it's just the opposite of what @kentcdodds' prettier-eslint is doing.

@kentcdodds
Copy link
Member Author

it seems it's just the opposite of what @kentcdodds' prettier-eslint is doing.

🤔 I'm not sure how you're getting that. It clearly states:

Defaults if you have all of the relevant ESLint rules disabled (or have ESLint disabled entirely via /* eslint-disable */ then prettier options will fall back to the prettier defaults

@CiGit
Copy link
Member

CiGit commented Apr 15, 2017

Sorry for the confusion.
I was meaning user's provided prettier configuration which in prettier-atom is dropped.

  1. Use eslint as source of truth
  2. Fallback to user's config for missing settings
  3. Fallback to prettier's default for the rest.

@kentcdodds
Copy link
Member Author

Ah, gotcha. Yeah, with prettier-atom, we try to make it very simple: If you check the eslint integration button, then none of your other settings matter. That makes things pretty clear. But I suppose it could also make sense if you wanted to fallback to settings in the IDE if eslint is not configured...

@robwise
Copy link

robwise commented Apr 16, 2017

@kentcdodds in fact, some users have requested this. I think it would be okay to do it, although yes, it would be a bit more complicated

@kentcdodds
Copy link
Member Author

Come to think of it, now that prettier supports no semicolons, I would also like this! 😅

@robwise
Copy link

robwise commented Apr 16, 2017

@kentcdodds If we somehow allow passing the fallback prettier options to prettier-eslint when invoking it, then I can hook this up pretty easily in prettier-atom.

@kentcdodds
Copy link
Member Author

@robwise
Copy link

robwise commented Apr 17, 2017

I guess we'd do the same thing but call it fallbackPrettierOptions or something?

@CiGit
Copy link
Member

CiGit commented Apr 23, 2017

Great! prettier/prettier-eslint#73 👍

Question to prettier-eslint users:
Does it make sens to use it without having it as a project dependency ? $HOME/.eslintrc
If not we could simply pick it up from the project's dependencies and use it, thus avoiding an option.

CiGit added a commit to CiGit/prettier-vscode that referenced this issue Apr 23, 2017
Use prettier-eslint
new option: prettier.eslintIntegration (boolean)

code refactor
making a type definition file.
requirePrettier is now requirePackage(name)

fixes prettier#70
CiGit added a commit to CiGit/prettier-vscode that referenced this issue Apr 23, 2017
Use prettier-eslint
new option: prettier.eslintIntegration (boolean)

code refactor
making a type definition file.
requirePrettier is now requirePackage(name)

fixes prettier#70
@kentcdodds
Copy link
Member Author

I could have a project with eslint configured, but not prettier-eslint. I would prefer to have it be: default to locally installed version, if it doesn't exist, use the plugin's version. Does that make sense?

@CiGit
Copy link
Member

CiGit commented Apr 23, 2017

Definitely. So I won't remove the option

Does it make sens to load prettier-eslint from the project? If I understand it correctly prettier-eslint will load eslint/prettier from the project if I give it a filePath
But do you expect some output changes between prettier-eslint's different versions? Therefor project's version may differ from bundled one?

@kentcdodds
Copy link
Member Author

Yeah, I don't expect the output too differ. It's probably fine to just use the plugin's version.

@CiGit
Copy link
Member

CiGit commented Apr 23, 2017

Thanks for your time.
Will update my PR accordingly and wait for a review (there are a lot of changes involved)

By the way, nice work on your eslint-prettier, I've played around with it in my vscode integration and it's well better than prettier -> eslint --fix 😉

@kentcdodds
Copy link
Member Author

Wonderful! Debugging tip: open up Dev tools and set: process.env.LOG_LEVEL = 'trace'
Then run the format command and you'll get a bunch of useful logs from prettier-eslint 😀

@CiGit
Copy link
Member

CiGit commented Apr 23, 2017

a bunch ....
Thanks for the tip. It also made me correct my definitions 😆

diff --git a/src/types.d.ts b/src/types.d.ts
index f8ef5b9..d0a4ab0 100644
--- a/src/types.d.ts
+++ b/src/types.d.ts
@@ -71,7 +71,7 @@ interface PrettierEslintOptions {
     /**
      * The level for the logs
      */
-    loglevel?: LogLevel;
+    logLevel?: LogLevel;
     /**
      * Run Prettier Last. Default false
      */

CiGit added a commit to CiGit/prettier-vscode that referenced this issue Apr 23, 2017
As discussed on prettier#70
It seems to be pointless and should avoid some issues.
@CiGit CiGit closed this as completed in #92 Apr 28, 2017
@kentcdodds
Copy link
Member Author

Thanks so much for doing this. It's great to converge solutions :)

@github-actions
Copy link

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.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Apr 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants