alexanderweiss / nova-prettier

Prettier extension for Nova
MIT License
35 stars 6 forks source link

If using a config file, all options not overwritten in the config file will be set to the prettier default instead of the project or workspace default values #43

Closed cschlittPHI closed 3 years ago

cschlittPHI commented 3 years ago

I noticed that my .prettierrc.js file (in the project root) is not being used by prettier (I have it set to not include trailing commas), but prettier continues to add trailing commas. I then changed the prettier's settings specific to this project to not include trailing commas, but they are still added on save. I then changed prettier's global settings to not include trailing commas, but they are still added on save.

Is there something I'm doing wrong or is this a bug in this extension?

Happy to share and additional details/files!

cschlittPHI commented 3 years ago

More information: It looks like it actually is picking up my .prettierrc.js config file, the issue is that for anything I don't have listed there (and thus want to fallback to the defaults for) it will take the overall prettier default instead of what I have set in the project or workspace settings override.

cschlittPHI commented 3 years ago

My first instinct as a solution would be maybe dynamically create a .prettierrc.js file in the extension's folder in the .nova folder that's based on the defaults set in any config file in the project, project defaults, and workspace defaults and pass that to prettier using --config

alexanderweiss commented 3 years ago

Hi @cschlittPHI, thanks for looking into it further!

This is currently the intended behaviour and as far as I'm aware Prettier plugins for other editors work the same. I think it's the best way to handle this. At least for most people. If it were to merge your project's Prettier config file with your Nova (project) preferences you wouldn't get consistent results between different contributors to the same repository because they might have their editor set up slightly differently. I think it's an important feature of the config file that results are the same wherever / by whoever the formatting happens.

cschlittPHI commented 3 years ago

No problem!

Thinking about it a little more, the way you just explained it makes a lot of sense, I completely agree!

I'll close this issue

alexanderweiss commented 3 years ago

Great! I had to think about it for a little bit as well :)