Skip to content

Commit 15ca91f

Browse files
committed
Feat: Implement import order in prettier
- Install sort import plugin - Add import order related setting
1 parent 92c4794 commit 15ca91f

File tree

3 files changed

+135
-3
lines changed

3 files changed

+135
-3
lines changed

.prettierrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
23
"singleQuote": true,
34
"trailingComma": "all",
4-
"importOrder": ["^@nestjs/(.*)$", "^@dms/(.*)$", "^[./]"],
5+
"importOrder": ["^@nestjs/(.*)$", "<THIRD_PARTY_MODULES>", "^src/(.*)$", "^[./]"],
6+
"importOrderSeparation": true,
7+
"importOrderSortSpecifiers": true,
58
"importOrderParserPlugins" : ["typescript", "[\"decorators-legacy\", {\"decoratorsBeforeExport\": true}]"]
69
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@nestjs/cli": "^10.1.10",
6565
"@nestjs/schematics": "^10.0.1",
6666
"@nestjs/testing": "^10.1.2",
67+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
6768
"@types/bcrypt": "^5.0.0",
6869
"@types/cron": "^2.0.1",
6970
"@types/express": "^4.17.17",
@@ -116,4 +117,4 @@
116117
"coverageDirectory": "../coverage",
117118
"testEnvironment": "node"
118119
}
119-
}
120+
}

yarn.lock

+129-1
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,14 @@
878878
dependencies:
879879
"@babel/highlight" "^7.22.5"
880880

881+
"@babel/code-frame@^7.22.13", "@babel/code-frame@^7.23.5":
882+
version "7.23.5"
883+
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244"
884+
integrity sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==
885+
dependencies:
886+
"@babel/highlight" "^7.23.4"
887+
chalk "^2.4.2"
888+
881889
"@babel/compat-data@^7.22.9":
882890
version "7.22.9"
883891
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.9.tgz#71cdb00a1ce3a329ce4cbec3a44f9fef35669730"
@@ -904,6 +912,15 @@
904912
json5 "^2.2.2"
905913
semver "^6.3.1"
906914

915+
"@babel/generator@7.17.7":
916+
version "7.17.7"
917+
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad"
918+
integrity sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==
919+
dependencies:
920+
"@babel/types" "^7.17.0"
921+
jsesc "^2.5.1"
922+
source-map "^0.5.0"
923+
907924
"@babel/generator@^7.22.7", "@babel/generator@^7.22.9", "@babel/generator@^7.7.2":
908925
version "7.22.9"
909926
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.22.9.tgz#572ecfa7a31002fa1de2a9d91621fd895da8493d"
@@ -914,6 +931,16 @@
914931
"@jridgewell/trace-mapping" "^0.3.17"
915932
jsesc "^2.5.1"
916933

934+
"@babel/generator@^7.23.0":
935+
version "7.23.6"
936+
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.23.6.tgz#9e1fca4811c77a10580d17d26b57b036133f3c2e"
937+
integrity sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw==
938+
dependencies:
939+
"@babel/types" "^7.23.6"
940+
"@jridgewell/gen-mapping" "^0.3.2"
941+
"@jridgewell/trace-mapping" "^0.3.17"
942+
jsesc "^2.5.1"
943+
917944
"@babel/helper-compilation-targets@^7.22.9":
918945
version "7.22.9"
919946
resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.9.tgz#f9d0a7aaaa7cd32a3f31c9316a69f5a9bcacb892"
@@ -925,6 +952,11 @@
925952
lru-cache "^5.1.1"
926953
semver "^6.3.1"
927954

955+
"@babel/helper-environment-visitor@^7.22.20":
956+
version "7.22.20"
957+
resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz#96159db61d34a29dba454c959f5ae4a649ba9167"
958+
integrity sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==
959+
928960
"@babel/helper-environment-visitor@^7.22.5":
929961
version "7.22.5"
930962
resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz#f06dd41b7c1f44e1f8da6c4055b41ab3a09a7e98"
@@ -938,6 +970,14 @@
938970
"@babel/template" "^7.22.5"
939971
"@babel/types" "^7.22.5"
940972

