-
-
Notifications
You must be signed in to change notification settings - Fork 95
Request: remove merging of explicit configurations with atom-prettier settings #370
Comments
@olsonpm I'm a bit confused. The way it's supposed to work is that the settings in your package.json should be respected? We merge them in after the Atom settings, so they should take precedence. Answers to those questions:
Maybe what you're suggesting/questioning is similar to point raised by #218? |
Thanks for the reply. Let me think about what you wrote, but regarding:
I was expecting them to not be merged with the atom-settings configurations. By merging them with atom-settings I have no way to fall back to prettier defaults. |
By merging project settings with those local to my editor prevents project compatible settings though, correct? For # 2 - we agree this is not ideal. Thanks for the link to the other issue. Seems I'm suggesting exactly what you wrote there
|
I can also agree that if a configuration is found in the project; then we should ignore using the settings in I normally put all the configuration settings in, even if they are just the defaults, so I’ve never seen this. However, I would be extremely frustrated by the situation described here. It should work like:
We should probably also consider allowing the user to completely disable package settings as well. I’ve been wanting a way to make sure I just use Prettier’s defaults no matter what I put in the |
That logic sounds good to me. I'll get a PR implementing that so we have something concrete to discuss. In the PR I'll also modify the debug command to be explicit about what configurations would be applied to a given file. |
I think one of the issues we originally had when prettier implemented its configuration files was that it considered an empty configuration file as having no rules defined. In this case, we weren't able to tell the difference between a default configuration and no configuration at all. That's sort of the arcane history explaining why it got implemented the way it did. Hopefully, they've changed this (I think they might have fixed it when I brought up the issue during an editorconfig integration on Prettier, but I can't really remember). |
AFAIK and what I would assume Prettier does is take in any settings and for those it doesn’t find it fills in the defaults. In a sort of Prettier config > .editorconfig > Prettier defaults manner. |
I've been looking into the implementation and catching up on some issue reading - Prettier uses Regardless, the implementation I'm starting with is: -- return {
-- ...optionsFromSettings,
-- ...buildEditorConfigOptionsIfAppropriate(editor),
-- ...getPrettierConfigOptions(editor),
-- };
++ return getPrettierConfigOptions(editor) || optionsFromSettings; btw @SavePointSam, when you mentioned
You meant to format using the project prettier version's defaults as the found configuration would be null/empty - correct? Edit:
This is incorrect, I assumed it would be a project setting but because of what robwise pointed out (empty === nonexistent) I created a cosmiconfig issue to address that. This is blocked until the cosmiconfig issue is addressed. |
@olsonpm, I meant that you only format if a Prettier configuration was found in the current project path. It can still be a subset configuration that would need to be cast against Prettier defaults. However, if no configuration is found, do not format at all. Also note, I’ve written a new API for Prettier called |
@olsonpm I think at least being able to see what options are used, even if we can't see why because of the editorconfig ambiguity, would be a huge win for us. |
Sounds good about exposing what options are used. And I was planning on using cosmiconfig's Unfortunately I'm realizing the combinations of configurations this tool allows can lead to some pretty unexpected behavior in a team setting. e.g. I don't see any applicable scenario where someone should use a global installation of prettier with a local configuration, or a local installation with |
@olsonpm I agree that both of those use cases wouldn't make sense to me personally. |
…ugin settings Stop the current behavior of merging a local prettier config with those found in the plugin settings. The reason being a project should be formatted according to its own rules, and per Prettier convention omitted rules should fallback to prettier defaults. Remove the plugin's integration with editorconfig in favor of relying on prettier's via its editorconfig option. BREAKING CHANGE: The formatting configuration is now built according to different rules fix prettier#370
…ugin settings Stop the current behavior of merging a local prettier config with those found in the plugin settings. The reason being a project should be formatted according to its own rules, and per Prettier convention omitted rules should fallback to prettier defaults. Remove the plugin's integration with editorconfig in favor of relying on prettier's via its editorconfig option. BREAKING CHANGE: The formatting configuration is now built according to different rules fix prettier#370
…ugin settings Stop the current behavior of merging a local prettier config with those found in the plugin settings. The reason being a project should be formatted according to its own rules, and per Prettier convention omitted rules should fallback to prettier defaults. Remove the plugin's integration with editorconfig in favor of relying on prettier's via its editorconfig option. BREAKING CHANGE: The formatting configuration is now built according to different rules fix prettier#370
…ugin settings Stop the current behavior of merging a local prettier config with those found in the plugin settings. The reason being a project should be formatted according to its own rules, and per Prettier convention omitted rules should fallback to prettier defaults. When a prettier config is found, use its integration with editorconfig instead of the plugin's own implementation. BREAKING CHANGE: The formatting configuration is now built according to different rules fix prettier#370
…ugin settings Stop the current behavior of merging a local prettier config with those found in the plugin settings. The reason being a project should be formatted according to its own rules, and per Prettier convention omitted rules should fallback to prettier defaults. When a prettier config is found, use its integration with editorconfig instead of the plugin's own implementation. BREAKING CHANGE: The formatting configuration is now built according to different rules fix prettier#370
…ugin settings Stop the current behavior of merging a local prettier config with those found in the plugin settings. The reason being a project should be formatted according to its own rules, and per Prettier convention omitted rules should fallback to prettier defaults. When a prettier config is found, use its integration with editorconfig instead of the plugin's own implementation. Remove incorrect note: "You must have at least one valid rule in order for your config to be considered present". In reality, if the result of 'resolveConfig' is not null or undefined then a configuration is considered to be found. BREAKING CHANGE: The formatting configuration is now built according to different rules fix prettier#370
…ugin settings Stop the current behavior of merging a local prettier config with those found in the plugin settings. The reason being a project should be formatted according to its own rules, and per Prettier convention omitted rules should fallback to prettier defaults. When a prettier config is found, use its integration with editorconfig instead of the plugin's own implementation. Remove incorrect note: "You must have at least one valid rule in order for your config to be considered present". In reality, if the result of 'resolveConfig' is not null or undefined then a configuration is considered to be found. BREAKING CHANGE: The formatting configuration is now built according to different rules fix prettier#370 fix prettier#218
I just spent some time looking into why my prettier settings in package.json weren't being respected, and it's due to them being assigned over atom-prettier settings. I'm wondering what the use-case is for
only format if a prettier config is found
andi.e. why would I want to require an explicit configuration while also using the one local to my editor? I assume the use-case for allowing users to require both an explicit prettier instance and settings would be to ensure consistent formatting should they move to a different editor or machine.
Even if I set atom-prettier's settings to the defaults, this could become problematic should the defaults in the local prettier instance be different.
Another less breaking solution would be to add an option to ignore atom-prettier's configuration settings.
I'm willing to create a PR if either solution is agreeable.
The text was updated successfully, but these errors were encountered: