I came across this GitHub issue, which helped me resolve the problem.

phongpt156 posted:

"importOrder": ["^[./].*(?<!\\.(c|le|sc)ss)$", "\\.(c|le|sc)ss$"]

The use of the negative lookahead solved it. Hopefully it helps someone

Final

// .prettierrc
{
  "printWidth": 80,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "es5",
  "bracketSpacing": true,
  "arrowParens": "always",
  "importOrder": ["^[./].*(?<!\\.(c|le|sc)ss)$", "\\.(c|le|sc)ss$"],
  "importOrderSeparation": true,
  "importOrderSortSpecifiers": true,
  "plugins": ["@trivago/prettier-plugin-sort-imports"]
}
Answer from nop on Stack Overflow
🌐
GitHub
github.com › trivago › prettier-plugin-sort-imports
GitHub - trivago/prettier-plugin-sort-imports: A prettier plugin to sort imports in typescript and javascript files by the provided RegEx order. · GitHub
A prettier plugin to sort import declarations by provided Regular Expression order.
Starred by 3.9K users
Forked by 157 users
Languages   TypeScript 81.4% | JavaScript 11.0% | Svelte 4.3% | Vue 3.3%
🌐
trivago
tech.trivago.com › presenting @trivago/prettier-plugin-sort-imports
Presenting @trivago/prettier-plugin-sort-imports · trivago tech blog
The @trivago/prettier-plugin-sort-imports prettier plugin sorts the import declarations by using prettier.
🌐
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
🌐
npm
npmjs.com › package › @ianvs › prettier-plugin-sort-imports
@ianvs/prettier-plugin-sort-imports - npm
A prettier plugin to sort import declarations by provided Regular Expression order, while preserving side-effect import order. This project is based on @trivago/prettier-plugin-sort-imports, but adds additional features:
      » npm install @ianvs/prettier-plugin-sort-imports
    
🌐
Medium
medium.com › @diballesteros › how-to-quickly-sort-imports-with-prettier-14f82b16a956
How to quickly sort imports with Prettier | by Diego Ballesteros (Relatable Code) | Medium
March 30, 2022 - This plugin receives an array of strings. It uses these strings to decide the order of our imports! So for example in my small sample project I have the following files: ... So we’ll have to set up the rules to configure them.
🌐
CodeSandbox
codesandbox.io › examples › package › @trivago › prettier-plugin-sort-imports
@trivago/prettier-plugin-sort-imports examples - CodeSandbox
Use this online @trivago/prettier-plugin-sort-imports playground to view and fork @trivago/prettier-plugin-sort-imports example apps and templates on CodeSandbox.
🌐
GitHub
github.com › trivago › prettier-plugin-sort-imports › releases
Releases · trivago/prettier-plugin-sort-imports
A prettier plugin to sort imports in typescript and javascript files by the provided RegEx order. - trivago/prettier-plugin-sort-imports
Author   trivago
Find elsewhere
🌐
DEV Community
dev.to › diballesteros › how-to-quickly-sort-imports-with-prettier-3po7
How to quickly sort imports with Prettier - DEV Community
March 30, 2022 - This plugin receives an array of strings. It uses these strings to decide the order of our imports! So for example in my small sample project I have the following files: So we’ll have to set up the rules to configure them.
🌐
Stack Overflow
stackoverflow.com › questions › 76127977 › prettier-plugin-sort-imports-ignores-import-order
node.js - prettier-plugin-sort-imports ignores import order - Stack Overflow
I'm considering opening up some sort of bug report ticket. Though I don't see what could cause the issue. It is clearly doing something different, just not what it is being told lol ... For me it was something stupid, I think I put @components instead of @/components so that was the difference I think, check for that and if that does not work double check your regexes. Hope it works for you too! ... Something like this will get you far. { "importOrder": ["^react", "^.(css|scss)$", "<THIRD_PARTY_MODULES>", "^components/(.*)$", "^[./]"], "importOrderSeparation": true, "importOrderSortSpecifiers": true }
🌐
GitHub
github.com › trivago › prettier-plugin-sort-imports › blob › main › docs › TROUBLESHOOTING.md
prettier-plugin-sort-imports/docs/TROUBLESHOOTING.md at main · trivago/prettier-plugin-sort-imports
A prettier plugin to sort imports in typescript and javascript files by the provided RegEx order. - prettier-plugin-sort-imports/docs/TROUBLESHOOTING.md at main · trivago/prettier-plugin-sort-imports
Author   trivago
🌐
GitHub
github.com › IanVS › prettier-plugin-sort-imports
GitHub - IanVS/prettier-plugin-sort-imports: An opinionated but flexible prettier plugin to sort import statements · GitHub
A prettier plugin to sort import declarations by provided Regular Expression order, while preserving side-effect import order. This project is based on @trivago/prettier-plugin-sort-imports, but adds additional features:
Starred by 1.3K users
Forked by 38 users
Languages   TypeScript 90.1% | JavaScript 7.2% | Vue 2.6% | Astro 0.1%
🌐
GitHub
github.com › orgs › trivago › packages › npm › package › prettier-plugin-sort-imports
Package prettier-plugin-sort-imports · GitHub
trivago / prettier-plugin-sort-imports Public · Notifications · You must be signed in to change notification settings · Fork 152 · Star 3.9k · A prettier plugins to sort imports in provided RegEx order · Learn more about npm packages · ...
🌐
GitHub
github.com › trivago › prettier-plugin-sort-imports › issues › 131
Prettier next (2.6.0) + import order plugin @trivago/prettier-plugin-sort-imports Error Ignored unknown option { importOrderSeparation: true } · Issue #131 · trivago/prettier-plugin-sort-imports
February 25, 2022 - "scripts": { "prettier-check": "prettier --check 'src/**/*.{css,scss,json,html,md,yml,yaml,js,jsx,ts,tsx}'", }, "devDependencies": { ... "@trivago/prettier-plugin-sort-imports": "^3.2.0", "eslint-config-prettier": "^8.4.0", "eslint-plugin-prettier": "^4.0.0", "prettier": "prettier/prettier", ...
Author   alex-athenian
🌐
DEV Community
dev.to › josephciullo › how-to-customize-import-sorting-in-javascript-with-prettier-and-regex-1h8j
Customizing JavaScript Import Sorting in VSCode Using Prettier (and Regex) - DEV Community
January 20, 2024 - @trivago/prettier-plugin-sort-imports: By incorporating this package, we gain the capability to leverage Prettier for not only code formatting but also the systematic arrangement of import statements.
🌐
GitHub
github.com › trivago › prettier-plugin-sort-imports › blob › main › docs › MIGRATION.md
prettier-plugin-sort-imports/docs/MIGRATION.md at main · trivago/prettier-plugin-sort-imports
A prettier plugin to sort imports in typescript and javascript files by the provided RegEx order. - prettier-plugin-sort-imports/docs/MIGRATION.md at main · trivago/prettier-plugin-sort-imports
Author   trivago