@kb-labs/devkit 1.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.
Files changed (295) hide show
  1. package/.cursorrules +32 -0
  2. package/.github/CODEOWNERS +2 -0
  3. package/.github/actions/setup-node-pnpm/action.yml +47 -0
  4. package/.github/workflow-templates/ci.yml +13 -0
  5. package/.github/workflow-templates/drift-check.yml +10 -0
  6. package/.github/workflow-templates/profiles-validate.yml +16 -0
  7. package/.github/workflow-templates/release.yml +8 -0
  8. package/.github/workflows/ci-reusable.yml +131 -0
  9. package/.github/workflows/drift-check-reusable.yml +23 -0
  10. package/.github/workflows/fixtures.yml +74 -0
  11. package/.github/workflows/profiles-validate-reusable.yml +67 -0
  12. package/.github/workflows/release-reusable.yml +50 -0
  13. package/.vscode/settings.json +23 -0
  14. package/AGENTS.md +130 -0
  15. package/LICENSE +21 -0
  16. package/README.md +1542 -0
  17. package/agents/devkit-maintainer/context.globs +15 -0
  18. package/agents/devkit-maintainer/permissions.yml +17 -0
  19. package/agents/devkit-maintainer/prompt.md +28 -0
  20. package/agents/devkit-maintainer/runbook.md +31 -0
  21. package/agents/docs-crafter/prompt.md +24 -0
  22. package/agents/docs-crafter/runbook.md +18 -0
  23. package/agents/release-manager/context.globs +7 -0
  24. package/agents/release-manager/prompt.md +27 -0
  25. package/agents/release-manager/runbook.md +17 -0
  26. package/agents/test-generator/context.globs +7 -0
  27. package/agents/test-generator/prompt.md +27 -0
  28. package/agents/test-generator/runbook.md +18 -0
  29. package/bin/devkit-architecture.mjs +1225 -0
  30. package/bin/devkit-build-order.mjs +500 -0
  31. package/bin/devkit-check-build-readiness.mjs +222 -0
  32. package/bin/devkit-check-commands.mjs +394 -0
  33. package/bin/devkit-check-configs.mjs +461 -0
  34. package/bin/devkit-check-deprecated.mjs +532 -0
  35. package/bin/devkit-check-duplicates.mjs +431 -0
  36. package/bin/devkit-check-exports.mjs +561 -0
  37. package/bin/devkit-check-imports.mjs +712 -0
  38. package/bin/devkit-check-paths.mjs +670 -0
  39. package/bin/devkit-check-scripts.mjs +335 -0
  40. package/bin/devkit-check-structure.mjs +495 -0
  41. package/bin/devkit-check-types.mjs +450 -0
  42. package/bin/devkit-ci.mjs +261 -0
  43. package/bin/devkit-core-gate.mjs +225 -0
  44. package/bin/devkit-fix-deps.mjs +1169 -0
  45. package/bin/devkit-freshness.mjs +199 -0
  46. package/bin/devkit-health.mjs +489 -0
  47. package/bin/devkit-migrate-configs.mjs +370 -0
  48. package/bin/devkit-paths.mjs +192 -0
  49. package/bin/devkit-stats.mjs +453 -0
  50. package/bin/devkit-sync.mjs +12 -0
  51. package/bin/devkit-tsup-external.mjs +148 -0
  52. package/bin/devkit-types-audit.mjs +615 -0
  53. package/bin/devkit-types-order.mjs +637 -0
  54. package/bin/devkit-validate-naming.mjs +203 -0
  55. package/bin/devkit-visualize.mjs +452 -0
  56. package/bin/kb-devkit-qa-history.mjs +453 -0
  57. package/bin/kb-devkit-qa.mjs +915 -0
  58. package/eslint/node.js +134 -0
  59. package/eslint/react.js +260 -0
  60. package/package.json +186 -0
  61. package/prettier/index.json +10 -0
  62. package/sync/index.mjs +693 -0
  63. package/templates/configs/README.md +306 -0
  64. package/templates/configs/eslint.config.js +27 -0
  65. package/templates/configs/package.json.bin +25 -0
  66. package/templates/configs/package.json.lib +30 -0
  67. package/templates/configs/tsconfig.build.json +15 -0
  68. package/templates/configs/tsconfig.json +9 -0
  69. package/templates/configs/tsup.config.bin.ts +34 -0
  70. package/templates/configs/tsup.config.cli.ts +41 -0
  71. package/templates/configs/tsup.config.dual.ts +46 -0
  72. package/templates/configs/tsup.config.ts +36 -0
  73. package/templates/package-json/README.md +290 -0
  74. package/templates/package-json/package.json.bin.template +40 -0
  75. package/templates/package-json/package.json.template +45 -0
  76. package/tsconfig/base.json +21 -0
  77. package/tsconfig/cli.json +12 -0
  78. package/tsconfig/dist/__tests__/cache.spec.d.ts +6 -0
  79. package/tsconfig/dist/__tests__/cache.spec.d.ts.map +1 -0
  80. package/tsconfig/dist/__tests__/cache.spec.js +85 -0
  81. package/tsconfig/dist/__tests__/cache.spec.js.map +1 -0
  82. package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts +6 -0
  83. package/tsconfig/dist/__tests__/fs-atomic.spec.d.ts.map +1 -0
  84. package/tsconfig/dist/__tests__/fs-atomic.spec.js +153 -0
  85. package/tsconfig/dist/__tests__/fs-atomic.spec.js.map +1 -0
  86. package/tsconfig/dist/__tests__/init-workspace.spec.d.ts +6 -0
  87. package/tsconfig/dist/__tests__/init-workspace.spec.d.ts.map +1 -0
  88. package/tsconfig/dist/__tests__/init-workspace.spec.js +99 -0
  89. package/tsconfig/dist/__tests__/init-workspace.spec.js.map +1 -0
  90. package/tsconfig/dist/__tests__/kb-error.spec.d.ts +6 -0
  91. package/tsconfig/dist/__tests__/kb-error.spec.d.ts.map +1 -0
  92. package/tsconfig/dist/__tests__/kb-error.spec.js +190 -0
  93. package/tsconfig/dist/__tests__/kb-error.spec.js.map +1 -0
  94. package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts +6 -0
  95. package/tsconfig/dist/__tests__/preset-lockfile.spec.d.ts.map +1 -0
  96. package/tsconfig/dist/__tests__/preset-lockfile.spec.js +142 -0
  97. package/tsconfig/dist/__tests__/preset-lockfile.spec.js.map +1 -0
  98. package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts +6 -0
  99. package/tsconfig/dist/__tests__/product-config-profiles.spec.d.ts.map +1 -0
  100. package/tsconfig/dist/__tests__/product-config-profiles.spec.js +100 -0
  101. package/tsconfig/dist/__tests__/product-config-profiles.spec.js.map +1 -0
  102. package/tsconfig/dist/__tests__/product-config.spec.d.ts +6 -0
  103. package/tsconfig/dist/__tests__/product-config.spec.d.ts.map +1 -0
  104. package/tsconfig/dist/__tests__/product-config.spec.js +298 -0
  105. package/tsconfig/dist/__tests__/product-config.spec.js.map +1 -0
  106. package/tsconfig/dist/__tests__/runtime.spec.d.ts +2 -0
  107. package/tsconfig/dist/__tests__/runtime.spec.d.ts.map +1 -0
  108. package/tsconfig/dist/__tests__/runtime.spec.js +127 -0
  109. package/tsconfig/dist/__tests__/runtime.spec.js.map +1 -0
  110. package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts +6 -0
  111. package/tsconfig/dist/__tests__/upsert-lockfile.spec.d.ts.map +1 -0
  112. package/tsconfig/dist/__tests__/upsert-lockfile.spec.js +251 -0
  113. package/tsconfig/dist/__tests__/upsert-lockfile.spec.js.map +1 -0
  114. package/tsconfig/dist/__tests__/validate-config.spec.d.ts +2 -0
  115. package/tsconfig/dist/__tests__/validate-config.spec.d.ts.map +1 -0
  116. package/tsconfig/dist/__tests__/validate-config.spec.js +14 -0
  117. package/tsconfig/dist/__tests__/validate-config.spec.js.map +1 -0
  118. package/tsconfig/dist/api/init-workspace.d.ts +10 -0
  119. package/tsconfig/dist/api/init-workspace.d.ts.map +1 -0
  120. package/tsconfig/dist/api/init-workspace.js +191 -0
  121. package/tsconfig/dist/api/init-workspace.js.map +1 -0
  122. package/tsconfig/dist/api/product-config.d.ts +21 -0
  123. package/tsconfig/dist/api/product-config.d.ts.map +1 -0
  124. package/tsconfig/dist/api/product-config.js +192 -0
  125. package/tsconfig/dist/api/product-config.js.map +1 -0
  126. package/tsconfig/dist/api/read-config.d.ts +22 -0
  127. package/tsconfig/dist/api/read-config.d.ts.map +1 -0
  128. package/tsconfig/dist/api/read-config.js +105 -0
  129. package/tsconfig/dist/api/read-config.js.map +1 -0
  130. package/tsconfig/dist/api/upsert-lockfile.d.ts +10 -0
  131. package/tsconfig/dist/api/upsert-lockfile.d.ts.map +1 -0
  132. package/tsconfig/dist/api/upsert-lockfile.js +63 -0
  133. package/tsconfig/dist/api/upsert-lockfile.js.map +1 -0
  134. package/tsconfig/dist/cache/fs-cache.d.ts +38 -0
  135. package/tsconfig/dist/cache/fs-cache.d.ts.map +1 -0
  136. package/tsconfig/dist/cache/fs-cache.js +142 -0
  137. package/tsconfig/dist/cache/fs-cache.js.map +1 -0
  138. package/tsconfig/dist/errors/kb-error.d.ts +32 -0
  139. package/tsconfig/dist/errors/kb-error.d.ts.map +1 -0
  140. package/tsconfig/dist/errors/kb-error.js +54 -0
  141. package/tsconfig/dist/errors/kb-error.js.map +1 -0
  142. package/tsconfig/dist/fs/__tests__/fs.spec.d.ts +2 -0
  143. package/tsconfig/dist/fs/__tests__/fs.spec.d.ts.map +1 -0
  144. package/tsconfig/dist/fs/__tests__/fs.spec.js +22 -0
  145. package/tsconfig/dist/fs/__tests__/fs.spec.js.map +1 -0
  146. package/tsconfig/dist/fs/fs.d.ts +6 -0
  147. package/tsconfig/dist/fs/fs.d.ts.map +1 -0
  148. package/tsconfig/dist/fs/fs.js +12 -0
  149. package/tsconfig/dist/fs/fs.js.map +1 -0
  150. package/tsconfig/dist/fs/index.d.ts +2 -0
  151. package/tsconfig/dist/fs/index.d.ts.map +1 -0
  152. package/tsconfig/dist/fs/index.js +2 -0
  153. package/tsconfig/dist/fs/index.js.map +1 -0
  154. package/tsconfig/dist/hash/config-hash.d.ts +17 -0
  155. package/tsconfig/dist/hash/config-hash.d.ts.map +1 -0
  156. package/tsconfig/dist/hash/config-hash.js +55 -0
  157. package/tsconfig/dist/hash/config-hash.js.map +1 -0
  158. package/tsconfig/dist/index.d.ts +5 -0
  159. package/tsconfig/dist/index.d.ts.map +1 -0
  160. package/tsconfig/dist/index.js +5 -0
  161. package/tsconfig/dist/index.js.map +1 -0
  162. package/tsconfig/dist/lockfile/lockfile.d.ts +54 -0
  163. package/tsconfig/dist/lockfile/lockfile.d.ts.map +1 -0
  164. package/tsconfig/dist/lockfile/lockfile.js +141 -0
  165. package/tsconfig/dist/lockfile/lockfile.js.map +1 -0
  166. package/tsconfig/dist/logging/__tests__/logger.spec.d.ts +2 -0
  167. package/tsconfig/dist/logging/__tests__/logger.spec.d.ts.map +1 -0
  168. package/tsconfig/dist/logging/__tests__/logger.spec.js +65 -0
  169. package/tsconfig/dist/logging/__tests__/logger.spec.js.map +1 -0
  170. package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts +2 -0
  171. package/tsconfig/dist/logging/__tests__/redaction.spec.d.ts.map +1 -0
  172. package/tsconfig/dist/logging/__tests__/redaction.spec.js +34 -0
  173. package/tsconfig/dist/logging/__tests__/redaction.spec.js.map +1 -0
  174. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts +2 -0
  175. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.d.ts.map +1 -0
  176. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js +90 -0
  177. package/tsconfig/dist/logging/__tests__/sinks-and-env.spec.js.map +1 -0
  178. package/tsconfig/dist/logging/index.d.ts +6 -0
  179. package/tsconfig/dist/logging/index.d.ts.map +1 -0
  180. package/tsconfig/dist/logging/index.js +6 -0
  181. package/tsconfig/dist/logging/index.js.map +1 -0
  182. package/tsconfig/dist/logging/logger.d.ts +9 -0
  183. package/tsconfig/dist/logging/logger.d.ts.map +1 -0
  184. package/tsconfig/dist/logging/logger.js +101 -0
  185. package/tsconfig/dist/logging/logger.js.map +1 -0
  186. package/tsconfig/dist/logging/redaction.d.ts +7 -0
  187. package/tsconfig/dist/logging/redaction.d.ts.map +1 -0
  188. package/tsconfig/dist/logging/redaction.js +23 -0
  189. package/tsconfig/dist/logging/redaction.js.map +1 -0
  190. package/tsconfig/dist/logging/sinks/json.d.ts +4 -0
  191. package/tsconfig/dist/logging/sinks/json.d.ts.map +1 -0
  192. package/tsconfig/dist/logging/sinks/json.js +23 -0
  193. package/tsconfig/dist/logging/sinks/json.js.map +1 -0
  194. package/tsconfig/dist/logging/sinks/stdout.d.ts +3 -0
  195. package/tsconfig/dist/logging/sinks/stdout.d.ts.map +1 -0
  196. package/tsconfig/dist/logging/sinks/stdout.js +24 -0
  197. package/tsconfig/dist/logging/sinks/stdout.js.map +1 -0
  198. package/tsconfig/dist/logging/types/index.d.ts +2 -0
  199. package/tsconfig/dist/logging/types/index.d.ts.map +1 -0
  200. package/tsconfig/dist/logging/types/index.js +2 -0
  201. package/tsconfig/dist/logging/types/index.js.map +1 -0
  202. package/tsconfig/dist/logging/types/types.d.ts +37 -0
  203. package/tsconfig/dist/logging/types/types.d.ts.map +1 -0
  204. package/tsconfig/dist/logging/types/types.js +2 -0
  205. package/tsconfig/dist/logging/types/types.js.map +1 -0
  206. package/tsconfig/dist/merge/layered-merge.d.ts +16 -0
  207. package/tsconfig/dist/merge/layered-merge.d.ts.map +1 -0
  208. package/tsconfig/dist/merge/layered-merge.js +97 -0
  209. package/tsconfig/dist/merge/layered-merge.js.map +1 -0
  210. package/tsconfig/dist/preset/resolve-preset.d.ts +29 -0
  211. package/tsconfig/dist/preset/resolve-preset.d.ts.map +1 -0
  212. package/tsconfig/dist/preset/resolve-preset.js +104 -0
  213. package/tsconfig/dist/preset/resolve-preset.js.map +1 -0
  214. package/tsconfig/dist/repo/__tests__/repo.spec.d.ts +2 -0
  215. package/tsconfig/dist/repo/__tests__/repo.spec.d.ts.map +1 -0
  216. package/tsconfig/dist/repo/__tests__/repo.spec.js +25 -0
  217. package/tsconfig/dist/repo/__tests__/repo.spec.js.map +1 -0
  218. package/tsconfig/dist/repo/index.d.ts +2 -0
  219. package/tsconfig/dist/repo/index.d.ts.map +1 -0
  220. package/tsconfig/dist/repo/index.js +2 -0
  221. package/tsconfig/dist/repo/index.js.map +1 -0
  222. package/tsconfig/dist/repo/repo.d.ts +6 -0
  223. package/tsconfig/dist/repo/repo.d.ts.map +1 -0
  224. package/tsconfig/dist/repo/repo.js +25 -0
  225. package/tsconfig/dist/repo/repo.js.map +1 -0
  226. package/tsconfig/dist/runtime/index.d.ts +2 -0
  227. package/tsconfig/dist/runtime/index.d.ts.map +1 -0
  228. package/tsconfig/dist/runtime/index.js +2 -0
  229. package/tsconfig/dist/runtime/index.js.map +1 -0
  230. package/tsconfig/dist/runtime/runtime.d.ts +46 -0
  231. package/tsconfig/dist/runtime/runtime.d.ts.map +1 -0
  232. package/tsconfig/dist/runtime/runtime.js +126 -0
  233. package/tsconfig/dist/runtime/runtime.js.map +1 -0
  234. package/tsconfig/dist/tsconfig.tools.tsbuildinfo +1 -0
  235. package/tsconfig/dist/tsconfig.tsbuildinfo +1 -0
  236. package/tsconfig/dist/types/index.d.ts +2 -0
  237. package/tsconfig/dist/types/index.d.ts.map +1 -0
  238. package/tsconfig/dist/types/index.js +2 -0
  239. package/tsconfig/dist/types/index.js.map +1 -0
  240. package/tsconfig/dist/types/init.d.ts +34 -0
  241. package/tsconfig/dist/types/init.d.ts.map +1 -0
  242. package/tsconfig/dist/types/init.js +6 -0
  243. package/tsconfig/dist/types/init.js.map +1 -0
  244. package/tsconfig/dist/types/preset.d.ts +27 -0
  245. package/tsconfig/dist/types/preset.d.ts.map +1 -0
  246. package/tsconfig/dist/types/preset.js +6 -0
  247. package/tsconfig/dist/types/preset.js.map +1 -0
  248. package/tsconfig/dist/types/types.d.ts +6 -0
  249. package/tsconfig/dist/types/types.d.ts.map +1 -0
  250. package/tsconfig/dist/types/types.js +2 -0
  251. package/tsconfig/dist/types/types.js.map +1 -0
  252. package/tsconfig/dist/utils/__tests__/env.spec.d.ts +2 -0
  253. package/tsconfig/dist/utils/__tests__/env.spec.d.ts.map +1 -0
  254. package/tsconfig/dist/utils/__tests__/env.spec.js +33 -0
  255. package/tsconfig/dist/utils/__tests__/env.spec.js.map +1 -0
  256. package/tsconfig/dist/utils/env.d.ts +7 -0
  257. package/tsconfig/dist/utils/env.d.ts.map +1 -0
  258. package/tsconfig/dist/utils/env.js +25 -0
  259. package/tsconfig/dist/utils/env.js.map +1 -0
  260. package/tsconfig/dist/utils/fs-atomic.d.ts +15 -0
  261. package/tsconfig/dist/utils/fs-atomic.d.ts.map +1 -0
  262. package/tsconfig/dist/utils/fs-atomic.js +45 -0
  263. package/tsconfig/dist/utils/fs-atomic.js.map +1 -0
  264. package/tsconfig/dist/utils/index.d.ts +3 -0
  265. package/tsconfig/dist/utils/index.d.ts.map +1 -0
  266. package/tsconfig/dist/utils/index.js +3 -0
  267. package/tsconfig/dist/utils/index.js.map +1 -0
  268. package/tsconfig/dist/utils/paths.d.ts +21 -0
  269. package/tsconfig/dist/utils/paths.d.ts.map +1 -0
  270. package/tsconfig/dist/utils/paths.js +32 -0
  271. package/tsconfig/dist/utils/paths.js.map +1 -0
  272. package/tsconfig/dist/utils/product-normalize.d.ts +27 -0
  273. package/tsconfig/dist/utils/product-normalize.d.ts.map +1 -0
  274. package/tsconfig/dist/utils/product-normalize.js +45 -0
  275. package/tsconfig/dist/utils/product-normalize.js.map +1 -0
  276. package/tsconfig/dist/validation/validate-config.d.ts +7 -0
  277. package/tsconfig/dist/validation/validate-config.d.ts.map +1 -0
  278. package/tsconfig/dist/validation/validate-config.js +22 -0
  279. package/tsconfig/dist/validation/validate-config.js.map +1 -0
  280. package/tsconfig/lib.json +13 -0
  281. package/tsconfig/node.json +12 -0
  282. package/tsconfig/react-app.json +8 -0
  283. package/tsconfig/react-lib.json +8 -0
  284. package/tsconfig/test.json +15 -0
  285. package/tsup/bin.js +172 -0
  286. package/tsup/dual.js +155 -0
  287. package/tsup/external-sync.mjs +41 -0
  288. package/tsup/external.mjs +109 -0
  289. package/tsup/node.js +65 -0
  290. package/tsup/react-lib.js +18 -0
  291. package/tsup/sdk.js +118 -0
  292. package/vite/react-app.js +50 -0
  293. package/vitest/node.js +37 -0
  294. package/vitest/react.js +39 -0
  295. package/vitest/vitest-setup.ts +9 -0
