-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathknip.ts
90 lines (81 loc) · 2.08 KB
/
knip.ts
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
// eslint-disable-next-line import/no-extraneous-dependencies
import { resolveDependenciesSync } from '@graphcommerce/next-config'
import type { KnipConfig } from 'knip'
type WorkspaceEntry = NonNullable<KnipConfig['workspaces']>[string]
const skip: WorkspaceEntry = {
ignore: ['**/*.*'],
}
const asPackageDir: WorkspaceEntry = {
ignore: [
'__tests__',
'__mocks__',
'__fixtures__',
'**/*.interceptor.tsx',
'**/*.interceptor.ts',
'dist',
'index.ts',
'index.js',
'src/index.ts',
],
entry: [
'plugins/**/*.{ts,tsx}',
'src/bin/*.ts',
'**/resolvers.ts',
'**/resolver.ts',
'**/*Resolver.ts',
],
}
const dependencies: Record<string, WorkspaceEntry> = Object.fromEntries(
[...resolveDependenciesSync(`${process.cwd()}/examples/magento-graphcms`).values()]
.slice(1)
.map((dir) => [dir, asPackageDir]),
)
const asNextjsDir: WorkspaceEntry = {
ignore: ['.next', 'public', 'copy/**'],
entry: [
'next.config.js',
'graphcommerce.config.js',
'lingui.config.js',
'next-sitemap.config.js',
'next.config.{ts,cjs,mjs}',
'middleware.{ts}',
'app/**/route.{ts}',
'app/**/{error,layout,loading,not-found,page,template}.{jsx,ts,tsx}',
'instrumentation.{ts}',
'app/{manifest,sitemap,robots}.{ts}',
'app/**/{icon,apple-icon}.{ts,tsx}',
'app/**/{opengraph,twitter}-image.{ts,tsx}',
'pages/**/*.{jsx,ts,tsx}',
'plugins/**/*.{ts,tsx}',
'lib/sw.ts',
],
}
const config: KnipConfig = {
// eslint: false,
// playwright: false,
// next: false,
include: [
'files',
'exports',
'classMembers',
'enumMembers',
'unlisted',
'unresolved',
// Enable when files and exports are handled.
'nsExports',
// 'types',
'nsTypes',
'duplicates',
],
workspaces: {
'packagesDev/*': skip,
'packages/*': skip,
scripts: skip,
...dependencies,
'packages/*/example': asNextjsDir,
'examples/magento-graphcms': asNextjsDir,
'examples/magento-open-source': asNextjsDir,
'packages/hygraph-dynamic-rows-ui': asNextjsDir,
},
}
export default config