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

CLI with config option throws "cannot read property 'sync' of undefined" since 1.14.0 #4962

Closed
alexandernanberg opened this issue Aug 9, 2018 · 2 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! type:bug Issues identifying ugly output, or a defect in the program
Milestone

Comments

@alexandernanberg
Copy link

alexandernanberg commented Aug 9, 2018

Environments:

  • Prettier Version: 1.14.2
  • Running Prettier via: CLI
  • Runtime: Node 8.11.3
  • Operating System: MacOS 10.13.6

Steps to reproduce:
Run the following (this expects that you have a .prettierrc.examples file and a examples dir with code in it)

prettier --config .prettierrc.examples --write \"examples/**/*.js\"

Expected behavior:
Prettier should format my files inside the examples dir without any errors

Actual behavior:
Throws this error

Invalid configuration file: Cannot read property 'sync' of undefined

This worked prior to 1.14.1. Is there some workaround to this?

@ikatyang
Copy link
Member

ikatyang commented Aug 9, 2018

We updated cosmiconfig to v5 in #4899 (1.14.1), which should probably be the cause. But a config file with .examples extension is not something we supported, we only support config files with no extension (written in JSON/YAML) or one of the supported extensions.

I think the issue here is that the error message needs to be improved, we should open an issue there.

Edit: tracked in cosmiconfig/cosmiconfig#153

@ikatyang ikatyang added scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program labels Aug 9, 2018
@alexandernanberg
Copy link
Author

I see, in my case simply renaming the file to .prettierrc and moving it the examples dir solved the problem.

Thanks!

@ikatyang ikatyang added the status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! label Aug 9, 2018
@ikatyang ikatyang added this to the 1.15 milestone Oct 25, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 23, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants