🌐
Reddit
reddit.com › r/sveltejs › are you using any plugins to organise import order?
r/sveltejs on Reddit: Are you using any plugins to organise import order?
September 28, 2022 -

I have been searching for a way to sort imports in Svelte files. Previously I've used trivago/prettier-plugin-sort-imports but that does not yet work well for Svelte. Does anyone have any other suggestions?

🌐
GitHub
github.com › sveltejs › prettier-plugin-svelte › issues › 229
Combine exports and imports · Issue #229 · sveltejs/prettier-plugin-svelte
September 23, 2020 - Hi, I would like to know if the plugin supports combining all exports at one place and all exports to one place. If not could this be marked as a feat request? For instance if this is the original code · export let var1; import { Chart } from '@abc/xyz'; export let var2 = 400; import { onMount, afterUpdate, onDestroy } from 'svelte'; The code after running prettier could become ·
Published   May 19, 2021
🌐
Gebna
gebna.gg › blog › auto-sort-imports-prettier
Automatically Sort Your Imports Using This Prettier Plugin
June 1, 2025 - pnpm add -D @ianvs/prettier-plugin-sort-imports · Now all you need is to add it to the plugins array in your prettier config file: .prettierrc · { "useTabs": true, "singleQuote": true, "trailingComma": "es5", "printWidth": 100, "htmlWhitespaceSensitivity": "ignore", "plugins": [ "prettier-plugin-svelte", "prettier-plugin-tailwindcss", "@ianvs/prettier-plugin-sort-imports" ], "overrides": [ { "files": "*.svelte", "options": { "parser": "svelte" } } ] } You can stop here.
🌐
GitHub
github.com › sveltejs › prettier-plugin-svelte
GitHub - sveltejs/prettier-plugin-svelte: Format your svelte components using prettier.
Sort order for svelte:options, scripts, markup, and styles. Format: join the keywords options, scripts, markup, styles with a - in the order you want; or none if you don't want Prettier to reorder anything.
Starred by 807 users
Forked by 98 users
Languages   TypeScript 64.7% | HTML 34.4% | JavaScript 0.9%
🌐
npm
npmjs.com › package › prettier-plugin-organize-imports
prettier-plugin-organize-imports - npm
Make sure that your import statements ... are. A plugin that makes Prettier organize your imports (i. e. sorts, combines and removes unused ones) using the organizeImports feature of the TypeScript language service API...
      » npm install prettier-plugin-organize-imports
    
