@ankhorage/devtools 1.0.1 → 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,17 +1,21 @@
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
  - Consistent linting across repos
7
8
  - Zero-config Prettier setup
9
+ - Shared Knip static-analysis defaults
8
10
  - Strict TypeScript rules without compromise
9
11
  - One source of truth for tooling
10
12
 
11
13
  ## Features
14
+
12
15
  - Flat ESLint config (latest standard)
13
16
  - Preconfigured plugin ecosystem
14
17
  - Prettier integration
18
+ - Shared Knip config factory
15
19
  - Monorepo-friendly
16
20
 
17
21
  ## Installation
@@ -20,14 +24,20 @@ Shared ESLint and Prettier configuration for modern TypeScript projects.
20
24
  bun add -D @ankhorage/devtools
21
25
  ```
22
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
+
23
33
  ## Usage
24
34
 
25
35
  ### ESLint
26
36
 
27
37
  ```js
28
- import config from '@ankhorage/devtools/eslint'
38
+ import config from '@ankhorage/devtools/eslint';
29
39
 
30
- export default config()
40
+ export default config();
31
41
  ```
32
42
 
33
43
  ### Prettier
@@ -38,14 +48,72 @@ export default config()
38
48
  }
39
49
  ```
40
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
+
41
106
  ## Use Cases
107
+
42
108
  - Monorepos with shared standards
43
109
  - Teams that want strict, predictable linting
44
110
  - Projects avoiding duplicated config
111
+ - Repos that need consistent unused-file, unused-export, and dependency checks
45
112
 
46
113
  ## Why this exists
47
114
 
48
- Maintaining ESLint + Prettier configs across multiple repositories leads to:
115
+ Maintaining ESLint, Prettier, and Knip configs across multiple repositories leads to:
116
+
49
117
  - duplication
50
118
  - inconsistency
51
119
  - drift over time
@@ -55,9 +123,12 @@ This package centralizes tooling so all projects stay aligned.
55
123
  ## Scope
56
124
 
57
125
  Includes:
126
+
58
127
  - ESLint configuration
59
128
  - Prettier configuration
129
+ - Knip configuration
60
130
 
61
131
  Excludes:
132
+
62
133
  - runtime code
63
134
  - build tooling
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,16 +1,38 @@
1
1
  {
2
2
  "name": "@ankhorage/devtools",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Shared Lint and Format Configuration for Ankhorage",
5
+ "homepage": "https://github.com/ankhorage/devtools#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/ankhorage/devtools/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ankhorage/devtools.git"
12
+ },
5
13
  "type": "module",
6
14
  "publishConfig": {
7
15
  "access": "public"
8
16
  },
17
+ "keywords": [
18
+ "typescript",
19
+ "eslint",
20
+ "prettier",
21
+ "knip",
22
+ "linting",
23
+ "formatting",
24
+ "static-analysis",
25
+ "developer-tools"
26
+ ],
9
27
  "exports": {
10
28
  "./eslint": {
11
29
  "types": "./dist/eslint.d.ts",
12
30
  "import": "./dist/eslint.js"
13
31
  },
32
+ "./knip": {
33
+ "types": "./dist/knip.d.ts",
34
+ "import": "./dist/knip.js"
35
+ },
14
36
  "./prettier": {
15
37
  "require": "./dist/prettier.cjs"
16
38
  }
@@ -23,10 +45,12 @@
23
45
  ],
24
46
  "scripts": {
25
47
  "build": "tsc && cp src/prettier.cjs dist/prettier.cjs",
48
+ "knip": "knip",
26
49
  "lint": "eslint .",
27
50
  "format": "prettier --write .",
28
51
  "format:check": "prettier --check .",
29
- "test": "bun test"
52
+ "test": "bun test",
53
+ "version-packages": "changeset version"
30
54
  },
31
55
  "dependencies": {
32
56
  "@eslint/js": "^10.0.1",
@@ -41,8 +65,10 @@
41
65
  },
42
66
  "devDependencies": {
43
67
  "@changesets/cli": "^2.30.0",
68
+ "@types/bun": "^1.3.13",
44
69
  "@types/node": "^25.2.3",
45
- "bun-types": "^1.3.11",
70
+ "knip": "^6.12.2",
46
71
  "typescript": "^5.9.3"
47
- }
72
+ },
73
+ "packageManager": "bun@1.3.13"
48
74
  }