Skip to content

--prettier-config throws misleading error if custom config isn't JSON #222

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

Closed
ikornienko opened this issue Apr 24, 2020 · 4 comments · Fixed by #224
Closed

--prettier-config throws misleading error if custom config isn't JSON #222

ikornienko opened this issue Apr 24, 2020 · 4 comments · Fixed by #224

Comments

@ikornienko
Copy link

When I used --prettier-config .prettierrc.js I've got an an error Prettier: couldn’t find '.prettierrc.js' in .... It turned out that the error is misleading, as the exception was about config not being a valid JSON.

In general, I see more and more people prefer .eslintrc.js and prettierrc.js over JSON, as JavaScript allows sharing configurations through import / export (and it's just nicer than JSON). Haven't found Prettier exposing any API for reading the config file, but it does state in the docs it uses cosmiconfig. It would be great if swagger-to-ts also used cosmiconfig to read any Prettier config file.

@drwpow
Copy link
Contributor

drwpow commented Apr 26, 2020

That’s a good idea! I think that’s a great add. I’d love a PR if you have time, but if not I’d be happy to add this.

@ikornienko
Copy link
Author

Thanks, @DangoDev! Unfortunately, I cannot commit to creating a PR in any short-term future. If you have capacity to do it, please go for it.

@drwpow
Copy link
Contributor

drwpow commented Apr 26, 2020

No worries. I’ll see if I can get this in for the 2.0 launch. Thanks again for the issue!

@drwpow
Copy link
Contributor

drwpow commented Apr 27, 2020

Just released a new next version to npm that uses Prettier’s resolveConfig option instead to support all the configurations Prettier does. Give it a try:

npx @manifoldco/swagger-to-ts@next …

I added a test and confirmed that .js format is working, but I didn’t test out all the different Prettier configurations (hopefully Prettier handles that for us!). Please let me know if you still experience the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants