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

Auto-format only if Prettier Config Found #101

Closed
afska opened this issue Feb 2, 2018 · 8 comments
Closed

Auto-format only if Prettier Config Found #101

afska opened this issue Feb 2, 2018 · 8 comments

Comments

@afska
Copy link

afska commented Feb 2, 2018

It would be great to have an option to only enable autoformat when a .prettierrc is defined on the root of the project.

I use Sublime Text with a lot of projects and many of them don't use Prettier, so currently every time I switch between projects I have to go to the settings file to disable/enable autoformat. Example:

{
  "auto_format_on_save": true,
  "auto_format_only_if_prettierrc_found": true
}

Prettier version:
1.10.2

Platform Details:
Sublime Text 3 Build 3126, Linux.

@jonlabelle
Copy link
Owner

@rodri042: Sounds similar to #96. Can you verify?

@afska
Copy link
Author

afska commented Feb 3, 2018

Yeah, looks pretty similar, but I didn't understand why "disabling autoformat if a prettier config isn't found" solves the problem with @dliuzzi's old files. So I thought maybe we were talking about different things.

@jonlabelle
Copy link
Owner

See #96

@afska
Copy link
Author

afska commented Feb 5, 2018

@jonlabelle there are some problems too if this is not implemented:

Users who have prettier locally installed in every project (and NOT global), and use autoformat, will see this annoying message everytime they save a file in a non-prettier project:

screenshot1

@afska
Copy link
Author

afska commented Feb 5, 2018

Maybe we could have an option for ignoring 'command not found' errors? :) I'm just trying to ignore that horrible message for every save, without disabling autoformat, or adding ignore paths for every project in the settings.

@jonlabelle
Copy link
Owner

jonlabelle commented Feb 5, 2018

Why not just install prettier globally? When applicable, your local prettier will always resolve first.

@afska
Copy link
Author

afska commented Feb 5, 2018

If I install prettier globally, JsPrettier formats the file on projects where I don't want to (the reason of this issue), which is much worse than the error popup.

jonlabelle added a commit that referenced this issue Feb 13, 2018
@jonlabelle jonlabelle changed the title Option request: Only autosave when a .prettierrc is defined Auto-format only if Prettier Config Found Feb 17, 2018
@lock
Copy link

lock bot commented Aug 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants