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

Support formatter config files that are not JSON #26

Open
achou11 opened this issue Jan 8, 2025 · 3 comments
Open

Support formatter config files that are not JSON #26

achou11 opened this issue Jan 8, 2025 · 3 comments
Labels
good first issue Good for newcomers

Comments

@achou11
Copy link

achou11 commented Jan 8, 2025

I'm using this plugin in a repo where my prettier config is a module in the form of prettier.config.js. Took me a moment to realize that the plugin attempts to read the file and only uses it if it contains JSON:

https://github.com/forge42dev/vite-plugin-icons-spritesheet/blob/58aeffc8cf0e4f5d5a0b8c952df6a19fae4bc6bf/src/index.ts#L195-L239

Some options that could be considered:

  1. Support non-JSON based config files
  2. Document that the pathToFormatterConfig option must point to a JSON file
  3. Have an option that accepts the parsed config instead of pointing to a path. If you want to be flexible, could have it so that this option accepts either a path to the config file (in which case keeping the existing behavior of pathToFormatterConfig is fine) or the parsed JSON object
@AlemTuzlak
Copy link
Contributor

To be honest I'm not really sure how to pass the parsed js config and actually parse it myself, I'll have to look into that part as I haven't done this before but I'd love to add support for both .js and .rc files

@AlemTuzlak AlemTuzlak added the good first issue Good for newcomers label Jan 9, 2025
@achou11
Copy link
Author

achou11 commented Jan 9, 2025

To be honest I'm not really sure how to pass the parsed js config and actually parse it myself, I'll have to look into that part as I haven't done this before but I'd love to add support for both .js and .rc files

maybe I'm misunderstanding but at least for prettier, you can get the resolved config options by using prettier.resolveConfig()

@achou11
Copy link
Author

achou11 commented Jan 9, 2025

also after seeing #19, my guess is that whatever comes of the discussion there could make this issue irrelevant, which would be great!

@sairus2k sairus2k mentioned this issue Jan 17, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants