nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst
https://nene.github.io/prettier-sql-playground/
GNU General Public License v3.0
123 stars 7 forks source link

Formatting not working thorough prettierrc #1

Closed kiwicopple closed 1 year ago

kiwicopple commented 1 year ago

Hey nene, picking up from my conversation here

I'm testing this on our main repo, but for some reason I can't get it working https://github.com/supabase/supabase/pull/12577/files#r1113003143

Thoughts:

Let me know if you have any pointers. I really like the direction this repo is going, and I think it will be useful to supabase. we'd eventually need a full postgres parser, but for now I'm happy to use the default sql and help you iterate.

nene commented 1 year ago

The problem is that supabase also depends on prettier-plugin-sql, which also registers itself as a formatter for SQL files and happens to win out.

npm why prettier-plugin-sql tells me:

prettier-plugin-sql@0.12.1 dev
node_modules/prettier-plugin-sql
  prettier-plugin-sql@"^0.12.1" from @supabase/postgres-meta@0.60.7
  node_modules/@supabase/postgres-meta
    dev @supabase/postgres-meta@"^0.60.2" from studio@0.0.9
    studio
      studio@0.0.9
      node_modules/studio
        workspace studio from the root project

If you don't want to remove the other library, you can also force Prettier to use this one by overriding the parser option:

  "overrides": [
    {
      "files": ["*.sql"],
      "options": { "sqlKeywordCase": "lower", "parser": "sqlite" }
    }
  ]
kiwicopple commented 1 year ago

thanks @nene - checking with the team if we can remove that dependency in Studio

also, TIL about npm why