@lewishowles/pkg-checks
v0.2.3
Published
Validate package exports, size budgets, runtime dependencies, type declarations, and test coverage.
Readme
pkg-checks
Checks a JavaScript package for common release problems: incorrect package.json exports, runtime dependencies that should be dev dependencies, size budgets, missing type declarations, and missing test coverage.
Requirements
- Bun or Node
Getting started
Published as @lewishowles/pkg-checks:
npm install --save-dev @lewishowles/pkg-checksUsage
pkg-checks exports ./packages/helpers
pkg-checks runtime-deps ./packages/helpers --config ./quality.config.json
pkg-checks size ./packages/helpers --config ./quality.config.json
pkg-checks type-declarations ./packages/helpers
pkg-checks test-coverage ./packages/helpersexports <package-path>: checks category barrels andpackage.jsonexportsruntime-deps <package-path>: checks the configured runtime dependency policysize <package-path>: checks the configured package size budgetstype-declarations <package-path>: checks that exports have matching type declarationstest-coverage <package-path>: checks that exports have colocated test files
Configuration
Each check reads its own top-level key from <package-path>/quality.config.json by default, or from the path passed to --config. You only need the keys for the checks you actually run:
{
"exportsPolicy": {
"internalOnly": ["lib/object/path-traversal.js"],
"fileOnlyEntrypoints": ["./resolver"]
},
"sizeBudgets": {
"perFile": { "globs": ["dist/*.js"], "maxBytes": 12288 },
"total": [{ "name": "dist total", "globs": ["dist/**"], "maxBytes": 122880 }]
},
"runtimeDependencyPolicy": {
"allowed": ["dayjs"]
}
}exportsPolicy.internalOnly: helper files that exist in the package but aren't part of its public export barrel, so theexportscheck doesn't flag them as missingexportsPolicy.fileOnlyEntrypoints: entrypoints (e.g. a CSS file or a resolver) that only need to exist as a file, skipping the barrel/type-declaration checks that apply to regular exportssizeBudgets.perFile: amaxByteslimit applied to every file matchingglobssizeBudgets.total: one or more named groups, each with its ownmaxByteslimit across all its matchingglobsruntimeDependencyPolicy.allowed: dependency names allowed independencies; anything else there gets flagged (move it todevDependencies, or add it here)
