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

File created with mix of single and double quotes #44

Closed
benmccann opened this issue Sep 27, 2024 · 6 comments · Fixed by #96 · May be fixed by #380
Closed

File created with mix of single and double quotes #44

benmccann opened this issue Sep 27, 2024 · 6 comments · Fixed by #96 · May be fixed by #380

Comments

@benmccann
Copy link
Member

benmccann commented Sep 27, 2024

Can we just use single quotes everywhere?

The Drizzle adder creates the drizzle.config.ts below currently:

if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');

export default defineConfig({
  schema: "./src/lib/server/db/schema.ts",

  dbCredentials: {
    url: process.env.DATABASE_URL
  },

  verbose: true,
  strict: true,
  dialect: "sqlite"
});
@AdrianGonz97
Copy link
Member

This case is a bit tricky because it's a newly created file so the code printer has no frame of reference to determine the style preferences. I guess we could poke around and find a similar file type, but im not quite sure if there's an existing recast api that can help us determine the style preference of any given script.

Implementing #33 may be able to solve this as well.

@benmccann
Copy link
Member Author

I think we should assume single quotes by default since that's what the new template creation will spit out and is typically used in JS. We can try to get fancier later on, but it probably isn't necessary out of the gate

@AdrianGonz97
Copy link
Member

those defaults aren't set by us, they're set by recast. if we were to force an override on the printer to use single quotes, then that override will apply to all generated code (even on existing code that uses double quotes), which isn't preferable

there may be a way to hack it now, but the better fix will be to implement #33, so we may as well hold off on this particular change until then

@manuel3108
Copy link
Member

manuel3108 commented Sep 28, 2024

I mean for the moment we could also only set recast to default to double qoutes, if we know that the file had no content before our modification. But as @AdrianGonz97 suggested, i think we should solve the bigger picture in #33

Edit: Maybe the end result will be a combination of both.

@benmccann
Copy link
Member Author

#33 has been implemented. This is still an issue though. Can we change the default recast setting to single quotes to match the default style for newly created projects? It's not perfect as we'll still have issues for users using double quotes, but should affect fewer users overall

@benmccann benmccann mentioned this issue Oct 11, 2024
24 tasks
@manuel3108
Copy link
Member

Also see: #67 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants