-
Notifications
You must be signed in to change notification settings - Fork 14
/
knip.config.ts
107 lines (97 loc) · 2.73 KB
/
knip.config.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import {
type KnipConfigPlugin,
combineNxKnipPlugins,
withEsbuildApps,
withEsbuildPublishableLibs,
withEslint,
withLibraryMapper,
withLocalNxPlugins,
withNxTsPaths,
withVitest,
} from '@beaussan/nx-knip';
const withIgnoreMockInLibs = () =>
withLibraryMapper({
mapperFn: ({ rootFolder }) => {
return {
ignore: [
rootFolder + '/perf/**',
'**/mock/**',
'**/mocks/**',
'**/__snapshots__/**',
],
entry: [rootFolder + '/src/bin.ts', rootFolder + '/perf/**/index.ts'],
};
},
});
const withExamplePlugins = (): KnipConfigPlugin => () => {
return {
// Given there is no publish target, thoes libs were not picked up by the auto discovery
entry: [
'examples/plugins/src/index.ts',
'packages/plugin-lighthouse/src/index.ts',
],
ignore: ['examples/**/constants.ts'],
};
};
const withReactExample = (): KnipConfigPlugin => () => {
return {
entry: [
'examples/react-todos-app/src/index.jsx',
'examples/react-todos-app/test-setup.js',
],
eslint: {
// Given there is no lint target on the project, we need to manually specify the entry point
config: ['examples/react-todos-app/.eslintrc.js'],
},
};
};
const withNxStandards = (): KnipConfigPlugin => () => {
return {
project: ['**/*.{ts,js,tsx,jsx}'],
ignore: ['tmp/**', 'node_modules/**'],
commitlint: {
config: ['commitlint.config.mjs'],
},
exclude: ['duplicates'],
ignoreExportsUsedInFile: true,
entry: [
'**/index.ts',
// unknown why this is needed, it should be picked up by knip from the vitest setup files
'testing/test-{setup,utils}/src/lib/**/*.{js,mjs,ts,cjs,mts,cts}',
'global-setup.*.ts',
// missing knip plugin for now, so this is in the root entry
'packages/models/zod2md.config.ts',
'**/code-pushup.*.{js,mjs,ts,cjs,mts,cts}',
'**/vite.config.*.ts',
'**/*.d.ts',
'esbuild.config.js',
'tools/**/*.{js,mjs,ts,cjs,mts,cts}',
],
ignoreDependencies: [
'@swc/helpers',
'@swc/cli',
'@nx/plugin',
'@nx/workspace',
'@nx/jest',
'@nx/eslint',
// Knip does not pick up this as it is used for TS execution
'tsx',
// Not a npm library, and resolved in a different typescript path than the global import one
'@example/custom-plugin',
'@code-pushup/models',
'@code-pushup/utils',
],
};
};
export default combineNxKnipPlugins(
withNxTsPaths(),
withLocalNxPlugins({ pluginNames: ['nx-plugin'] }),
withEsbuildApps(),
withEsbuildPublishableLibs(),
withVitest(),
withIgnoreMockInLibs(),
withEslint(),
withReactExample(),
withExamplePlugins(),
withNxStandards(),
);