Config for SvelteKit #171
babakfp
started this conversation in
Show and tell
Replies: 2 comments 1 reply
-
|
Good idea, thanks for the suggestion, @babakfp. Feel free to edit the title to better describe the config you're sharing. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Much appreciated |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Get Started
First, install the library:
Then, create a file named
prettier.config.js.Configuration
Copy and paste the following configuration into
prettier.config.js:Breakdown of
importOrder"^@(?!/)": Matches imports starting with@not followed by/."^@/"regex. If you don't use the{ "@": "./src" }alias in SvelteKit config, you can replace"^@(?!/)"with"^@"."<THIRD_PARTY_MODULES>": Placeholder for everything else that is not matched by the regexes inimportOrder. For more details, refer to the documentation."^\\$": Matches imports starting with$."$env/static/public"."^@/": Matches imports starting with@/.srcfolder.{ "@": "./src" }alias, this regex is applicable. Otherwise, you can remove it, and replace"^@(?!/)"with"^@"."^[.]": Matches relative imports starting with.(e.g.,./,../,../../).Before and After:
My commit after applying the changes:
babakfp/angle-berry-client@82514fc
Customizing for
$libAliasIf you'r using the
{ $lib: "./src/lib" }alias in your SvelteKit config, adjust theimportOrderas follows:"^@": Imports that start with@. Example"@sveltejs/adapter-vercel"."<THIRD_PARTY_MODULES>": Placeholder for everything else that is not matched by the regexes inimportOrder. For more details, refer to the documentation."^\\$(?!lib/)": Matches imports starting with$but not followed bylib/. Example"$env/static/public""^\\$lib/": Matches import statements that start with$lib/."^[.]": Matches relative imports starting with.(e.g.,./,../,../../).That's all! Now you can run
prettier --write .to format your code according to the new configuration.More customization?
Just copy and paste one of the above configs to ChatGPT and ask it to make the changes for you :)
Beta Was this translation helpful? Give feedback.
All reactions