forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.dependency-cruiser.js
129 lines (128 loc) · 4.08 KB
/
.dependency-cruiser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
extends: 'dependency-cruiser/configs/recommended',
forbidden: [
{
name: 'no-orphans',
severity: 'warn',
from: { orphan: true },
to: {},
},
{
name: 'only-import-state-via-hooks',
severity: 'error',
from: { path: '^src/*', pathNot: ['^src/store/*'] },
to: {
path: ['^src/store/*'],
pathNot: [`src.*\.hooks\.ts`, `src.*\.models\.ts`, `src.*\.utils\.ts`],
},
},
{
name: 'ban-jotai-outside-store',
severity: 'error',
from: { path: '^src/*', pathNot: ['^src/store/*'] },
to: { path: 'jotai*' },
},
{
name: 'component-cannot-import-pages-or-features',
severity: 'error',
from: { path: 'src/components*' },
to: { path: ['^src/pages*', '^src/features/*'] },
},
{
name: 'no-circular',
severity: 'warn',
comment:
'This dependency is part of a circular relationship. You might want to revise ' +
'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
from: {},
to: { circular: true },
},
// @kyranjamie: imo components in `components/` should be dumb
// so would be nice to enable this rule, though following state
// refactor, this has been disabled to be more permissive
// {
// name: 'components-must-not-import-store',
// severity: 'error',
// from: { path: '^src/components/.*' },
// to: { path: '^src/store/.*' },
// },
{
name: 'features-cannot-import-pages',
severity: 'error',
from: { path: '^src/features/.*' },
to: { path: '^src/pages/.*' },
},
{
name: 'background-cannot-import-content-scripts',
severity: 'error',
from: { path: '^src/background/.*' },
to: { path: '^src/content-scripts/.*' },
},
{
name: 'content-cannot-import-background-script',
severity: 'error',
from: { path: '^src/content-scripts/.*' },
to: { path: '^src/background/.*' },
},
{
name: 'only-allow-react-icons-fi',
comment: 'Ensure only icons from `fi` group are allowed',
severity: 'error',
from: { path: '^src' },
to: { path: 'react-icons.*', pathNot: 'react-icons/fi' },
},
{
name: 'no-using-pino-directly',
comment: 'Enforce use of Pino logging library via @logger wrapper',
severity: 'error',
from: { path: '^src', pathNot: ['^src/common/logger.ts$'] },
to: { path: 'pino' },
},
{
name: 'no-inter-pages-deps',
comment: 'Prohibit dependencies between pages',
severity: 'error',
from: { path: '^src/pages/([^/]+)/.+' },
to: {
path: '^src/pages/([^/]+)/.+',
pathNot: '^src/pages/$1/.+',
},
},
],
options: {
doNotFollow: {
path: 'node_modules',
dependencyTypes: ['npm', 'npm-dev', 'npm-optional', 'npm-peer', 'npm-bundled', 'npm-no-pkg'],
},
webpackConfig: {
fileName: './webpack/webpack.config.prod.js',
},
tsConfig: {
fileName: 'tsconfig.json',
},
tsPreCompilationDeps: true,
enhancedResolveOptions: {
exportsFields: ['exports'],
conditionNames: ['import', 'require', 'node', 'default'],
},
reporterOptions: {
dot: {
/* pattern of modules that can be consolidated in the detailed
graphical dependency graph. The default pattern in this configuration
collapses everything in node_modules to one folder deep so you see
the external modules, but not the innards your app depends upon.
*/
collapsePattern: 'node_modules/[^/]+',
},
archi: {
/* pattern of modules that can be consolidated in the high level
graphical dependency graph. If you use the high level graphical
dependency graph reporter (`archi`) you probably want to tweak
this collapsePattern to your situation.
*/
collapsePattern: '^(node_modules|packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+',
},
},
},
};