@ankhorage/devtools 1.0.2 → 1.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.
package/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # devtools
2
2
 
3
- Shared ESLint and Prettier configuration for modern TypeScript projects.
3
+ Shared ESLint, Prettier, and Knip configuration for modern TypeScript projects.
4
4
 
5
5
  ## What you get
6
6
 
7
7
  - Consistent linting across repos
8
8
  - Zero-config Prettier setup
9
+ - Shared Knip static-analysis defaults
9
10
  - Strict TypeScript rules without compromise
10
11
  - One source of truth for tooling
11
12
 
@@ -14,6 +15,7 @@ Shared ESLint and Prettier configuration for modern TypeScript projects.
14
15
  - Flat ESLint config (latest standard)
15
16
  - Preconfigured plugin ecosystem
16
17
  - Prettier integration
18
+ - Shared Knip config factory
17
19
  - Monorepo-friendly
18
20
 
19
21
  ## Installation
@@ -22,6 +24,12 @@ Shared ESLint and Prettier configuration for modern TypeScript projects.
22
24
  bun add -D @ankhorage/devtools
23
25
  ```
24
26
 
27
+ Install the tools used by your local scripts as development dependencies:
28
+
29
+ ```bash
30
+ bun add -D eslint prettier knip
31
+ ```
32
+
25
33
  ## Usage
26
34
 
27
35
  ### ESLint
@@ -40,15 +48,71 @@ export default config();
40
48
  }
41
49
  ```
42
50
 
51
+ ### Knip
52
+
53
+ Create a repo-local `knip.config.ts` file:
54
+
55
+ ```ts
56
+ import { createKnipConfig } from '@ankhorage/devtools/knip';
57
+
58
+ export default createKnipConfig();
59
+ ```
60
+
61
+ Add a package script:
62
+
63
+ ```json
64
+ {
65
+ "scripts": {
66
+ "knip": "knip"
67
+ }
68
+ }
69
+ ```
70
+
71
+ Repos can add narrow repo-specific patterns when needed:
72
+
73
+ ```ts
74
+ import { createKnipConfig } from '@ankhorage/devtools/knip';
75
+
76
+ export default createKnipConfig({
77
+ entry: ['scripts/release.ts'],
78
+ project: ['scripts/**/*.ts'],
79
+ ignore: ['fixtures/**'],
80
+ });
81
+ ```
82
+
83
+ The shared config intentionally keeps defaults narrow so Knip does not fail on unmatched optional paths. Prefer explicit `entry`, `project`, or Knip plugin configuration over broad ignores when tool config files are reported as unused.
84
+
85
+ ### CI
86
+
87
+ Run Knip in CI after dependencies are installed:
88
+
89
+ ```yaml
90
+ - name: Run Knip
91
+ run: bun run knip
92
+ ```
93
+
94
+ For workflows that support optional scripts, use the same guard style as the other devtools checks:
95
+
96
+ ```yaml
97
+ - name: Run Knip
98
+ run: |
99
+ if node -e "const p=require('./package.json'); process.exit(p.scripts?.knip ? 0 : 1)"; then
100
+ bun run knip
101
+ else
102
+ echo "No knip script found; skipping."
103
+ fi
104
+ ```
105
+
43
106
  ## Use Cases
44
107
 
45
108
  - Monorepos with shared standards
46
109
  - Teams that want strict, predictable linting
47
110
  - Projects avoiding duplicated config
111
+ - Repos that need consistent unused-file, unused-export, and dependency checks
48
112
 
49
113
  ## Why this exists
50
114
 
51
- Maintaining ESLint + Prettier configs across multiple repositories leads to:
115
+ Maintaining ESLint, Prettier, and Knip configs across multiple repositories leads to:
52
116
 
53
117
  - duplication
54
118
  - inconsistency
@@ -62,6 +126,7 @@ Includes:
62
126
 
63
127
  - ESLint configuration
64
128
  - Prettier configuration
129
+ - Knip configuration
65
130
 
66
131
  Excludes:
67
132
 
package/dist/knip.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { KnipConfig } from 'knip';
2
+ export interface DevtoolsKnipWorkspaceConfigOptions {
3
+ entry?: string[];
4
+ project?: string[];
5
+ ignore?: string[];
6
+ ignoreDependencies?: (string | RegExp)[];
7
+ ignoreFiles?: string[];
8
+ }
9
+ export interface DevtoolsKnipConfigOptions extends DevtoolsKnipWorkspaceConfigOptions {
10
+ workspaces?: Record<string, DevtoolsKnipWorkspaceConfigOptions>;
11
+ }
12
+ export declare function createKnipConfig(options?: DevtoolsKnipConfigOptions): KnipConfig;
package/dist/knip.js ADDED
@@ -0,0 +1,12 @@
1
+ export function createKnipConfig(options = {}) {
2
+ return {
3
+ ...(options.entry === undefined ? {} : { entry: options.entry }),
4
+ ...(options.project === undefined ? {} : { project: options.project }),
5
+ ...(options.ignore === undefined ? {} : { ignore: options.ignore }),
6
+ ...(options.ignoreDependencies === undefined
7
+ ? {}
8
+ : { ignoreDependencies: options.ignoreDependencies }),
9
+ ...(options.ignoreFiles === undefined ? {} : { ignoreFiles: options.ignoreFiles }),
10
+ ...(options.workspaces === undefined ? {} : { workspaces: options.workspaces }),
11
+ };
12
+ }
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type tseslint from 'typescript-eslint';
2
- export type FlatConfig = ReturnType<typeof tseslint.config>;
2
+ type FlatConfig = ReturnType<typeof tseslint.config>;
3
3
  export type FlatConfigItem = FlatConfig[number];
4
- export interface RestrictedImport {
4
+ interface RestrictedImport {
5
5
  name: string;
6
6
  message: string;
7
7
  }
@@ -15,3 +15,4 @@ export interface DevtoolsConfigOptions {
15
15
  overrides?: FlatConfigItem[];
16
16
  includePrettier?: boolean;
17
17
  }
18
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ankhorage/devtools",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Shared Lint and Format Configuration for Ankhorage",
5
5
  "homepage": "https://github.com/ankhorage/devtools#readme",
6
6
  "bugs": {
@@ -14,11 +14,25 @@
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
+ "keywords": [
18
+ "typescript",
19
+ "eslint",
20
+ "prettier",
21
+ "knip",
22
+ "linting",
23
+ "formatting",
24
+ "static-analysis",
25
+ "developer-tools"
26
+ ],
17
27
  "exports": {
18
28
  "./eslint": {
19
29
  "types": "./dist/eslint.d.ts",
20
30
  "import": "./dist/eslint.js"
21
31
  },
32
+ "./knip": {
33
+ "types": "./dist/knip.d.ts",
34
+ "import": "./dist/knip.js"
35
+ },
22
36
  "./prettier": {
23
37
  "require": "./dist/prettier.cjs"
24
38
  }
@@ -31,6 +45,7 @@
31
45
  ],
32
46
  "scripts": {
33
47
  "build": "tsc && cp src/prettier.cjs dist/prettier.cjs",
48
+ "knip": "knip",
34
49
  "lint": "eslint .",
35
50
  "format": "prettier --write .",
36
51
  "format:check": "prettier --check .",
@@ -52,6 +67,7 @@
52
67
  "@changesets/cli": "^2.30.0",
53
68
  "@types/bun": "^1.3.13",
54
69
  "@types/node": "^25.2.3",
70
+ "knip": "^6.12.2",
55
71
  "typescript": "^5.9.3"
56
72
  },
57
73
  "packageManager": "bun@1.3.13"