Skip to content

Commit 40404d0

Browse files
authored
chore: add import organizer to prettier config (#959)
* chore(web): add import organizer plugin to prettier config * chore(api): add import organizer plugin to prettier config * chore(api): sort imports in notifications resolver & service as a demonstration * chore(web): sort imports in notifications indicator as a demonstration
1 parent 20e43f4 commit 40404d0

File tree

9 files changed

+277
-437
lines changed

9 files changed

+277
-437
lines changed

api/.prettierrc.cjs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
1-
// prettier.config.js or .prettierrc.js
1+
/**
2+
* @see https://prettier.io/docs/en/configuration.html
3+
* @type {import("prettier").Config}
4+
*/
25
module.exports = {
3-
trailingComma: "es5",
6+
trailingComma: 'es5',
47
tabWidth: 4,
58
semi: true,
69
singleQuote: true,
710
printWidth: 105,
11+
plugins: ['@ianvs/prettier-plugin-sort-imports'],
12+
// decorators-legacy lets the import sorter transform files with decorators
13+
importOrderParserPlugins: ['typescript', 'decorators-legacy'],
14+
importOrder: [
15+
/**----------------------
16+
* Nest.js & node.js imports
17+
*------------------------**/
18+
'<TYPES>^@nestjs(/.*)?$',
19+
'^@nestjs(/.*)?$', // matches imports starting with @nestjs
20+
'<TYPES>^(node:)',
21+
'<BUILTIN_MODULES>', // Node.js built-in modules
22+
'',
23+
/**----------------------
24+
* Third party packages
25+
*------------------------**/
26+
'<TYPES>',
27+
'<THIRD_PARTY_MODULES>', // Imports not matched by other special words or groups.
28+
'',
29+
/**----------------------
30+
* Application Code
31+
*------------------------**/
32+
'<TYPES>^@app(/.*)?$', // matches type imports starting with @app
33+
'^@app(/.*)?$',
34+
'',
35+
'<TYPES>^[.]',
36+
'^[.]', // relative imports
37+
],
838
};

0 commit comments

Comments
 (0)