nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst

Home Page:https://nene.github.io/prettier-sql-playground/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Formatting not working thorough prettierrc

kiwicopple opened this issue · comments

commented

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:

  • It could be a turborepo issue
  • It could be my local settings
  • It could be something I've missed
  • It could be a legitimate bug

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.

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" }
    }
  ]
commented

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

also, TIL about npm why