fix: Fix the sorting of imports (#42419)

This PR switches the sort imports plugin to
@ianvs/prettier-plugin-sort-imports which is more reliable and merges
imports from the same file (the old one reported them as error).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Updated import-sorting tooling and related configuration to improve
consistency of import ordering and formatting across the codebase,
simplifying rules and adjusting behavior for private/internal paths to
produce more predictable diffs and clearer code style in development.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Ivan Vasilov
2026-02-03 20:09:16 +01:00
committed by GitHub
parent aaa268da24
commit 3a391d4f6b
3 changed files with 39 additions and 63 deletions

View File

@@ -44,7 +44,7 @@
},
"devDependencies": {
"@aws-sdk/client-secrets-manager": "^3.823.0",
"@trivago/prettier-plugin-sort-imports": "^6.0.0",
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
"@types/node": "catalog:",
"eslint": "^9.0.0",
"prettier": "3.2.4",

89
pnpm-lock.yaml generated
View File

@@ -95,9 +95,9 @@ importers:
'@aws-sdk/client-secrets-manager':
specifier: ^3.823.0
version: 3.823.0
'@trivago/prettier-plugin-sort-imports':
specifier: ^6.0.0
version: 6.0.0(@vue/compiler-sfc@3.5.21)(prettier@3.2.4)(supports-color@8.1.1)
'@ianvs/prettier-plugin-sort-imports':
specifier: ^4.7.0
version: 4.7.0(@vue/compiler-sfc@3.5.21)(prettier@3.2.4)(supports-color@8.1.1)
'@types/node':
specifier: 'catalog:'
version: 22.13.14
@@ -4222,6 +4222,24 @@ packages:
resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==}
engines: {node: '>=18.18'}
'@ianvs/prettier-plugin-sort-imports@4.7.0':
resolution: {integrity: sha512-soa2bPUJAFruLL4z/CnMfSEKGznm5ebz29fIa9PxYtu8HHyLKNE1NXAs6dylfw1jn/ilEIfO2oLLN6uAafb7DA==}
peerDependencies:
'@prettier/plugin-oxc': ^0.0.4
'@vue/compiler-sfc': 2.7.x || 3.x
content-tag: ^4.0.0
prettier: 2 || 3 || ^4.0.0-0
prettier-plugin-ember-template-tag: ^2.1.0
peerDependenciesMeta:
'@prettier/plugin-oxc':
optional: true
'@vue/compiler-sfc':
optional: true
content-tag:
optional: true
prettier-plugin-ember-template-tag:
optional: true
'@iconify/types@2.0.0':
resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}
@@ -9174,25 +9192,6 @@ packages:
resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==}
engines: {node: '>= 10'}
'@trivago/prettier-plugin-sort-imports@6.0.0':
resolution: {integrity: sha512-Xarx55ow0R8oC7ViL5fPmDsg1EBa1dVhyZFVbFXNtPPJyW2w9bJADIla8YFSaNG9N06XfcklA9O9vmw4noNxkQ==}
engines: {node: '>= 20'}
peerDependencies:
'@vue/compiler-sfc': 3.x
prettier: 2.x - 3.x
prettier-plugin-ember-template-tag: '>= 2.0.0'
prettier-plugin-svelte: 3.x
svelte: 4.x || 5.x
peerDependenciesMeta:
'@vue/compiler-sfc':
optional: true
prettier-plugin-ember-template-tag:
optional: true
prettier-plugin-svelte:
optional: true
svelte:
optional: true
'@ts-morph/common@0.23.0':
resolution: {integrity: sha512-m7Lllj9n/S6sOkCkRftpM7L24uvmfXQFedlW/4hENcuJH1HHm9u5EgxZb9uVjQSCGrbBWBkOGgcTxNg36r6ywA==}
@@ -13995,9 +13994,6 @@ packages:
engines: {node: '>=10'}
hasBin: true
javascript-natural-sort@0.7.1:
resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==}
jest-diff@29.7.0:
resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@@ -15941,9 +15937,6 @@ packages:
resolution: {integrity: sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==}
engines: {node: '>=0.8'}
parse-imports-exports@0.2.4:
resolution: {integrity: sha512-4s6vd6dx1AotCx/RCI2m7t7GCh5bDRUtGNvRfHSP2wbBQdMi67pPe7mtzmgwcaQ8VKK/6IB7Glfyu3qdZJPybQ==}
parse-json@4.0.0:
resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==}
engines: {node: '>=4'}
@@ -15970,9 +15963,6 @@ packages:
parse-path@7.1.0:
resolution: {integrity: sha512-EuCycjZtfPcjWk7KTksnJ5xPMvWGA/6i4zrLYhRG0hGvC3GPU/jGUj3Cy+ZR0v30duV3e23R95T1lE2+lsndSw==}
parse-statements@1.0.11:
resolution: {integrity: sha512-HlsyYdMBnbPQ9Jr/VgJ1YF4scnldvJpJxCVx6KgqPL4dxppsWrJHCIIxQXMJrqGnsRkNPATbeMJ8Yxu7JMsYcA==}
parse-url@9.2.0:
resolution: {integrity: sha512-bCgsFI+GeGWPAvAiUv63ZorMeif3/U0zaXABGJbOWt5OH2KCaPHF6S+0ok4aqM9RuIPGyZdx9tR9l13PsW4AYQ==}
engines: {node: '>=14.13.0'}
@@ -22462,6 +22452,19 @@ snapshots:
'@humanwhocodes/retry@0.4.3': {}
'@ianvs/prettier-plugin-sort-imports@4.7.0(@vue/compiler-sfc@3.5.21)(prettier@3.2.4)(supports-color@8.1.1)':
dependencies:
'@babel/generator': 7.28.3
'@babel/parser': 7.28.4
'@babel/traverse': 7.28.4(supports-color@8.1.1)
'@babel/types': 7.28.4
prettier: 3.2.4
semver: 7.7.3
optionalDependencies:
'@vue/compiler-sfc': 3.5.21
transitivePeerDependencies:
- supports-color
'@iconify/types@2.0.0': {}
'@iconify/utils@3.0.2(supports-color@8.1.1)':
@@ -28593,22 +28596,6 @@ snapshots:
'@tootallnate/once@2.0.0':
optional: true
'@trivago/prettier-plugin-sort-imports@6.0.0(@vue/compiler-sfc@3.5.21)(prettier@3.2.4)(supports-color@8.1.1)':
dependencies:
'@babel/generator': 7.28.3
'@babel/parser': 7.28.4
'@babel/traverse': 7.28.4(supports-color@8.1.1)
'@babel/types': 7.28.4
javascript-natural-sort: 0.7.1
lodash-es: 4.17.23
minimatch: 9.0.5
parse-imports-exports: 0.2.4
prettier: 3.2.4
optionalDependencies:
'@vue/compiler-sfc': 3.5.21
transitivePeerDependencies:
- supports-color
'@ts-morph/common@0.23.0':
dependencies:
fast-glob: 3.3.3
@@ -34164,8 +34151,6 @@ snapshots:
filelist: 1.0.4
minimatch: 3.1.2
javascript-natural-sort@0.7.1: {}
jest-diff@29.7.0:
dependencies:
chalk: 4.1.2
@@ -37074,10 +37059,6 @@ snapshots:
map-cache: 0.2.2
path-root: 0.1.1
parse-imports-exports@0.2.4:
dependencies:
parse-statements: 1.0.11
parse-json@4.0.0:
dependencies:
error-ex: 1.3.2
@@ -37106,8 +37087,6 @@ snapshots:
dependencies:
protocols: 2.0.2
parse-statements@1.0.11: {}
parse-url@9.2.0:
dependencies:
'@types/parse-path': 7.1.0

View File

@@ -15,16 +15,13 @@ let options = {
],
}
// Disable sorting imports when running a prettier command in CI. This is to make the sorting work in editors
// for easier migration.
// Disable sorting imports when running a prettier command in CI. This is to make the sorting work in editors
// for easier migration.
if (process.env.SORT_IMPORTS !== 'false') {
options = {
...options,
plugins: [...options.plugins, '@trivago/prettier-plugin-sort-imports'],
importOrder: ['<THIRD_PARTY_MODULES>', '^(@|\.{1,2})\/(.*)$'],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
importOrderSideEffects: false,
plugins: [...options.plugins, '@ianvs/prettier-plugin-sort-imports'],
importOrder: ['<THIRD_PARTY_MODULES>', '', '^(@|\\.{1,2})/(.*)$'],
}
}