Published   Sep 18, 2025
Version   4.3.0
Author   Simon Haenisch
🌐
GitHub
github.com › simonhaenisch › prettier-plugin-organize-imports › issues › 39
[Feature request] Add Svelte support · Issue #39 · simonhaenisch/prettier-plugin-organize-imports
Hey, yeah it's probably doable but I haven't worked with Svelte yet and even though I'd love to, I currently don't have the time. PRs are welcome ... # Motivation To ease the review of PR and to improve our DX, automatically organize and sort the `import` # Changes - add [prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports) # Note - the plugin does not organize imports in `.svelte` [yet](simonhaenisch/prettier-plugin-organize-imports#39) but will do so in all other files (all `.ts` and `.spec.ts` files)
Published   Oct 26, 2021
Author   danielquintero
🌐
Haseeb Majid
haseebmajid.dev › posts › how to autosort our sveltekit imports
How to Autosort our SvelteKit Imports | Haseeb Majid
January 4, 2026 - module.exports = { root: true, parser: '@typescript-eslint/parser', parserOptions: { project: './tsconfig.json', extraFileExtensions: ['.svelte'] }, extends: [ 'eslint:recommended', 'plugin:svelte/recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'plugin:import/errors', 'plugin:import/warnings', 'plugin:import/typescript' ], plugins: ['@typescript-eslint'], ignorePatterns: ['*.cjs'], overrides: [ { files: ['*.svelte'], parser: 'svelte-eslint-parser', parserOptions: { parser: '@typescript-eslint/parser' } } ], rules: { 'import/order': [ 'warn', { alphabetize: { order: 'asc', caseInsensitive: true }, 'newlines-between': 'always' } ] }, settings: { 'svelte3/typescript': () => require('typescript') }, parserOptions: { sourceType: 'module', ecmaVersion: 2020 }, env: { browser: true, es2017: true, node: true } };
🌐
GitHub
github.com › sveltejs › language-tools › issues › 1649
prettier-plugin-organize-imports needs some help :) · Issue #1649 · sveltejs/language-tools
It might also be easier for you as it won't need jsx configs in the tsconfig, the namespace is svelteHTML but it probably won't matter much for your use case. emitOnTemplateError should be true. accessors didn't matter much. run the organize-import from the ts language service and sourcemap the result back to the original file. By the start and end of the range. And then apply some logic to fix the indent and the possible sourcemap errors. language-tools/packages/language-server/src/plugins/typescript/features/CodeActionsProvider.ts
Published   Sep 20, 2022
Author   benallfree
🌐
GitHub
github.com › trivago › prettier-plugin-sort-imports › discussions › 282
Sorting of .svelte file import does not work with sveltekit2 and prettier3 · trivago/prettier-plugin-sort-imports · Discussion #282
{ "semi": false, "useTabs": false, "singleQuote": true, "trailingComma": "all", "printWidth": 100, "plugins": [ "prettier-plugin-svelte", "@trivago/prettier-plugin-sort-imports", "prettier-plugin-css-order" ], "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }], "importOrder": ["^@", "^[^$@.~]", "^\\$", "^\\.\\.", "^\\.", "^~"], "importOrderSortSpecifiers": true, "cssDeclarationSorterOrder": "alphabetical" }
Author   trivago
Find elsewhere
🌐
Prettier
prettier.io › docs › plugins
Plugins · Prettier
Thus, the two print functions – the one from the core and the one from the plugin – call each other while descending down the AST recursively. Here’s a simplified example to give an idea of what a typical implementation of print looks like: import * as prettier from "prettier"; const { group, indent, join, line, softline } = prettier.doc.builders; function print(path, options, print) { const node = path.node; switch (node.type) { case "list": return group([ "(", indent([softline, join(line, path.map(print, "elements"))]), softline, ")", ]); case "pair": return group([ "(", indent([softline, print("left"), line, ".
🌐
DEV Community
dev.to › kachidk › common-prettier-plugins-installation-30hc
Common Prettier Plugins & Installation - DEV Community
February 29, 2024 - // prettier.config.js module.exports = { plugins: ['prettier-plugin-organize-imports', 'prettier-plugin-tailwindcss'], }
🌐
npm
npmjs.com › package › prettier-plugin-svelte
prettier-plugin-svelte - npm
Prettier loads plugins from the plugin array differently. If you have used require.resolve("prettier-plugin-svelte") in your .prettierrc.cjs to tell Prettier where to find the plugin, you may need to remove that and just write "prettier-plugin-svelte" instead
      » npm install prettier-plugin-svelte
    
Published   Feb 18, 2026
Version   3.5.0
Author   James Birtles
🌐
Allandeutsch
allandeutsch.com › notes › lint-format-svelte
Linting and formatting a svelte project - Allan Deutsch
npm i -D prettier@3.2.5 npm i -D prettier-plugin-organize-imports@3.2.4 npm i -D prettier-plugin-svelte@3.2.2 npm i -D prettier-plugin-tailwindcss@0.5.13
🌐
Stack Overflow
stackoverflow.com › questions › 70429784 › disable-prettier-plugin-for-specific-directory
disable prettier plugin for specific directory - Stack Overflow
@compos from the repo, prettier-plugin-organize-imports only support .js, .jsx, .ts, .tsx and .vue files so .svelte aren't affected by the plugin 2021-12-23T11:13:29.25Z+00:00
🌐
Reddit
reddit.com › r/neovim › format svelte files with conform.nvim and prettierd
r/neovim on Reddit: Format svelte files with conform.nvim and prettierd
March 8, 2025 -

I'm working with svelte and until now I was formatting files with the LSP. However I wanted to format the imports and added prettierd and a prettier pluguin to format my imports. I configured conform.nvim as

opts = {
  formatters_by_ft = {
    lua = { "stylua" },
    javascript = { "prettierd" },
    typescript = { "prettierd" },
    svelte = { "prettierd" },
  },
  format_on_save = {
    timeout_ms = 500,
    async = false,
    lsp_format = "fallback",
  },
},

But I'm not getting svelte files formatted, if I delete typescript and svelte lines then I get to format with the LSP. I changed prettierd to prettier just to make sure conform was being called and it was. And if I run npx prettier --write "src/**/*.{js,ts,svelte}" imports are formatted as expected.

So I'm a bit lost;

are prettierd and svelteLSP incompatible?

how could I add import formatting to my svelte files?

And, what are the accepted fields of formatters_by_ft?

thank you

🌐
GitHub
github.com › sveltejs › prettier-plugin-svelte › issues › 407
Prettier does not format .svelte files when run with "prettier --write ." · Issue #407 · sveltejs/prettier-plugin-svelte
October 30, 2023 - { "useTabs": true, "singleQuote": true, "trailingComma": "none", "printWidth": 100, "plugins": ["prettier-plugin-svelte", "prettier-plugin-organize-imports"], "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] } Note that with or without the overrides.
Published   Oct 30, 2023
🌐
npm
npmjs.com › package › @trivago › prettier-plugin-sort-imports
@trivago/prettier-plugin-sort-imports - npm
A prettier plugin to sort import declarations by provided Regular Expression order.
      » npm install @trivago/prettier-plugin-sort-imports
    
Published   Jan 07, 2026
Version   6.0.2
Author   Ayush Sharma
🌐
Bjorn Lu
bjornlu.com › blog › my-svelte-code-ordering-style
My Svelte Code Ordering Style - Bjorn Lu
Formatting Svelte code with Prettier is just half the story, the script tag is where the magic happens, but there's no formal way to organize it. Over time I picked up a pattern to help with readabilty, code flow, and familiarity. Feel free to use and tweak it to your own style.
🌐
npm
npmjs.com › package › @ianvs › prettier-plugin-sort-imports
@ianvs/prettier-plugin-sort-imports - npm
Latest version: 4.7.1, last published: a month ago. Start using @ianvs/prettier-plugin-sort-imports in your project by running `npm i @ianvs/prettier-plugin-sort-imports`. There are 239 other projects in the npm registry using ...
      » npm install @ianvs/prettier-plugin-sort-imports