un-ts / prettier

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

sql plugin files types question #202

Closed ssukienn closed 2 years ago

ssukienn commented 2 years ago

Hi. Does this plugin works only for *.sql files or is it also capable of formatting inline sql in javascript/typescript string, literal tag (i.e. sql`...`)?

JounQin commented 2 years ago

https://unpkg.com/browse/prettier-plugin-sql@0.9.0/lib/languages.js

These files are supported for now, not sql tag, and I don't know what it is.

You should add some references for it as a feature request.

JounQin commented 2 years ago

Maybe you mean https://github.com/ruimarinho/sql-tag

ssukienn commented 2 years ago

Maybe you mean https://github.com/ruimarinho/sql-tag

H, yes, thanks for the response. That was exactly my question regarding TS files. That or other (chosen tags) but also normal string literals (why not, if you can see that given string is an SQL query).

From what I can see this plugin is working for SQL related file types so not sure if that would be even in scope.

As this is more complicated with finding SQL in syntax of specific language where there could be strings with expressions that might not be direct correct SQL, but you would like to format them anyway i.e. TS string literal: select ${cols} from ${tab}${whereWithConditions}.

Was looking for something more robust than https://www.npmjs.com/package/eslint-plugin-sql which is quite buggy and unmaintained. It is using eslint to parse ts files. I know prettier is doing it a little differently.

JounQin commented 2 years ago

This is a good-to-have feature request, it requires to extends babel and typescript related parsers.

But it's not in high priority to me, so it would be great if you can raise a PR for it.

I'd like to offer some help if you need.

JounQin commented 2 years ago

How html tag work in prettier core would just be helpful.

ssukienn commented 2 years ago

Thanks for the encouragement and the kind offer but definitely won't have a capacity to dedicate time here :)

JounQin commented 2 years ago

Then no one would offer any effort here.