tsconf-validator
v0.1.0
Published
tsconfig validator cli tool
Maintainers
Readme
tsconf-validator
A CLI tool to validate your TypeScript configuration files (tsconfig.json). It helps catch common configuration issues, typos, and potential problems in your TypeScript project setup.
Features
- ✅ Validates
tsconfig.jsonfiles for common issues - 🔍 Checks for non-existent paths in
include,exclude, andpaths - 🚨 Validates
rootDirand other compiler options - ⚠️ Warns about potentially problematic patterns
- 🔄 Works with multiple
tsconfig.jsonfiles in monorepos - 🛠️ Zero configuration - works out of the box
Installation
You can install it globally to use across all your projects:
npm install -g tsconf-validator
# or
yarn global add tsconf-validator
# or
pnpm add -g tsconf-validatorOr use it directly with npx:
npx tsconf-validatorUsage
Basic Usage
To validate all tsconfig.json files in your project:
tsconf-validatorThis will recursively find and validate all tsconfig.json files in your project, excluding node_modules.
Validate a Specific File
To validate a specific tsconfig.json file:
# Validate all tsconfig*.json files
validate-tsconfigs
# Validate specific file
tsconf-validator --config path/to/your/tsconfig.json
# or
validate-tsconfigs -c path/to/your/tsconfig.jsonIntegration with npm scripts
Add it to your package.json:
{
"scripts": {
"validate:tsconfig": "tsconf-validator"
}
}Then run:
npm run validate:tsconfigWhat It Checks
The validator performs the following checks:
Include/Exclude Patterns
- Verifies that all patterns in the
includearray match at least one file/directory - Warns about potentially problematic
excludepatterns that don't match anything - Ignores common patterns like
node_modules,dist,build, etc.
Paths and Aliases
- Validates that all path aliases in
compilerOptions.pathsresolve to existing files/directories - Helps catch typos in path mappings
Root Directory
- Verifies that
compilerOptions.rootDirexists and is a directory - Ensures your source directory structure is correctly configured
Exit Codes
0: All configurations are valid (may have warnings)1: One or more configurations have errors2: Notsconfig.jsonfiles found
License
Distributed under the MIT License. See LICENSE for more information.
Support
If you find this project helpful, please consider giving it a ⭐️ on GitHub!
