Version: 0.21.2
My config.cson has:
"prettier-atom":
prettierOptions: {}
singleQuote: true
trailingComma: false
useEslint: true
Error:
prettier-atom: ● Validation Error:
Option "trailingComma" must be of type: boolean but instead received: string
Example: { "trailingComma": false }
● Validation Error:
Option "trailingComma" must be of type:
boolean
but instead received:
string
Example:
{
"trailingComma": false
}
@aaronshaf It looks like you've got old options set in there, I would wipe those and use the settings menu to repopulate your config.
Where can I find the old options?
In your config.cson, it still is listing the old options. I would delete those manually. Then I would go to Preferences -> Packages -> prettier-atom and set the new settings there. Let me know if that works.
I did that and it did not work. I ended up deleting the entire .atom directory, still no cigar after reinstall of the module.
Can you screenshot your settings page for prettier-atom and show me which option you have selected for Trailing Commas?
@aaronshaf Hmm, this is a very strange bug, it seems like your old config settings are still there no matter what you do on your end. I'm not really sure what's going on, but I am going to try something weird in the plugin and see if it fixes your issue.
@aaronshaf Please let me know if the latest version fixes this issue for you.
I tried 0.21.3. Unfortunately... same issue :-(
@aaronshaf Ugh, sorry man. Okay, so if you manually delete those options from your config.cson, then restart atom, they come back again? Or do they stay gone from the config?
Is anyone else having issues like this? Maybe we can figure out a common thread between environments and that will point towards what the cause is.
That worked! Thank you so much.
Users will have to delete the relevant section of config.cson and restart.
Drat, sorry. False positive. Once I re-enabled eslint integration, same issue.
When you re-enable the eslint integration, the old values come back and put themselves into your config.cson again?
New config.cson:
"*":
core:
telemetryConsent: "no"
editor:
fontSize: 16
"prettier-atom":
useEslint: true
So, you delete the old options from your config.cson, then it works. Then you uncheck and check the ESlint integration option, and although the old options don't reappear in your config, you get an error about the trailing comma being a string instead of a boolean again? Except now there's nothing to delete?
It looks like it never worked when eslint integration was enabled for the plugin.
Shoot, I can't think of what the problem may be here.
I'm having a similar problem where commas are inserted always regardless of what the setting is. In addition, ESLint is not running fix.
I have deleted the relevant section in my config.cson and re-created it from the settings, no change.
config.cson now has
"prettier-atom":
prettierOptions:
singleQuote: true
useEslint: true
Yet commas are inserted and eslint is not run. Double-quoted strings _are_ changed to single-quoted strings, so prettier is definitely running and picking up that setting.
Here is a repo showing this behavior: https://github.com/dgcoffman/DailyProgrammer
@dgcoffman I checked that repo using prettier-eslint's CLI directly and the bug still happens, so this is a prettier-eslint error. Can you make an issue over at https://github.com/prettier/prettier-eslint?
In the meantime, I noticed that, for some reason, adding this to the end of your .eslintrc stops the bug from happening even though it's redundant to the eslint:recommended preset.
comma-dangle:
- error
- never
@aaronshaf Are you still encountering this? I believe it may actually be an error with atom and how it deals with changes to package settings, as I noticed similar problems when other packages changed their own settings API as well.
I just updated prettier-atom and get the same error as Aaron. When I enabled "ESLint integration" it immediately fails with the error listed above. My config.cson doesn't have anything listed except
useEslint: true
What version were you on prior to updating?
Similar issue here. prettier-atom will not respect my settings (commas, line-length, etc.) while eslint integration is turned on. I think it's falling back to the defaults or something.
Using the latest version (0.26.0)
prettier-atom will not respect my settings (commas, line-length, etc.) while eslint integration is turned on. I think it's falling back to the defaults or something.
@spudly This is the intended behavior, if you want it to use the prettier settings you chose and not the eslint settings, you need to turn the eslint integration off
@robwise So in my setup, I've disabled all style configs for eslint because I want prettier to handle style (I only want eslint to fix errors / bad practices). I don't have any configured line-length or comma rules in my eslint config because I want prettier to handle that.
Let's take line-length for example. I would expect it to look at the maxlen eslint rule first. If it's configured, use the configured length. If not, look at the settings for prettier-atom. If there's a line length configured there, use that. If not, fall back to the default prettier settings (80 chars I believe).
If I understand you correctly, it seems like the second step is not happening, and it first looks like it looks in eslint first and if there's no maxlen rule it just uses the prettier default. Is that right? Would you be willing to accept a PR that makes it fallback to the prettier-atom settings before falling back to the prettier defaults?
I don't think this is going to be possible to do from this plugin, because the detection of the ESlint rules and whether they are defined or need to fall back is all done by prettier-eslint, not this atom plugin?
@robwise,
I spent some time digging through the code, and it looks to me like we should be sending the configured options to prettier-eslint. It will then behave as expected.
prettier-eslint takes a prettierOptions option. See https://github.com/prettier/prettier-eslint/blob/master/src/index.js#L47
If prettierOptions is specified, it uses the prettierOptions configured by the user. Otherwise, it infers the prettier options from the package's ESLint config. See: https://github.com/prettier/prettier-eslint/blob/master/src/utils.js#L88
It's not passing prettierOptions here: https://github.com/prettier/prettier-atom/blob/615d4a37227536ae953f6edb5479d4b04950de69/src/executePrettier.js#L34 . We can fix this by including prettierOptions: getPrettierOptions(editor), in the object passed to pretterEslint()
Perhaps the best way forward is to add a config in the plugin called "Infer prettier options from eslint config." If false, it will pass prettierOptions to prettierEslint.
@spudly Can you elaborate on the use case for this? Why would you want to add trailing commas with prettier, for example, if your eslint config is set to not add trailing commas? The original intent was that if you are going to use the ESlint integration, then prettier-eslint "just works" by picking up your configuration from the ESlint config. This way, as you switch to different projects with different ESlint configurations, you don't need to adjust anything.
@robwise
My use case is this: I want eslint to handle warnings and errors (possible bugs), while prettier makes the code look pretty.
To that end, I:
Unfortunately, the prettier options I specify in the plugin settings are not respected because they are not passed on to prettier-eslint.
Oh okay, now I see. Yeah so maybe what we should do is add a boolean flag like you say to the prettier-eslint options section of the settings that you made in #110 and we default this to off. If we detect it's true, then we pass the prettier options on to ESlint?
Sounds good to me.
I'm still seeing this issue with the latest version of prettier-atom, definitely not fixed.
@tommoor A fix was never attempted. I'm pretty sure this is an Atom bug related to config schema changes.
Just for anyone coming across this, my issue was a old version of prettier installed as a devDependency of the project I was working on, which expected trailingComma to be a boolean and was being passed the string all.
Should prettier-atom check that the version of prettier it will use is compatible with the options being passed?
Thanks Mark, that's really useful - almost definitely the problem on my end
as I update the dependency much less often than the plugin, I'll try that
out.
On Mon, Apr 24, 2017 at 12:06 AM, Mark Cola notifications@github.com
wrote:
Just for anyone coming across this, my issue was a old version of prettier
installed as a devDependency of the project I was working on, which
expected trailingComma to be a boolean and was being passed the string all
.
Should prettier-atom check that the version of prettier it will use is
compatible with the options being passed?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/prettier/prettier-atom/issues/72#issuecomment-296549207,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAXP8gpVrlddMwdygI2FVdYp8SMOjAiyks5rzEoEgaJpZM4MUKuK
.
--
Tom Moor
Still getting this error:
atom version 1.17.2 prettier-atom version 0.31.1
$ prettier -v
1.3.1
$ prettier
[...]
--trailing-comma <none|es5|all>
[...]
Last time, the fix was to upgrade the prettier binary. Seems 1.3.1 is the latest. Is the atom package somehow referencing an old version?
FWIW in my case it was definitely the the dependency in my project and prettier-atom were mismatched. It turns out that I didn't need to use prettier-atom at all anyway as I was already running prettier through eslint, the atom integration is pointless in that scenario.
apologies, it seems my yarn.lock had two versions and it was resolving the old version 😭
Most helpful comment
Just for anyone coming across this, my issue was a old version of prettier installed as a
devDependencyof the project I was working on, which expectedtrailingCommato be a boolean and was being passed the stringall.Should prettier-atom check that the version of prettier it will use is compatible with the options being passed?