@kitschpatrol/knip-config 5.0.0

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
+ import type { KnipConfig } from 'knip';
2
+ /**
3
+ * Must return a POJO to be merged into package.json
4
+ */
5
+ declare const sharedKnipConfig: KnipConfig;
6
+ /**
7
+ * **\@Kitschpatrol's Shared Knip Configuration**
8
+ * @see [@kitschpatrol/knip-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/knip-config)
9
+ * @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
10
+ * @example
11
+ * ```ts
12
+ * import { knipConfig } from '@kitschpatrol/knip-config'
13
+ *
14
+ * export default knipConfig({
15
+ * // Customizations here
16
+ * })
17
+ * ```
18
+ */
19
+ export declare function knipConfig(config?: KnipConfig): KnipConfig;
20
+ export default sharedKnipConfig;
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import { deepmerge } from 'deepmerge-ts';
2
+ // export { commandDefinition } from './command.js'
3
+ /**
4
+ * Must return a POJO to be merged into package.json
5
+ */
6
+ const sharedKnipConfig = {
7
+ entry: [
8
+ 'scripts/**/*.ts',
9
+ '.remarkrc.js',
10
+ 'cspell.config.js',
11
+ 'eslint.config.ts',
12
+ 'mdat.config.ts',
13
+ 'prettier.config.js',
14
+ 'stylelint.config.js',
15
+ ],
16
+ };
17
+ /**
18
+ * **\@Kitschpatrol's Shared Knip Configuration**
19
+ * @see [@kitschpatrol/knip-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/knip-config)
20
+ * @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
21
+ * @example
22
+ * ```ts
23
+ * import { knipConfig } from '@kitschpatrol/knip-config'
24
+ *
25
+ * export default knipConfig({
26
+ * // Customizations here
27
+ * })
28
+ * ```
29
+ */
30
+ export function knipConfig(config) {
31
+ return deepmerge(sharedKnipConfig, config);
32
+ }
33
+ export default sharedKnipConfig;
@@ -0,0 +1,3 @@
1
+ import { knipConfig } from '@kitschpatrol/knip-config'
2
+
3
+ export default knipConfig()
package/license.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Eric Mika
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@kitschpatrol/knip-config",
3
+ "version": "5.0.0",
4
+ "description": "Knip configuration for @kitschpatrol/shared-config.",
5
+ "keywords": [
6
+ "shared-config",
7
+ "knip-config",
8
+ "knip",
9
+ "cli",
10
+ "kpi",
11
+ "kpi-knip"
12
+ ],
13
+ "bugs": "https://github.com/kitschpatrol/shared-config/issues",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/kitschpatrol/shared-config/cli.git",
17
+ "directory": "packages/knip-config"
18
+ },
19
+ "license": "MIT",
20
+ "author": {
21
+ "name": "Eric Mika",
22
+ "email": "eric@ericmika.com",
23
+ "url": "https://ericmika.com"
24
+ },
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./dist/index.js",
29
+ "types": "./dist/index.d.ts"
30
+ }
31
+ },
32
+ "main": "dist/index.js",
33
+ "types": "dist/index.d.ts",
34
+ "bin": {
35
+ "kpi-knip": "bin/cli.js"
36
+ },
37
+ "files": [
38
+ "dist/*",
39
+ "bin/*",
40
+ "init/*"
41
+ ],
42
+ "dependencies": {
43
+ "@pinojs/json-colorizer": "^4.0.0",
44
+ "cosmiconfig": "^9.0.0",
45
+ "deepmerge-ts": "^7.1.4",
46
+ "execa": "^9.5.2",
47
+ "fs-extra": "^11.3.0",
48
+ "knip": "^5.43.6"
49
+ },
50
+ "engines": {
51
+ "node": ">=22.0.0",
52
+ "pnpm": ">=10.0.0"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "scripts": {
58
+ "build": "tsc && ../../scripts/build.ts",
59
+ "cli": "node ./bin/cli.js"
60
+ }
61
+ }
package/readme.md ADDED
@@ -0,0 +1,189 @@
1
+ <!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->
2
+
3
+ <!-- title -->
4
+
5
+ # @kitschpatrol/knip-config
6
+
7
+ <!-- /title -->
8
+
9
+ <!-- badges -->
10
+
11
+ [![NPM Package @kitschpatrol/knip-config](https://img.shields.io/npm/v/@kitschpatrol/knip-config.svg)](https://npmjs.com/package/@kitschpatrol/knip-config)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
13
+
14
+ <!-- /badges -->
15
+
16
+ <!-- description -->
17
+
18
+ **Knip configuration for @kitschpatrol/shared-config.**
19
+
20
+ <!-- /description -->
21
+
22
+ ## Overview
23
+
24
+ It's a shared [Knip](https://knip.dev) config, plus a command-line tool `kpi-knip` to perform Knip-related project initialization, linting, and fixing.
25
+
26
+ <!-- recommendation -->
27
+
28
+ > [!Important]
29
+ >
30
+ > **You can use this package on its own, but it's recommended to use [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config) instead for a single-dependency and single-package approach to linting and fixing your project.**
31
+ >
32
+ > This package is included as a dependency in [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config), which also automatically invokes the command line functionality in this package via its `kpi` command
33
+
34
+ <!-- /recommendation -->
35
+
36
+ ## Setup
37
+
38
+ To use just this Knip config in isolation:
39
+
40
+ 1. Install the `.npmrc` in your project root. This is required for correct PNPM behavior:
41
+
42
+ ```sh
43
+ pnpm dlx @kitschpatrol/repo-config init
44
+ ```
45
+
46
+ 2. Add the package:
47
+
48
+ ```sh
49
+ pnpm add -D @kitschpatrol/knip-config
50
+ ```
51
+
52
+ 3. Add the starter `knip.config.ts` files to your project root, and add any customizations you'd like:
53
+
54
+ ```sh
55
+ pnpm exec kpi-knip init
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ Integrate with your `package.json` scripts as you see fit, for example:
61
+
62
+ ```json
63
+ {
64
+ "scripts": {
65
+ "lint": "kpi-knip lint"
66
+ }
67
+ }
68
+ ```
69
+
70
+ ### Configuration
71
+
72
+ To create a `knip.config.ts` in your project root:
73
+
74
+ ```sh
75
+ pnpm exec kpi-knip init
76
+ ```
77
+
78
+ (Note that this will delete the `knip` property in your `package.json`!)
79
+
80
+ _Or_
81
+
82
+ To create a `knip` property in `package.json`:
83
+
84
+ ```sh
85
+ pnpm exec kpi-knip init --location package
86
+ ```
87
+
88
+ (Note that this will delete the `knip.config.ts` file in your project root!)
89
+
90
+ ### CLI
91
+
92
+ <!-- cli-help -->
93
+
94
+ #### Command: `kpi-knip`
95
+
96
+ Kitschpatrol's Knip shared configuration tools.
97
+
98
+ This section lists top-level commands for `kpi-knip`.
99
+
100
+ Usage:
101
+
102
+ ```txt
103
+ kpi-knip <command>
104
+ ```
105
+
106
+ | Command | Description |
107
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
108
+ | `init` | Initialize by copying starter config files to your project root or to your package.json file. |
109
+ | `lint` | Check for unused code and dependencies. Package-scoped. In a monorepo, it will also run in all packages below the current working directory. |
110
+ | `fix` | Automatically remove unused code and dependencies. Package-scoped. In a monorepo, it will also run in all packages below the current working directory. |
111
+ | `print-config` | Print the effective Knip configuration. Package-scoped. Searches up to the root of a monorepo if necessary. |
112
+
113
+ | Option | Description | Type |
114
+ | ------------------- | ------------------- | --------- |
115
+ | `--help`<br>`-h` | Show help | `boolean` |
116
+ | `--version`<br>`-v` | Show version number | `boolean` |
117
+
118
+ _See the sections below for more information on each subcommand._
119
+
120
+ #### Subcommand: `kpi-knip init`
121
+
122
+ Initialize by copying starter config files to your project root or to your package.json file.
123
+
124
+ Usage:
125
+
126
+ ```txt
127
+ kpi-knip init
128
+ ```
129
+
130
+ | Option | Description | Type | Default |
131
+ | ------------------- | ------------------- | -------------------- | -------- |
132
+ | `--location` | TK | `"file"` `"package"` | `"file"` |
133
+ | `--help`<br>`-h` | Show help | `boolean` | |
134
+ | `--version`<br>`-v` | Show version number | `boolean` | |
135
+
136
+ #### Subcommand: `kpi-knip lint`
137
+
138
+ Check for unused code and dependencies. Package-scoped. In a monorepo, it will also run in all packages below the current working directory.
139
+
140
+ Usage:
141
+
142
+ ```txt
143
+ kpi-knip lint
144
+ ```
145
+
146
+ | Option | Description | Type |
147
+ | ------------------- | ------------------- | --------- |
148
+ | `--help`<br>`-h` | Show help | `boolean` |
149
+ | `--version`<br>`-v` | Show version number | `boolean` |
150
+
151
+ #### Subcommand: `kpi-knip fix`
152
+
153
+ Automatically remove unused code and dependencies. Package-scoped. In a monorepo, it will also run in all packages below the current working directory.
154
+
155
+ Usage:
156
+
157
+ ```txt
158
+ kpi-knip fix
159
+ ```
160
+
161
+ | Option | Description | Type |
162
+ | ------------------- | ------------------- | --------- |
163
+ | `--help`<br>`-h` | Show help | `boolean` |
164
+ | `--version`<br>`-v` | Show version number | `boolean` |
165
+
166
+ #### Subcommand: `kpi-knip print-config`
167
+
168
+ Print the effective Knip configuration. Package-scoped. Searches up to the root of a monorepo if necessary.
169
+
170
+ Usage:
171
+
172
+ ```txt
173
+ kpi-knip print-config
174
+ ```
175
+
176
+ | Option | Description | Type |
177
+ | ------------------- | ------------------- | --------- |
178
+ | `--help`<br>`-h` | Show help | `boolean` |
179
+ | `--version`<br>`-v` | Show version number | `boolean` |
180
+
181
+ <!-- /cli-help -->
182
+
183
+ <!-- license -->
184
+
185
+ ## License
186
+
187
+ [MIT](license.txt) © Eric Mika
188
+
189
+ <!-- /license -->