973+
"@babel/helper-function-name@^7.23.0":
974+
version "7.23.0"
975+
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz#1f9a3cdbd5b2698a670c30d2735f9af95ed52759"
976+
integrity sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==
977+
dependencies:
978+
"@babel/template" "^7.22.15"
979+
"@babel/types" "^7.23.0"
980+
941981
"@babel/helper-hoist-variables@^7.22.5":
942982
version "7.22.5"
943983
resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz#c01a007dac05c085914e8fb652b339db50d823bb"
@@ -987,6 +1027,16 @@
9871027
resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz#533f36457a25814cf1df6488523ad547d784a99f"
9881028
integrity sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==
9891029

1030+
"@babel/helper-string-parser@^7.23.4":
1031+
version "7.23.4"
1032+
resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz#9478c707febcbbe1ddb38a3d91a2e054ae622d83"
1033+
integrity sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==
1034+
1035+
"@babel/helper-validator-identifier@^7.16.7", "@babel/helper-validator-identifier@^7.22.20":
1036+
version "7.22.20"
1037+
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0"
1038+
integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==
1039+
9901040
"@babel/helper-validator-identifier@^7.22.5":
9911041
version "7.22.5"
9921042
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193"
@@ -1015,11 +1065,25 @@
10151065
chalk "^2.0.0"
10161066
js-tokens "^4.0.0"
10171067

1068+
"@babel/highlight@^7.23.4":
1069+
version "7.23.4"
1070+
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b"
1071+
integrity sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==
1072+
dependencies:
1073+
"@babel/helper-validator-identifier" "^7.22.20"
1074+
chalk "^2.4.2"
1075+
js-tokens "^4.0.0"
1076+
10181077
"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.22.5", "@babel/parser@^7.22.7":
10191078
version "7.22.7"
10201079
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.7.tgz#df8cf085ce92ddbdbf668a7f186ce848c9036cae"
10211080
integrity sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==
10221081

1082+
"@babel/parser@^7.20.5", "@babel/parser@^7.23.0", "@babel/parser@^7.23.9":
1083+
version "7.23.9"
1084+
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.9.tgz#7b903b6149b0f8fa7ad564af646c4c38a77fc44b"
1085+
integrity sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA==
1086+
10231087
"@babel/plugin-syntax-async-generators@^7.8.4":
10241088
version "7.8.4"
10251089
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d"
@@ -1125,6 +1189,15 @@
11251189
dependencies:
11261190
regenerator-runtime "^0.13.11"
11271191

1192+
"@babel/template@^7.22.15":
1193+
version "7.23.9"
1194+
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.23.9.tgz#f881d0487cba2828d3259dcb9ef5005a9731011a"
1195+
integrity sha512-+xrD2BWLpvHKNmX2QbpdpsBaWnRxahMwJjO+KZk2JOElj5nSmKezyS1B4u+QbHMTX69t4ukm6hh9lsYQ7GHCKA==
1196+
dependencies:
1197+
"@babel/code-frame" "^7.23.5"
1198+
"@babel/parser" "^7.23.9"
1199+
"@babel/types" "^7.23.9"
1200+
11281201
"@babel/template@^7.22.5", "@babel/template@^7.3.3":
11291202
version "7.22.5"
11301203
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.5.tgz#0c8c4d944509875849bd0344ff0050756eefc6ec"
@@ -1134,6 +1207,22 @@
11341207
"@babel/parser" "^7.22.5"
11351208
"@babel/types" "^7.22.5"
11361209

1210+
"@babel/traverse@7.23.2":
1211+
version "7.23.2"
1212+
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.23.2.tgz#329c7a06735e144a506bdb2cad0268b7f46f4ad8"
1213+
integrity sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==
1214+
dependencies:
1215+
"@babel/code-frame" "^7.22.13"
1216+
"@babel/generator" "^7.23.0"
1217+
"@babel/helper-environment-visitor" "^7.22.20"
1218+
"@babel/helper-function-name" "^7.23.0"
1219+
"@babel/helper-hoist-variables" "^7.22.5"
1220+
"@babel/helper-split-export-declaration" "^7.22.6"
1221+
"@babel/parser" "^7.23.0"
1222+
"@babel/types" "^7.23.0"
1223+
debug "^4.1.0"
1224+
globals "^11.1.0"
1225+
11371226
"@babel/traverse@^7.22.6", "@babel/traverse@^7.22.8":
11381227
version "7.22.8"
11391228
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.22.8.tgz#4d4451d31bc34efeae01eac222b514a77aa4000e"
@@ -1150,6 +1239,14 @@
11501239
debug "^4.1.0"
11511240
globals "^11.1.0"
11521241

