-
-
Notifications
You must be signed in to change notification settings - Fork 96
Simplify Settings by Relying on Users Setting Prettier Config #404
Conversation
f2b6e2d
to
9d3dd1c
Compare
Codecov Report
@@ Coverage Diff @@
## master #404 +/- ##
==========================================
- Coverage 78.61% 73.46% -5.15%
==========================================
Files 28 29 +1
Lines 505 456 -49
Branches 56 46 -10
==========================================
- Hits 397 335 -62
- Misses 92 103 +11
- Partials 16 18 +2
Continue to review full report at Codecov.
|
I still need to do some manual Q/A as well as check out whether we can get rid of the new |
4b6e180
to
1c25ee3
Compare
Waiting on prettier/prettier#4253 to be implemented as we need prettier to expose whether or not the file is parseable or not if we're not going to use prettier-atom settings to do this. |
Since this is going to break all builds that do not use the very latest prettier, we might as well refactor to use this as well: prettier/prettier#3846 |
1c25ee3
to
ad88808
Compare
@robwise WDYT of using Prettier via CLI rather than through |
@kachkaev This is pretty standard fare for Atom packages though and I believe the same behavior (needing to restart Atom to pick up a change in local version of a module/package/gem/bin) is observed for things like linter-eslint, linter-flow, linter-rubocop, etc. We also had a contributor test CLI vs. require and CLI was significantly slower for some reason. So I'm sort of hesitant to change it ATM. |
Does this mean that we can cache multiple projects' Prettier in paraller? That seems a pretty important thing to have. Imagine I have a single Atom window with three projects: one using local Prettier 1.12.1 with no plugins, another using Prettier 1.13.0 with a couple of local plugins and a third one falling back to a global Prettier, which has a globally installed plugin (different from project 2). I can imagine how this can work when Prettier is called via CLI, but how about JS API? |
@kachkaev We're using |
ad88808
to
75945e6
Compare
@kachkaev This should be working now. Do you want to test it for a bit (I will do the same), especially with Prettier plugins enabled? |
Many thanks @robwise! I’m on holidays now, so won’t be able to test things in the next week. But I trust your experience! |
Does everyone think it would be okay to release this finally? I'm super scared because this might break a lot of projects for a lot of people. |
I guess this should happen sooner or later anyway given the direction into which Prettier goes. If you anticipate a lot of broken workflows, how about adding one paragraph to README that would suggest how to temporary roll back? This command should be a remedy while people migrate from eslint integration etc.:
|
@kachkaev I can't reproduce this one. If it's a normal syntax error from Prettier (as opposed to one of these weird "undefined" errors it throws which causes a full on popup), we display it via the |
Instead of relying on the user to supply prettier-atom with a whole list of Atom scopes for each Prettier parser type, we instead rely on the new getFileInfo method from Prettier and let Prettier tell us whether or not a file is parseable. This will make future parser support automatic as well as allow Prettier plugins to work. Unfortunately, because we rely on this new feature from Prettier, it will mean that users will be forced to upgrade their local Prettier versions to be compatible. BREAKING CHANGE: Because prettier-atom now relies on the new `getFileInfo` method recently added to Prettier, if you are having prettier-atom use a local version of Prettier instead of the version that is packaged with the plugin, you will need to manually update your project's local Prettier version.
0678e08
to
a7e5187
Compare
Okay I changed the message to not mention the local package specifically since this isn't always where it's pulling from, now it's just generic. |
I see a change in the error message, thank you. Although it can be still improved by only mentioning the local prettier or the global one, I think it's good enough already! It's strange that you can't reproduce
The behaviour does not depend on the presense of Elm plugin in Atom. The same happens with |
Oh I was saying I can't reproduce where you don't get any feedback when formatting a bad JS file as I do still get a linter error. I think with the other languages like elm or php, the plugins or whatever is parsing is not throwing the error that Prettier normally expects so it just calls it undefined? |
I don’t believe that prettier interacts with liters unless this is happening inside the atom plugin (something like ‘linting report is not empty -> suppress exceptions’). So unless this is the case, the reason for this undefined popup can be in that plugins throw Error instead of SyntaxError. Can you suppress that popup someone (at least for the time being)? I a real scenario, users of prettier plugins will also have linters installed for those extra languages. So when no formatting on save happens, something will be highlighted in Elm and PHP by that other plugin. In my test case I did not have any additional linters installed as this was a blank Atom setup. |
Yes, sorry, this is the same thing as what I was attempting to say. I think we're on the same page here.
Hmm, perhaps we can have a special option as sort of a band-aid until plugins are better supporting errors? Some ideas:
|
I agree with you that some options look a bit hard to explain. What if we simply suppress undefined errors without any options and console.log them in Atom’s developer tools? This will make prettier’s behavior look the same for any language at start and we can think of better UX after getting feedback from people. I don’t exclude that this false positive error message originates from the plugins and has to be fixed upstream. However, given that it may take too much time and the current behavior may feel frustrating, it feels like implementing a special case for undefined is the least evil. No matter how hard we try to cover edge cases and make the plugin ideal, I’m sure there will be scenarios that we’ve missed. The redesign you were working on is already a breakthrough and I feel really keen to see it on the battlefield! The faster this happens, the quicker the community will polish things up. Iteration over perfection ;–) |
Yes, I agree on all points! I will implement this (suppress |
These messages were very annoying because many plugins do not properly define these and it tends to spam the user.
Okay all set, ready to ship finally? |
I believe so! 🕺 |
Hi! I authored one of the issues that this PR is meant to close (#401). I understand why you'd want to simplify this plugin to reduce the maintenance burden, but FWIW, I'm a bit sad to see this merged. As I mentioned in #401 (comment), my primary use case for this plugin is to format one-off files that are not part of a project and therefore don't have a Prettier config (e.g. individual markdown documents, or small gists). If I understand this PR correctly, this is no longer possible? |
@billyjanitsch this change should allow your use case. Just as before, If you want some config to be applied outside your project, simply create |
Please let me know if the flow @kachkaev described does not work for you, as I would consider that a bug and will fix ASAP. |
Resolves #395 (plugins will be free to run since settings are no inferred from the prettier config)
Resolves #401 (prose option will just be inferred from prettier config instead of needing to be set in prettier-atom)
Resolves #398 (prettier should just work for experimental features since prettier-atom no longer needs to duplicate new experimental options)
Resolves #178 (prettier-atom doesn't pass any options so there's no longer a need to clarify this)
Resolves #433 (prettier-atom will no longer rely on scopes to determine whether to format on save, it will ask Prettier to figure it out)
Resolves #406 (prettier-atom will now check Prettier version using a slightly different method so this logic bug is no longer a problem)