@ankhorage/devtools 1.0.5 → 1.0.6
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.
- package/README.md +36 -2
- package/dist/knip.d.ts +7 -0
- package/dist/knip.js +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Shared ESLint, Prettier, and Knip configuration for modern TypeScript projects.
|
|
|
16
16
|
- Flat ESLint config (latest standard)
|
|
17
17
|
- Preconfigured plugin ecosystem
|
|
18
18
|
- Prettier integration
|
|
19
|
-
- Shared Knip config
|
|
19
|
+
- Shared Knip config factories
|
|
20
20
|
- `ankhorage-eslint`, `ankhorage-prettier`, and `ankhorage-knip` binaries
|
|
21
21
|
- Monorepo-friendly
|
|
22
22
|
|
|
@@ -98,7 +98,41 @@ export default createKnipConfig({
|
|
|
98
98
|
});
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
For workspaces-based monorepos, use the monorepo preset:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { createKnipMonorepoConfig } from '@ankhorage/devtools/knip';
|
|
105
|
+
|
|
106
|
+
export default createKnipMonorepoConfig({
|
|
107
|
+
root: {
|
|
108
|
+
ignoreFiles: ['.prettierrc.js', 'eslint.config.js'],
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
By default, the monorepo preset configures Knip workspaces for the root package, `packages/*`, and `apps/*`. Repos can override those defaults or add extra workspace globs:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { createKnipMonorepoConfig } from '@ankhorage/devtools/knip';
|
|
117
|
+
|
|
118
|
+
export default createKnipMonorepoConfig({
|
|
119
|
+
workspaceGlobs: ['packages/*', 'apps/*', 'examples/*'],
|
|
120
|
+
workspaceDefaults: {
|
|
121
|
+
ignoreFiles: ['fixtures/**'],
|
|
122
|
+
},
|
|
123
|
+
workspaces: {
|
|
124
|
+
'.': {
|
|
125
|
+
ignoreFiles: ['.prettierrc.js', 'eslint.config.js'],
|
|
126
|
+
},
|
|
127
|
+
'apps/editor': {
|
|
128
|
+
ignoreFiles: ['babel.config.js'],
|
|
129
|
+
ignoreDependencies: ['babel-preset-expo'],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The shared config intentionally keeps defaults narrow so Knip can still report real unused files, exports, dependencies, and binaries. Prefer explicit `entry`, `project`, `ignoreBinaries`, `ignoreDependencies`, or `ignoreFiles` over broad ignores.
|
|
102
136
|
|
|
103
137
|
### CI
|
|
104
138
|
|
package/dist/knip.d.ts
CHANGED
|
@@ -10,4 +10,11 @@ export interface DevtoolsKnipWorkspaceConfigOptions {
|
|
|
10
10
|
export interface DevtoolsKnipConfigOptions extends DevtoolsKnipWorkspaceConfigOptions {
|
|
11
11
|
workspaces?: Record<string, DevtoolsKnipWorkspaceConfigOptions>;
|
|
12
12
|
}
|
|
13
|
+
export interface DevtoolsKnipMonorepoConfigOptions {
|
|
14
|
+
root?: DevtoolsKnipWorkspaceConfigOptions;
|
|
15
|
+
workspaceDefaults?: DevtoolsKnipWorkspaceConfigOptions;
|
|
16
|
+
workspaceGlobs?: string[];
|
|
17
|
+
workspaces?: Record<string, DevtoolsKnipWorkspaceConfigOptions>;
|
|
18
|
+
}
|
|
13
19
|
export declare function createKnipConfig(options?: DevtoolsKnipConfigOptions): KnipConfig;
|
|
20
|
+
export declare function createKnipMonorepoConfig(options?: DevtoolsKnipMonorepoConfigOptions): KnipConfig;
|
package/dist/knip.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const DEFAULT_MONOREPO_WORKSPACE_GLOBS = ['packages/*', 'apps/*'];
|
|
1
2
|
export function createKnipConfig(options = {}) {
|
|
2
3
|
return {
|
|
3
4
|
...(options.entry === undefined ? {} : { entry: options.entry }),
|
|
@@ -11,3 +12,20 @@ export function createKnipConfig(options = {}) {
|
|
|
11
12
|
...(options.workspaces === undefined ? {} : { workspaces: options.workspaces }),
|
|
12
13
|
};
|
|
13
14
|
}
|
|
15
|
+
export function createKnipMonorepoConfig(options = {}) {
|
|
16
|
+
const explicitWorkspaces = options.workspaces ?? {};
|
|
17
|
+
const workspaceGlobs = options.workspaceGlobs ?? [...DEFAULT_MONOREPO_WORKSPACE_GLOBS];
|
|
18
|
+
const workspaces = {
|
|
19
|
+
'.': options.root ?? {},
|
|
20
|
+
};
|
|
21
|
+
for (const workspaceGlob of workspaceGlobs) {
|
|
22
|
+
workspaces[workspaceGlob] = {
|
|
23
|
+
...(options.workspaceDefaults ?? {}),
|
|
24
|
+
...(explicitWorkspaces[workspaceGlob] ?? {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
for (const [workspaceGlob, workspaceConfig] of Object.entries(explicitWorkspaces)) {
|
|
28
|
+
workspaces[workspaceGlob] = workspaceConfig;
|
|
29
|
+
}
|
|
30
|
+
return createKnipConfig({ workspaces });
|
|
31
|
+
}
|