@virmator/deps 13.0.1 → 13.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ {
2
+ "100": true,
3
+ "all": true,
4
+ "checkCoverage": true,
5
+ "clean": true,
6
+ "exclude": [
7
+ "**/*.test.ts",
8
+ "**/*.example.ts",
9
+ "**/*.test-helper.ts"
10
+ ],
11
+ "include": [
12
+ "src/**/*.ts"
13
+ ],
14
+ "perFile": true,
15
+ "reporter": [
16
+ "html",
17
+ "istanbul-smart-text-reporter"
18
+ ],
19
+ "skipFull": true
20
+ }
@@ -0,0 +1,253 @@
1
+ import type {IConfiguration, IForbiddenRuleType} from 'dependency-cruiser';
2
+
3
+ export function generateDepCruiserConfig({
4
+ fileExceptions,
5
+ omitRules,
6
+ }: {
7
+ fileExceptions: Readonly<
8
+ Record<
9
+ string,
10
+ Readonly<
11
+ Partial<{
12
+ to: ReadonlyArray<string> | undefined;
13
+ from: ReadonlyArray<string> | undefined;
14
+ }>
15
+ >
16
+ >
17
+ >;
18
+ omitRules: ReadonlyArray<string>;
19
+ }) {
20
+ const forbiddenRules = [
21
+ /* rules from the 'recommended' preset: */
22
+ {
23
+ name: 'no-circular',
24
+ severity: 'error',
25
+ comment: 'This dependency is part of a circular relationship.',
26
+ from: {},
27
+ to: {
28
+ circular: true,
29
+ },
30
+ },
31
+ {
32
+ name: 'no-orphans',
33
+ comment:
34
+ "This is an orphan module - it's likely not used (anymore?). Either use it or " +
35
+ "remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
36
+ 'add an exception for it in your dependency-cruiser configuration.',
37
+ severity: 'error',
38
+ from: {
39
+ orphan: true,
40
+ pathNot: [
41
+ '\\.d\\.ts$', // TypeScript declaration files
42
+ ],
43
+ },
44
+ to: {},
45
+ },
46
+ {
47
+ name: 'no-deprecated-core',
48
+ comment:
49
+ 'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +
50
+ "bound to exist - node doesn't deprecate lightly.",
51
+ severity: 'error',
52
+ from: {},
53
+ to: {
54
+ dependencyTypes: ['core'],
55
+ path: [
56
+ '^(v8/tools/codemap)$',
57
+ '^(v8/tools/consarray)$',
58
+ '^(v8/tools/csvparser)$',
59
+ '^(v8/tools/logreader)$',
60
+ '^(v8/tools/profile_view)$',
61
+ '^(v8/tools/profile)$',
62
+ '^(v8/tools/SourceMap)$',
63
+ '^(v8/tools/splaytree)$',
64
+ '^(v8/tools/tickprocessor-driver)$',
65
+ '^(v8/tools/tickprocessor)$',
66
+ '^(node-inspect/lib/_inspect)$',
67
+ '^(node-inspect/lib/internal/inspect_client)$',
68
+ '^(node-inspect/lib/internal/inspect_repl)$',
69
+ '^(async_hooks)$',
70
+ '^(punycode)$',
71
+ '^(domain)$',
72
+ '^(constants)$',
73
+ '^(sys)$',
74
+ '^(_linklist)$',
75
+ '^(_stream_wrap)$',
76
+ ],
77
+ },
78
+ },
79
+ {
80
+ name: 'not-to-deprecated',
81
+ comment:
82
+ 'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +
83
+ 'version of that module, or find an alternative. Deprecated modules are a security risk.',
84
+ severity: 'error',
85
+ from: {},
86
+ to: {
87
+ dependencyTypes: ['deprecated'],
88
+ },
89
+ },
90
+ {
91
+ name: 'no-non-package-json',
92
+ severity: 'error',
93
+ comment:
94
+ "This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
95
+ "That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
96
+ 'available on live with an non-guaranteed version. Fix it by adding the package to the dependencies ' +
97
+ 'in your package.json.',
98
+ from: {},
99
+ to: {
100
+ dependencyTypes: [
101
+ 'npm-no-pkg',
102
+ 'npm-unknown',
103
+ ],
104
+ pathNot: [
105
+ '^src/',
106
+ ],
107
+ },
108
+ },
109
+ {
110
+ name: 'not-to-unresolvable',
111
+ comment:
112
+ "This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
113
+ 'module: add it to your package.json. In all other cases you likely already know what to do.',
114
+ severity: 'error',
115
+ from: {},
116
+ to: {
117
+ couldNotResolve: true,
118
+ },
119
+ },
120
+ {
121
+ name: 'no-duplicate-dep-types',
122
+ comment:
123
+ "Likely this module depends on an external ('npm') package that occurs more than once " +
124
+ 'in your package.json i.e. both as a devDependencies and in dependencies. This will cause ' +
125
+ 'maintenance problems later on.',
126
+ severity: 'error',
127
+ from: {},
128
+ to: {
129
+ moreThanOneDependencyType: true,
130
+ // as it's pretty common to have a type import be a type only import
131
+ // _and_ (e.g.) a devDependency - don't consider type-only dependency
132
+ // types for this rule
133
+ dependencyTypesNot: [
134
+ 'type-only',
135
+ ],
136
+ pathNot: [
137
+ '^src/',
138
+ ],
139
+ },
140
+ },
141
+ {
142
+ name: 'not-to-test',
143
+ comment:
144
+ 'This module depends on a test file. The sole responsibility of a test file is to test code. ' +
145
+ "If there's something in a test that's of use to other modules, it doesn't have that single " +
146
+ 'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
147
+ severity: 'error',
148
+ from: {},
149
+ to: {
150
+ path: '\\.test\\.ts$',
151
+ },
152
+ },
153
+ {
154
+ name: 'not-from-mock',
155
+ comment: `This non-test file depends on a mock file. Do not do this.`,
156
+ severity: 'error',
157
+ from: {
158
+ pathNot: '\\.test\\.ts$',
159
+ },
160
+ to: {
161
+ path: '\\.mock\\.ts$',
162
+ },
163
+ },
164
+ {
165
+ name: 'not-to-dev-dep',
166
+ severity: 'error',
167
+ comment:
168
+ "This module depends on an npm package from the 'devDependencies' section of your " +
169
+ 'package.json.',
170
+ from: {
171
+ path: '^(packages)',
172
+ pathNot: [
173
+ '\\.test\\.ts$',
174
+ ],
175
+ },
176
+ to: {
177
+ dependencyTypes: ['npm-dev'],
178
+ },
179
+ },
180
+ {
181
+ name: 'optional-deps-used',
182
+ severity: 'error',
183
+ comment:
184
+ 'This module depends on an npm package that is declared as an optional dependency ' +
185
+ "in your package.json. As this makes sense in limited situations only, it's flagged here. " +
186
+ "If you're using an optional dependency here by design - add an exception to your" +
187
+ 'dependency-cruiser configuration.',
188
+ from: {},
189
+ to: {
190
+ dependencyTypes: ['npm-optional'],
191
+ },
192
+ },
193
+ ] satisfies NonNullable<IConfiguration['forbidden']>;
194
+
195
+ Object.entries(fileExceptions).forEach(
196
+ ([
197
+ ruleName,
198
+ fileExceptions,
199
+ ]) => {
200
+ const rule: IForbiddenRuleType | undefined = forbiddenRules.find(
201
+ (rule) => rule.name === ruleName,
202
+ );
203
+
204
+ if (!rule) {
205
+ throw new Error(`Rule name not used: '${ruleName}'`);
206
+ }
207
+
208
+ const fromPathNot: string[] = rule.from.pathNot
209
+ ? Array.isArray(rule.from.pathNot)
210
+ ? rule.from.pathNot
211
+ : [rule.from.pathNot]
212
+ : [];
213
+ const toPathNot: string[] = rule.to.pathNot
214
+ ? Array.isArray(rule.to.pathNot)
215
+ ? rule.to.pathNot
216
+ : [rule.to.pathNot]
217
+ : [];
218
+
219
+ if (fileExceptions.from?.length) {
220
+ fromPathNot.push(...fileExceptions.from);
221
+ }
222
+ if (fileExceptions.to?.length) {
223
+ toPathNot.push(...fileExceptions.to);
224
+ }
225
+
226
+ if (!rule.from.pathNot) {
227
+ (rule.from as {pathNot: string[]}).pathNot = fromPathNot;
228
+ }
229
+ if (!rule.to.pathNot) {
230
+ (rule.to as {pathNot: string[]}).pathNot = toPathNot;
231
+ }
232
+ },
233
+ );
234
+
235
+ return {
236
+ forbidden: forbiddenRules.filter((rule) => !omitRules.includes(rule.name)),
237
+ options: {
238
+ doNotFollow: {
239
+ dependencyTypes: [
240
+ 'core',
241
+ 'npm',
242
+ 'npm-bundled',
243
+ 'npm-dev',
244
+ 'npm-no-pkg',
245
+ 'npm-optional',
246
+ 'npm-peer',
247
+ 'npm-unknown',
248
+ ],
249
+ },
250
+ tsPreCompilationDeps: true,
251
+ },
252
+ } satisfies IConfiguration;
253
+ }
@@ -0,0 +1,22 @@
1
+ import {generateDepCruiserConfig} from '@virmator/deps/configs/dep-cruiser.config.base';
2
+ import type {IConfiguration} from 'dependency-cruiser';
3
+
4
+ const baseConfig = generateDepCruiserConfig({
5
+ fileExceptions: {
6
+ // enter file exceptions by rule name here
7
+ 'no-orphans': {
8
+ from: [
9
+ 'src/index.ts',
10
+ ],
11
+ },
12
+ },
13
+ omitRules: [
14
+ // enter rule names here to omit
15
+ ],
16
+ });
17
+
18
+ const depCruiserConfig: IConfiguration = {
19
+ ...baseConfig,
20
+ };
21
+
22
+ module.exports = depCruiserConfig;
@@ -0,0 +1,13 @@
1
+ import {RunOptions} from 'npm-check-updates';
2
+ import {ReadonlyDeep} from 'type-fest';
3
+
4
+ export const baseNcuConfig = {
5
+ color: true,
6
+ upgrade: true,
7
+ root: true,
8
+ /** This option is needed otherwise ncu breaks, despite its type not requiring this property. */
9
+ install: 'never',
10
+ reject: [
11
+ // currently there are no deps to avoid updating
12
+ ],
13
+ } as const satisfies ReadonlyDeep<RunOptions>;
@@ -0,0 +1,12 @@
1
+ import {baseNcuConfig} from '@virmator/deps/configs/ncu.config.base';
2
+ import {RunOptions} from 'npm-check-updates';
3
+
4
+ export const ncuConfig: RunOptions = {
5
+ ...baseNcuConfig,
6
+ // exclude these
7
+ reject: [
8
+ ...baseNcuConfig.reject,
9
+ ],
10
+ // include only these
11
+ filter: [],
12
+ };
@@ -0,0 +1,25 @@
1
+ import {baseTypedocConfig} from '@virmator/docs/configs/typedoc.config.base';
2
+ import {join, resolve} from 'path';
3
+ import type {TypeDocOptions} from 'typedoc';
4
+
5
+ const repoRoot = resolve(
6
+ __dirname,
7
+ /** Go up two directories because this gets compiled into `node_modules/.virmator` */
8
+ '..',
9
+ '..',
10
+ );
11
+ const indexTsFile = join(repoRoot, 'src', 'deps.ts');
12
+
13
+ export const typeDocConfig: Partial<TypeDocOptions> = {
14
+ ...baseTypedocConfig,
15
+ out: join(repoRoot, 'dist-docs'),
16
+ entryPoints: [
17
+ indexTsFile,
18
+ ],
19
+ intentionallyNotExported: [],
20
+ defaultCategory: 'MISSING CATEGORY',
21
+ categoryOrder: [
22
+ 'Main',
23
+ 'Internal',
24
+ ],
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/deps",
3
- "version": "13.0.1",
3
+ "version": "13.0.3",
4
4
  "description": "Default TS deps plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@augment-vir/common": "^29.3.0",
37
37
  "@augment-vir/node-js": "^29.3.0",
38
- "@virmator/core": "^13.0.1",
38
+ "@virmator/core": "^13.0.3",
39
39
  "mri": "^1.2.0"
40
40
  },
41
41
  "devDependencies": {