package/eslint/node.js ADDED
@@ -0,0 +1,134 @@
1
+
2
+ import tseslint from 'typescript-eslint'
3
+ import importPlugin from 'eslint-plugin-import'
4
+ import unusedImports from 'eslint-plugin-unused-imports'
5
+ import sonarjs from 'eslint-plugin-sonarjs'
6
+
7
+ export default [
8
+ // ---- ignore common build artifacts and generated files
9
+ {
10
+ ignores: [
11
+ '/dist/',
12
+ '/coverage/',
13
+ '/.yalc/',
14
+ '/node_modules/',
15
+ '**/dist/**',
16
+ '**/coverage/**',
17
+ '**/node_modules/**',
18
+ '**/*.d.ts',
19
+ '**/scripts/**',
20
+ '**/eslint.config.*',
21
+ '**/bootstrap.js'
22
+ ]
23
+ },
24
+
25
+ // ---- base TypeScript recommendations
26
+ ...tseslint.configs.recommended,
27
+
28
+ // ---- project-wide rules and import resolver
29
+ {
30
+ plugins: {
31
+ import: importPlugin,
32
+ 'unused-imports': unusedImports,
33
+ sonarjs: sonarjs,
34
+ },
35
+ settings: {
36
+ // Let eslint-plugin-import resolve TS paths and packages without extensions
37
+ 'import/resolver': {
38
+ typescript: {
39
+ alwaysTryTypes: true,
40
+ project: ['./tsconfig.json'],
41
+ },
42
+ },
43
+ },
44
+ languageOptions: {
45
+ // Basic TypeScript parsing without requiring project setup
46
+ parserOptions: {
47
+ ecmaVersion: 'latest',
48
+ sourceType: 'module',
49
+ },
50
+ },
51
+ rules: {
52
+ // Allow bare imports without file extensions for TS/JS in ESM projects
53
+ 'import/extensions': ['error', 'ignorePackages', {
54
+ ts: 'never', tsx: 'never', mts: 'never', cts: 'never',
55
+ js: 'never', mjs: 'never', cjs: 'never',
56
+ }],
57
+
58
+ // Allow dev dependencies in tests, configs and scripts
59
+ 'import/no-extraneous-dependencies': ['error', {
60
+ devDependencies: [
61
+ '**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts}',
62
+ '**/__tests__/**',
63
+ '**/vite.config.*',
64
+ '**/vitest.config.*',
65
+ '**/tsup*.config.*',
66
+ '**/eslint.config.*',
67
+ '**/scripts/**',
68
+ ],
69
+ }],
70
+
71
+ // TS ergonomics - disable base rule, use unused-imports instead
72
+ '@typescript-eslint/no-unused-vars': 'off',
73
+ 'unused-imports/no-unused-imports': 'error',
74
+ 'unused-imports/no-unused-vars': ['warn', {
75
+ argsIgnorePattern: '^_',
76
+ varsIgnorePattern: '^_',
77
+ caughtErrors: 'all',
78
+ caughtErrorsIgnorePattern: '^_',
79
+ }],
80
+ '@typescript-eslint/no-explicit-any': 'off',
81
+ '@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }],
82
+
83
+ // Async/Promise safety (non-type-aware rules only)
84
+ // Note: @typescript-eslint/no-floating-promises requires project setup
85
+ 'no-return-await': 'error',
86
+ 'no-promise-executor-return': 'error',
87
+ // no-await-in-loop: off globally (too noisy for CLI/fs code).
88
+ // Enable per-repo where it matters (rest-api, workflow).
89
+ 'no-await-in-loop': 'off',
90
+
91
+ // Security
92
+ 'no-eval': 'error',
93
+ 'no-implied-eval': 'error',
94
+ 'no-new-func': 'error',
95
+
96
+ // General safety / clarity
97
+ 'no-console': 'off',
98
+ 'no-debugger': 'warn',
99
+ 'eqeqeq': ['error', 'smart'],
100
+ 'curly': ['error', 'all'],
101
+ 'no-throw-literal': 'error',
102
+ 'prefer-const': 'error',
103
+ 'no-var': 'error',
104
+
105
+ // SonarJS rules (code quality & bug detection)
106
+ 'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],
107
+ 'sonarjs/cognitive-complexity': ['warn', 15],
108
+ 'sonarjs/no-identical-functions': 'warn',
109
+ 'sonarjs/no-collapsible-if': 'warn',
110
+ 'sonarjs/no-redundant-boolean': 'warn',
111
+ 'sonarjs/prefer-immediate-return': 'warn',
112
+ },
113
+ },
114
+
115
+ // ---- minimal .vue support (without forcing Vue plugin)
116
+ {
117
+ files: ['**/*.vue'],
118
+ languageOptions: {
119
+ parserOptions: { extraFileExtensions: ['.vue'] },
120
+ },
121
+ },
122
+
123
+ // ---- test file overrides
124
+ {
125
+ files: [
126
+ '**/*.{test,spec}.{ts,tsx,js,jsx}',
127
+ '**/__tests__/**/*.{ts,tsx,js,jsx}',
128
+ ],
129
+ rules: {
130
+ // Disable duplicate string detection in tests - test literals should be inline for readability
131
+ 'sonarjs/no-duplicate-string': 'off',
132
+ },
133
+ },
134
+ ]
@@ -0,0 +1,260 @@
1
+ import tseslint from 'typescript-eslint'
2
+ import importPlugin from 'eslint-plugin-import'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import jsxA11y from 'eslint-plugin-jsx-a11y'
5
+ import unicorn from 'eslint-plugin-unicorn'
6
+
7
+ export default [
8
+ // ---- ignore common build artifacts and generated files
9
+ {
10
+ ignores: [
11
+ '**/dist/**',
12
+ '**/coverage/**',
13
+ '**/.yalc/**',
14
+ '**/node_modules/**',
15
+ '**/*.d.ts',
16
+ '**/scripts/**',
17
+ '**/*.config.js',
18
+ '**/*.config.ts',
19
+ '**/vitest-setup.ts',
20
+ '**/vitest.setup.ts'
21
+ ]
22
+ },
23
+
24
+ // ---- base TypeScript recommendations
25
+ ...tseslint.configs.recommended,
26
+
27
+ // ---- project-wide rules and import resolver
28
+ {
29
+ plugins: {
30
+ import: importPlugin,
31
+ 'react-hooks': reactHooks,
32
+ 'jsx-a11y': jsxA11y,
33
+ unicorn: unicorn,
34
+ },
35
+ settings: {
36
+ // Let eslint-plugin-import resolve TS paths and packages without extensions
37
+ 'import/resolver': {
38
+ typescript: {
39
+ alwaysTryTypes: true,
40
+ project: ['./tsconfig.json'],
41
+ },
42
+ },
43
+ },
44
+ languageOptions: {
45
+ // Enable type-aware capabilities when available without forcing per-repo setup
46
+ parserOptions: {
47
+ projectService: true,
48
+ },
49
+ // Define globals for browser and Node.js environments
50
+ globals: {
51
+ // Browser globals
52
+ window: 'readonly',
53
+ document: 'readonly',
54
+ fetch: 'readonly',
55
+ EventSource: 'readonly',
56
+ MessageEvent: 'readonly',
57
+ URLSearchParams: 'readonly',
58
+ console: 'readonly',
59
+ localStorage: 'readonly',
60
+ sessionStorage: 'readonly',
61
+ navigator: 'readonly',
62
+ setTimeout: 'readonly',
63
+ setInterval: 'readonly',
64
+ clearTimeout: 'readonly',
65
+ clearInterval: 'readonly',
66
+ crypto: 'readonly',
67
+
68
+ // Node.js globals
69
+ process: 'readonly',
70
+ Buffer: 'readonly',
71
+ __dirname: 'readonly',
72
+ __filename: 'readonly',
73
+ module: 'readonly',
74
+ require: 'readonly',
75
+ exports: 'readonly',
76
+ global: 'readonly',
77
+
78
+ // TypeScript globals
79
+ NodeJS: 'readonly',
80
+
81
+ // React/JSX globals
82
+ JSX: 'readonly',
83
+ HTMLElement: 'readonly',
84
+ HTMLInputElement: 'readonly',
85
+ HTMLDivElement: 'readonly',
86
+ React: 'readonly',
87
+
88
+ // Browser APIs
89
+ requestAnimationFrame: 'readonly',
90
+ cancelAnimationFrame: 'readonly',
91
+ Response: 'readonly',
92
+ Headers: 'readonly',
93
+ RequestInit: 'readonly',
94
+ },
95
+ },
96
+ rules: {
97
+ // Never use .ts/.tsx extensions, always use .js/.json extensions
98
+ 'import/extensions': ['error', 'never', {
99
+ 'js': 'always',
100
+ 'json': 'always'
101
+ }],
102
+
103
+ // Allow dev dependencies in tests, configs and scripts
104
+ 'import/no-extraneous-dependencies': ['error', {
105
+ devDependencies: [
106
+ '**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts}',
107
+ '**/__tests__/**',
108
+ '**/vite.config.*',
109
+ '**/vitest.config.*',
110
+ '**/tsup.config.*',
111
+ '**/eslint.config.*',
112
+ '**/scripts/**',
113
+ ],
114
+ }],
115
+
116
+ // TS ergonomics
117
+ '@typescript-eslint/no-unused-vars': ['warn', {
118
+ argsIgnorePattern: '^_',
119
+ varsIgnorePattern: '^_',
120
+ caughtErrorsIgnorePattern: '^_'
121
+ }],
122
+ '@typescript-eslint/no-explicit-any': 'off',
123
+ '@typescript-eslint/no-empty-object-type': 'off', // Allow empty interfaces (will be extended in future)
124
+ '@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }],
125
+
126
+ // CRITICAL: Catch undefined variables (missing imports)
127
+ 'no-undef': 'error',
128
+
129
+ // Naming conventions
130
+ '@typescript-eslint/naming-convention': [
131
+ 'error',
132
+ // Interfaces: PascalCase with optional I prefix
133
+ {
134
+ selector: 'interface',
135
+ format: ['PascalCase'],
136
+ custom: {
137
+ regex: '^I?[A-Z]',
138
+ match: true,
139
+ },
140
+ },
141
+ // Type aliases: PascalCase
142
+ {
143
+ selector: 'typeAlias',
144
+ format: ['PascalCase'],
145
+ },
146
+ // Enums: PascalCase
147
+ {
148
+ selector: 'enum',
149
+ format: ['PascalCase'],
150
+ },
151
+ // Classes: PascalCase
152
+ {
153
+ selector: 'class',
154
+ format: ['PascalCase'],
155
+ },
156
+ // Variables: camelCase or UPPER_CASE (for constants)
157
+ {
158
+ selector: 'variable',
159
+ format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
160
+ leadingUnderscore: 'allow',
161
+ },
162
+ // Functions: camelCase or PascalCase (for React components)
163
+ {
164
+ selector: 'function',
165
+ format: ['camelCase', 'PascalCase'],
166
+ },
167
+ // Parameters: camelCase or PascalCase (for React component parameters)
168
+ {
169
+ selector: 'parameter',
170
+ format: ['camelCase', 'PascalCase'],
171
+ leadingUnderscore: 'allow',
172
+ },
173
+ // Properties: camelCase, UPPER_CASE, or PascalCase
174
+ // Allow __html (React dangerouslySetInnerHTML), 2xl (Tailwind), and kebab-case for HTTP headers
175
+ {
176
+ selector: 'property',
177
+ format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
178
+ leadingUnderscore: 'allow',
179
+ filter: {
180
+ // Allow:
181
+ // - __html, __[a-z]+ (React internals)
182
+ // - --cols-sm, --text-primary (CSS variables)
183
+ // - 2xl, 5m, 10m (Tailwind sizes, time units)
184
+ // - kebab-case: chart-line, date-picker, gpt-4, claude-3-sonnet, gpt-3.5-turbo
185
+ // - snake_case: error_rate, plugin_failure
186
+ // - PascalCase-kebab: Header-Content
187
+ // - percentages: 0%, 100%
188
+ // - numeric: 50, 100, 200, 404, 500 (HTTP status codes, color values)
189
+ regex: '^(__|--)[a-z0-9-]+$|^[0-9]+[a-z]+$|^[a-z]+(-[a-z0-9.]+)+$|^[a-z]+(_[a-z]+)+$|^([A-Z][a-z]+-)*[A-Z][a-z]+$|^[0-9]+%$|^[0-9]+$',
190
+ match: false,
191
+ },
192
+ },
193
+ // Methods: camelCase or PascalCase (for mocked React components in tests)
194
+ {
195
+ selector: 'method',
196
+ format: ['camelCase', 'PascalCase'],
197
+ },
198
+ ],
199
+
200
+ // General safety / clarity
201
+ 'no-console': 'off',
202
+ 'no-debugger': 'warn',
203
+ 'eqeqeq': ['error', 'smart'],
204
+ 'curly': ['error', 'all'],
205
+
206
+ // React Hooks rules
207
+ 'react-hooks/rules-of-hooks': 'error',
208
+ 'react-hooks/exhaustive-deps': 'warn',
209
+
210
+ // JSX A11y basics
211
+ 'jsx-a11y/alt-text': 'warn',
212
+ 'jsx-a11y/anchor-is-valid': 'warn',
213
+
214
+ // File naming conventions
215
+ 'unicorn/filename-case': [
216
+ 'error',
217
+ {
218
+ cases: {
219
+ // React components: PascalCase (MyComponent.tsx)
220
+ // React hooks: camelCase (useHook.ts) - matched by camelCase
221
+ // Utility files: kebab-case (my-util.ts)
222
+ // Config files: kebab-case (tsup.config.ts)
223
+ // Test files: kebab-case (my-component.test.tsx)
224
+ kebabCase: true,
225
+ pascalCase: true,
226
+ camelCase: true,
227
+ },
228
+ ignore: [
229
+ // Allow common patterns
230
+ '^.*\\.config\\.(ts|js|mjs|cjs)$',
231
+ '^.*\\.test\\.(ts|tsx|js|jsx)$',
232
+ '^.*\\.spec\\.(ts|tsx|js|jsx)$',
233
+ '^README\\.md$',
234
+ '^CHANGELOG\\.md$',
235
+ '^LICENSE$',
236
+ // Allow UI prefix pattern (UIButton.tsx, UICard.tsx, etc.)
237
+ '^UI[A-Z].*\\.(ts|tsx|js|jsx)$',
238
+ ],
239
+ },
240
+ ],
241
+ },
242
+ },
243
+
244
+ // ---- minimal .vue support (without forcing Vue plugin)
245
+ {
246
+ files: ['**/*.vue'],
247
+ languageOptions: {
248
+ parserOptions: { extraFileExtensions: ['.vue'] },
249
+ },
250
+ },
251
+
252
+ // ---- config files: allow .js extensions for ESM compatibility
253
+ {
254
+ files: ['**/*.config.{ts,js,mjs,cjs}', '**/tsup.config.ts', '**/vite.config.ts', '**/vitest.config.ts'],
255
+ rules: {
256
+ 'import/extensions': 'off',
257
+ },
258
+ },
259
+ ]
260
+
package/package.json ADDED
@@ -0,0 +1,186 @@
1
+ {
2
+ "name": "@kb-labs/devkit",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Shared developer toolkit for KB Labs projects: TS/ESLint/Prettier/Vitest/Tsup presets and reusable GitHub Actions.",
6
+ "files": [
7
+ "agents",
8
+ ".cursorrules",
9
+ "tsconfig",
10
+ "eslint",
11
+ "prettier",
12
+ "vitest",
13
+ "vite",
14
+ "tsup",
15
+ "templates",
16
+ ".github",
17
+ ".vscode",
18
+ "bin",
19
+ "sync",
20
+ "AGENTS.md",
21
+ ".github",
22
+ ".github/workflow-templates/**",
23
+ ".github/actions/**"
24
+ ],
25
+ "bin": {
26
+ "kb-devkit-sync": "./bin/devkit-sync.mjs",
27
+ "kb-devkit-paths": "./bin/devkit-paths.mjs",
28
+ "kb-devkit-tsup-external": "./bin/devkit-tsup-external.mjs",
29
+ "kb-devkit-validate-naming": "./bin/devkit-validate-naming.mjs",
30
+ "kb-devkit-check-imports": "./bin/devkit-check-imports.mjs",
31
+ "kb-devkit-check-exports": "./bin/devkit-check-exports.mjs",
32
+ "kb-devkit-check-duplicates": "./bin/devkit-check-duplicates.mjs",
33
+ "kb-devkit-check-structure": "./bin/devkit-check-structure.mjs",
34
+ "kb-devkit-check-commands": "./bin/devkit-check-commands.mjs",
35
+ "kb-devkit-check-types": "./bin/devkit-check-types.mjs",
36
+ "kb-devkit-check-configs": "./bin/devkit-check-configs.mjs",
37
+ "kb-devkit-check-scripts": "./bin/devkit-check-scripts.mjs",
38
+ "kb-devkit-migrate-configs": "./bin/devkit-migrate-configs.mjs",
39
+ "kb-devkit-types-audit": "./bin/devkit-types-audit.mjs",
40
+ "kb-devkit-build-order": "./bin/devkit-build-order.mjs",
41
+ "kb-devkit-types-order": "./bin/devkit-types-order.mjs",
42
+ "kb-devkit-visualize": "./bin/devkit-visualize.mjs",
43
+ "kb-devkit-ci": "./bin/devkit-ci.mjs",
44
+ "kb-devkit-fix-deps": "./bin/devkit-fix-deps.mjs",
45
+ "kb-devkit-stats": "./bin/devkit-stats.mjs",
46
+ "kb-devkit-check-paths": "./bin/devkit-check-paths.mjs",
47
+ "kb-devkit-architecture": "./bin/devkit-architecture.mjs",
48
+ "kb-devkit-freshness": "./bin/devkit-freshness.mjs",
49
+ "kb-devkit-check-deprecated": "./bin/devkit-check-deprecated.mjs",
50
+ "kb-devkit-check-build-readiness": "./bin/devkit-check-build-readiness.mjs",
51
+ "kb-devkit-health": "./bin/devkit-health.mjs",
52
+ "kb-devkit-qa": "./bin/kb-devkit-qa.mjs",
53
+ "kb-devkit-qa-history": "./bin/kb-devkit-qa-history.mjs",
54
+ "kb-devkit-core-gate": "./bin/devkit-core-gate.mjs"
55
+ },
56
+ "exports": {
57
+ "./tsconfig/": "./tsconfig/",
58
+ "./tsconfig/base.json": "./tsconfig/base.json",
59
+ "./tsconfig/cli.json": "./tsconfig/cli.json",
60
+ "./tsconfig/lib.json": "./tsconfig/lib.json",
61
+ "./tsconfig/node.json": "./tsconfig/node.json",
62
+ "./tsconfig/react-lib.json": "./tsconfig/react-lib.json",
63
+ "./tsconfig/react-app.json": "./tsconfig/react-app.json",
64
+ "./tsconfig/test.json": "./tsconfig/test.json",
65
+ "./eslint/": "./eslint/",
66
+ "./eslint/node.js": "./eslint/node.js",
67
+ "./eslint/react.js": "./eslint/react.js",
68
+ "./eslint/node": "./eslint/node.js",
69
+ "./eslint/react": "./eslint/react.js",
70
+ "./prettier/": "./prettier/",
71
+ "./prettier/index.json": "./prettier/index.json",
72
+ "./vitest/": "./vitest/",
73
+ "./vitest/node.js": "./vitest/node.js",
74
+ "./vitest/react.js": "./vitest/react.js",
75
+ "./vitest/node": "./vitest/node.js",
76
+ "./vitest/react": "./vitest/react.js",
77
+ "./vite/": "./vite/",
78
+ "./vite/react-app.js": "./vite/react-app.js",
79
+ "./vite/react-app": "./vite/react-app.js",
80
+ "./tsup/": "./tsup/",
81
+ "./tsup/bin.js": "./tsup/bin.js",
82
+ "./tsup/dual.js": "./tsup/dual.js",
83
+ "./tsup/node.js": "./tsup/node.js",
84
+ "./tsup/react-lib.js": "./tsup/react-lib.js",
85
+ "./tsup/sdk.js": "./tsup/sdk.js",
86
+ "./tsup/node": "./tsup/node.js",
87
+ "./tsup/react-lib": "./tsup/react-lib.js",
88
+ "./tsup/bin": "./tsup/bin.js",
89
+ "./tsup/sdk": "./tsup/sdk.js",
90
+ "./tsup/dual": "./tsup/dual.js",
91
+ "./agents/": "./agents/",
92
+ "./cursorrules": "./.cursorrules",
93
+ "./.vscode/settings.json": "./.vscode/settings.json",
94
+ "./AGENTS.md": "./AGENTS.md",
95
+ "./bin/devkit-sync.mjs": "./bin/devkit-sync.mjs",
96
+ "./bin/devkit-paths.mjs": "./bin/devkit-paths.mjs",
97
+ "./bin/devkit-tsup-external.mjs": "./bin/devkit-tsup-external.mjs",
98
+ "./tsup/external.mjs": "./tsup/external.mjs",
99
+ "./tsup/external": "./tsup/external.mjs",
100
+ "./tsup/external-sync.mjs": "./tsup/external-sync.mjs",
101
+ "./tsup/external-sync": "./tsup/external-sync.mjs",
102
+ "./sync": "./sync/index.mjs"
103
+ },
104
+ "peerDependencies": {
105
+ "@playwright/test": "*",
106
+ "eslint": "^9.35.0",
107
+ "tsup": "^8.5.0",
108
+ "typescript": "^5.9.2",
109
+ "typescript-eslint": "^8.44.0",
110
+ "vitest": "^3.2.4"
111
+ },
112
+ "peerDependenciesMeta": {
113
+ "eslint-plugin-import": {
114
+ "optional": true
115
+ },
116
+ "eslint-import-resolver-typescript": {
117
+ "optional": true
118
+ },
119
+ "eslint-plugin-react-hooks": {
120
+ "optional": true
121
+ },
122
+ "eslint-plugin-jsx-a11y": {
123
+ "optional": true
124
+ },
125
+ "@testing-library/react": {
126
+ "optional": true
127
+ },
128
+ "react": {
129
+ "optional": true
130
+ },
131
+ "@vitejs/plugin-react": {
132
+ "optional": true
133
+ }
134
+ },
135
+ "dependencies": {
136
+ "eslint-import-resolver-typescript": "^3.10.1",
137
+ "eslint-plugin-import": "^2.32.0",
138
+ "eslint-plugin-unused-imports": "^4.1.4",
139
+ "glob": "^11.0.0",
140
+ "yaml": "^2.8.0"
141
+ },
142
+ "devDependencies": {
143
+ "@types/node": "^24.3.3",
144
+ "@vitest/coverage-v8": "^3.2.4",
145
+ "eslint": "^9.35.0",
146
+ "eslint-plugin-filenames-simple": "^0.9.0",
147
+ "eslint-plugin-sonarjs": "^3.0.6",
148
+ "eslint-plugin-unicorn": "^62.0.0",
149
+ "jsdom": "^27.0.0",
150
+ "prettier": "^3.6.2",
151
+ "rimraf": "^6.0.1",
152
+ "tsup": "^8.5.0",
153
+ "typescript": "^5.9.2",
154
+ "typescript-eslint": "^8.44.0",
155
+ "vitest": "^3.2.4",
156
+ "@kb-labs/devkit": "1.0.0"
157
+ },
158
+ "engines": {
159
+ "node": ">=20.0.0",
160
+ "pnpm": ">=9.11.0"
161
+ },
162
+ "license": "MIT",
163
+ "publishConfig": {
164
+ "access": "public"
165
+ },
166
+ "scripts": {
167
+ "clean": "rimraf dist",
168
+ "build": "echo \"@kb-labs/devkit: nothing to build\"",
169
+ "lint": "eslint . --ignore-pattern 'dist/**'",
170
+ "lint:fix": "eslint . --fix --ignore-pattern 'dist/**'",
171
+ "test": "vitest run --passWithNoTests",
172
+ "test:watch": "vitest --passWithNoTests",
173
+ "paths": "node ./bin/devkit-paths.mjs",
174
+ "fixtures": "node scripts/fixtures.js –help",
175
+ "fixtures:check": "node scripts/fixtures.js –action=check",
176
+ "fixtures:lint": "node scripts/fixtures.js –action=lint",
177
+ "fixtures:test": "node scripts/fixtures.js –action=test",
178
+ "fixtures:build": "node scripts/fixtures.js –action=build",
179
+ "fixtures:bootstrap": "node scripts/fixtures.js –action=bootstrap",
180
+ "fixtures:clean": "node scripts/fixtures.js –action=clean",
181
+ "fixtures:ci": "node scripts/fixtures.js –action=check –since=${GITHUB_BASE_REF:-origin/main} –concurrency=3 || node scripts/fixtures.js –action=check",
182
+ "postinstall": "kb-devkit-tsup-external --generate || true",
183
+ "dev": "tsup --config tsup.config.ts --watch",
184
+ "type-check": "tsc --noEmit"
185
+ }
186
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/prettierrc",
3
+ "semi": false,
4
+ "singleQuote": true,
5
+ "trailingComma": "all",
6
+ "printWidth": 100,
7
+ "tabWidth": 2,
8
+ "arrowParens": "always",
9
+ "endOfLine": "lf"
10
+ }