prebuild-check
v1.1.4
Published
Ensures there are no TypeScript type errors before building
Downloads
2
Maintainers
Readme
prebuild-check
prebuild-check is a lightweight CLI tool that ensures there are no TypeScript type errors before running your project's build process. It leverages the TypeScript compiler API to perform type checking quickly and efficiently, providing clear and colorful output in the terminal.
Features
- Type Checking: Automatically checks for TypeScript (.ts) and React TypeScript (.tsx) files using the TypeScript compiler API.
- ESLint Integration: Can also run ESLint checks to ensure code quality (with the
--eslintflag). - Clean Output: Displays summarized error messages in a colorful format using libraries like chalk and boxen.
- Exit Codes: Exits with a non-zero code if type errors are found, preventing the build from proceeding.
- Custom Patterns: Specify custom glob patterns for files to include in the checks.
- Easy to Use: Can be run via
npx prebuild-checkor installed globally/locally.
Installation
You can install prebuild-check globally or locally in your project:
# Install globally
pnpm add -g prebuild-check
# Or install locally
pnpm add -D prebuild-checkUsage
To check for TypeScript type errors in your project, simply run:
npx prebuild-checkThis command will automatically use your project's tsconfig.json to perform the type checking.
CLI Options
--strict: Enable strict type checking.--warn-only: Show warnings instead of errors.--tsconfig <path>: Specify a custom path to yourtsconfig.json.--eslint: Also run ESLint checks.--include <patterns>: Comma-separated glob patterns of files to include, e.g., "src//*.tsx,src//*.ts".
Examples
# Basic type checking
npx prebuild-check
# Enable strict mode
npx prebuild-check --strict
# Use a custom tsconfig path
npx prebuild-check --tsconfig ./configs/tsconfig.prod.json
# Run with ESLint checks
npx prebuild-check --eslint
# Only show warnings without failing the build
npx prebuild-check --warn-only
# Check specific file patterns
npx prebuild-check --include "src/**/*.tsx,src/**/*.ts"
# Combine options
npx prebuild-check --eslint --include "src/**/*.tsx" --warn-onlyContributing
Contributions are welcome! Please open an issue or submit a pull request if you have suggestions or improvements.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