1242+
"@babel/types@7.17.0":
1243+
version "7.17.0"
1244+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b"
1245+
integrity sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==
1246+
dependencies:
1247+
"@babel/helper-validator-identifier" "^7.16.7"
1248+
to-fast-properties "^2.0.0"
1249+
11531250
"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.22.5", "@babel/types@^7.3.3":
11541251
version "7.22.5"
11551252
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.22.5.tgz#cd93eeaab025880a3a47ec881f4b096a5b786fbe"
@@ -1159,6 +1256,15 @@
11591256
"@babel/helper-validator-identifier" "^7.22.5"
11601257
to-fast-properties "^2.0.0"
11611258

1259+
"@babel/types@^7.17.0", "@babel/types@^7.23.0", "@babel/types@^7.23.6", "@babel/types@^7.23.9":
1260+
version "7.23.9"
1261+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.9.tgz#1dd7b59a9a2b5c87f8b41e52770b5ecbf492e002"
1262+
integrity sha512-dQjSq/7HaSjRM43FFGnv5keM2HsxpmyV1PfaSVm0nzzjwwTmjOe6J4bC8e3+pTEIgHaHj+1ZlLThRJ2auc/w1Q==
1263+
dependencies:
1264+
"@babel/helper-string-parser" "^7.23.4"
1265+
"@babel/helper-validator-identifier" "^7.22.20"
1266+
to-fast-properties "^2.0.0"
1267+
11621268
"@bcoe/v8-coverage@^0.2.3":
11631269
version "0.2.3"
11641270
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
@@ -2338,6 +2444,18 @@
23382444
resolved "https://registry.yarnpkg.com/@sqltools/formatter/-/formatter-1.2.5.tgz#3abc203c79b8c3e90fd6c156a0c62d5403520e12"
23392445
integrity sha512-Uy0+khmZqUrUGm5dmMqVlnvufZRSK0FbYzVgp0UMstm+F5+W2/jnEEQyc9vo1ZR/E5ZI/B1WjjoTqBqwJL6Krw==
23402446

2447+
"@trivago/prettier-plugin-sort-imports@^4.3.0":
2448+
version "4.3.0"
2449+
resolved "https://registry.yarnpkg.com/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-4.3.0.tgz#725f411646b3942193a37041c84e0b2116339789"
2450+
integrity sha512-r3n0onD3BTOVUNPhR4lhVK4/pABGpbA7bW3eumZnYdKaHkf1qEC+Mag6DPbGNuuh0eG8AaYj+YqmVHSiGslaTQ==
2451+
dependencies:
2452+
"@babel/generator" "7.17.7"
2453+
"@babel/parser" "^7.20.5"
2454+
"@babel/traverse" "7.23.2"
2455+
"@babel/types" "7.17.0"
2456+
javascript-natural-sort "0.7.1"
2457+
lodash "^4.17.21"
2458+
23412459
"@tsconfig/node10@^1.0.7":
23422460
version "1.0.9"
23432461
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2"
@@ -3617,7 +3735,7 @@ chalk@4.1.2, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
36173735
ansi-styles "^4.1.0"
36183736
supports-color "^7.1.0"
36193737

3620-
chalk@^2.0.0:
3738+
chalk@^2.0.0, chalk@^2.4.2:
36213739
version "2.4.2"
36223740
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
36233741
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
@@ -5329,6 +5447,11 @@ jackspeak@^2.0.3:
53295447
optionalDependencies:
53305448
"@pkgjs/parseargs" "^0.11.0"
53315449

5450+
javascript-natural-sort@0.7.1:
5451+
version "0.7.1"
5452+
resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59"
5453+
integrity sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==
5454+
53325455
jest-changed-files@^29.5.0:
53335456
version "29.5.0"
53345457
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.5.0.tgz#e88786dca8bf2aa899ec4af7644e16d9dcf9b23e"
@@ -7168,6 +7291,11 @@ source-map@0.7.4:
71687291
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656"
71697292
integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==
71707293

7294+
source-map@^0.5.0:
7295+
version "0.5.7"
7296+
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
7297+
integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==
7298+
71717299
source-map@^0.6.0, source-map@^0.6.1:
71727300
version "0.6.1"
71737301
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"

0 commit comments

Comments
 (0)