forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dependency-cruiser.js
148 lines (147 loc) · 4.75 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
extends: 'dependency-cruiser/configs/recommended',
forbidden: [
{
name: 'no-orphans',
severity: 'warn',
from: { orphan: true },
to: {},
},
{
name: 'script-context-not-to-another',
comment: 'One script context must not depend on another',
severity: 'error',
from: { path: '(^src/)([^/]+)/' },
to: { path: '^$1', pathNot: ['$1$2', '^src/shared'] },
},
{
name: 'only-import-state-via-hooks',
severity: 'error',
from: { path: '^src/app/*', pathNot: ['^src/app/store/*'] },
to: {
path: ['^src/app/store/*'],
pathNot: [
`src/app/store/index.ts`,
`src/app.*\.actions\.ts`,
`src/app.*\.selectors\.ts`,
`src/app.*\.hooks\.ts`,
`src/app.*\.models\.ts`,
`src/app.*\.utils\.ts`,
],
},
},
{
name: 'ban-jotai-outside-store',
severity: 'error',
from: { path: '^src', pathNot: ['^src/app/store/*'] },
to: { path: 'jotai*' },
},
{
name: 'component-cannot-import-pages-or-features',
severity: 'error',
from: { path: 'src/app/components*' },
to: { path: ['^src/app/pages*', '^src/app/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/app/features/.*' },
to: { path: '^src/app/pages/.*' },
},
{
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/shared/logger.ts$'] },
to: { path: 'pino' },
},
{
name: 'no-inter-pages-deps',
comment: 'Prohibit dependencies between pages',
severity: 'error',
from: { path: '^src/app/pages/([^/]+)/.+' },
to: {
path: '^src/app/pages/([^/]+)/.+',
pathNot: '^src/app/pages/$1/.+',
},
},
{
name: 'no-feature-component-external-use',
comment: `Only a given feature may import its child 'src/feature/xxx/components'`,
severity: 'error',
from: { path: '(^src/app/features/)([^/]+)' },
to: {
path: '^src/app/features/[^/]+/components',
pathNot: '$1$2/',
},
},
{
name: 'no-feature-component-sibling-use',
comment: `Features cannot depend on a sibling feature's components`,
severity: 'error',
from: { pathNot: ['^src/app/features'] },
to: { path: '^src/app/features/([^/]+)/components' },
},
],
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?))/[^/]+',
},
},
},
};