un-ts / prettier

:package: Opinionated but Incredible Prettier plugins.
https://prettier.vercel.app
MIT License
261 stars 23 forks source link

[prettier-plugin-sql] prefix option names to prevent name collisions #312

Closed Sec-ant closed 7 months ago

Sec-ant commented 7 months ago

Hi @JounQin

Apologize for bothering 😂.

Some of the option names of prettier-plugin-embed (formatter, language, database) are very common words, especially in language formatting tools like prettier. It seems prettier doesn't have namespaces for different plugins with same option names defined (correct me if I'm wrong). So if a user use this plugin with other plugins, there might be a high risk of name collisions. We were wondering if you would change them to prefixed ones like sqlFormatter, sqlLanguage, sqlDatabase (or unify the latter two into sqlDialect) to mitigate the risk.

Thanks.

JounQin commented 7 months ago

Use overrides instead.

Sec-ant commented 7 months ago

I know overrides but it is file based overriding. However prettier-plugin-embed aims to support formatting embedded templates of different languages in the same file.

JounQin commented 7 months ago

I think that should be supported via embed plugin, instead of reversed.

It should support an option named overrides for example.

Sec-ant commented 7 months ago

I've already implemented an identifier based overriding in my plugin, ugly but working, because prettier doesn't support object type option value for plugins, so I have to use JSON.stringify or an absolute path of a config file.

It is ok if this is not planned. Just want to check if there's a plan

JounQin commented 7 months ago

Yes, I'm also using JSON.stringify hack in the sql plugin.

See also https://github.com/un-ts/prettier/issues/233#issuecomment-1803331128

By the way, I'm using jsox instead of standard JSON because it's much user friendly.


For prettier core, I've raised https://github.com/prettier/prettier/issues/14671 for tracking.

Sec-ant commented 7 months ago

Thanks for the sharing. I'll definitely check this.