typescript-template-configs
v4.0.0
Published
Shared TypeScript configuration files for library templates. Provides standardized ESLint, Prettier, Vitest, TypeScript, and build configs.
Downloads
125
Maintainers
Readme
typescript-template-configs
Shared TypeScript configuration files for library templates. Provides standardized ESLint, Prettier, Vitest, TypeScript, and build configs.
📦 What's Included
This package provides base configuration files for TypeScript library templates:
Locked Configs (Use As-Is)
.prettierrc- Code formatting rules.prettierignore- Files to ignore from formatting
Extendable Configs (Can Be Customized)
eslint.config.base.mjs- Base ESLint rules + TypeScript supportvitest.config.base.ts- Vitest test framework configurationtsconfig.base.json- TypeScript compiler base settingstsdown.config.base.ts- Build configuration for tsdownpackage-scripts.json- Standardized npm scripts reference
🚀 Installation
pnpm add -D typescript-template-configs
# Also install peer dependency:
pnpm add -D tsdown🛠️ CLI Commands
Initialize Project
npx typescript-template-configs
# or
npx typescript-template-configs initCreates .npmrc to configure pnpm to hoist CLI binaries from peer dependencies.
Show Help
npx typescript-template-configs helpList Bundled Packages
npx typescript-template-configs infoShows all 19 packages bundled with this config (eslint, prettier, typescript, vitest, etc.) that you don't need to install separately.
Remove Redundant Dependencies
npx typescript-template-configs cleanup
# or auto-confirm with
npx typescript-template-configs cleanup --yesScans your package.json and removes any devDependencies that are already bundled with typescript-template-configs.
Minimal Installation
Since this package bundles all tooling, you only need:
{
"devDependencies": {
"typescript-template-configs": "^3.0.0",
"tsdown": "^0.12.0"
}
}For local development (testing before publishing):
# Build first, then test
pnpm build
node dist/cli.js help
# Or link globally
pnpm link --global
typescript-template-configs help📖 Usage
Prettier (Locked - Use Exact Copy)
Copy the Prettier config to your project root:
cp node_modules/typescript-template-configs/.prettierrc .
cp node_modules/typescript-template-configs/.prettierignore .Or reference it in your package.json:
{
"prettier": "typescript-template-configs/prettier"
}ESLint (Extendable)
Basic usage (inherit all base rules):
// eslint.config.mjs
import baseConfig from "typescript-template-configs/eslint"
export default [...baseConfig]Extended usage (add variant-specific rules):
// eslint.config.mjs
import baseConfig from "typescript-template-configs/eslint"
export default [
...baseConfig,
{
// React-specific rules
files: ["**/*.tsx"],
rules: {
"react/jsx-uses-react": "error",
"react-hooks/rules-of-hooks": "error",
},
},
]Vitest (Extendable)
Basic usage:
// vitest.config.ts
import { defineConfig } from "vitest/config"
import baseConfig from "typescript-template-configs/vitest"
export default defineConfig(baseConfig)Extended usage:
// vitest.config.ts
import { defineConfig } from "vitest/config"
import baseConfig from "typescript-template-configs/vitest"
export default defineConfig({
...baseConfig,
test: {
...baseConfig.test,
setupFiles: ["./test/setup.ts"], // Add custom setup
},
})TypeScript (Extendable)
Basic usage:
{
"extends": "typescript-template-configs/tsconfig",
"compilerOptions": {
"outDir": "./dist"
}
}Extended usage:
{
"extends": "typescript-template-configs/tsconfig",
"compilerOptions": {
"outDir": "./dist",
"jsx": "react-jsx",
"lib": ["ES2020", "DOM"]
}
}Tsdown (Extendable)
Basic usage:
// tsdown.config.ts
import baseConfig from "typescript-template-configs/tsdown"
export default baseConfigExtended usage (customize entry points):
// tsdown.config.ts
import baseConfig from "typescript-template-configs/tsdown"
import type { UserConfig } from "tsdown"
export default {
...baseConfig,
entry: ["src/index.ts", "src/cli.ts"], // Multiple entry points
} satisfies UserConfigPackage Scripts (Reference Only)
The package-scripts.json file contains standardized npm scripts. Copy the relevant scripts to your package.json:
{
"scripts": {
"validate": "pnpm format && pnpm lint && pnpm test && pnpm build",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "eslint ./src --fix",
"lint:check": "eslint ./src",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --ui",
"build": "rimraf dist && cross-env NODE_ENV=production tsdown",
"build:watch": "tsdown --watch",
"dev": "tsdown --watch",
"prepublishOnly": "pnpm validate",
"ts-types": "tsc"
}
}🔄 Update Workflow
When configs are updated in this package, update your template:
# Update to latest version
pnpm update typescript-template-configs
# Re-copy locked files (Prettier)
cp node_modules/typescript-template-configs/.prettierrc .
cp node_modules/typescript-template-configs/.prettierignore .
# Test that everything still works
pnpm validate🎯 Design Philosophy
Locked vs Extendable
Locked files ensure consistency across all templates:
- Prettier - Code formatting should be identical everywhere
- Prevents formatting debates and merge conflicts
Extendable files allow variant-specific customization:
- ESLint - Different variants need different rules (React, Node.js, etc.)
- Vitest - Some variants need custom test setup
- TypeScript - Browser vs Node targets, JSX support, etc.
- Build configs - Different entry points, output formats
Semantic Versioning
This package follows semver:
- Patch (1.0.x) - Bug fixes in configs
- Minor (1.x.0) - New configs added, backward compatible
- Major (x.0.0) - Breaking changes to existing configs
📚 Available Template Variants
Templates using these configs:
- typescript-library-template - Base template (tsdown)
- typescript-library-template-vite - Vite-based variant (coming soon)
- typescript-library-template-react - React library variant (coming soon)
🤝 Contributing
Found a bug or want to improve the configs?
- Fork this repository
- Make your changes
- Test in a template project
- Submit a PR with explanation
📄 License
MIT © Jordan Burke
🔗 Related
- STANDARDIZATION_GUIDE.md - How to apply this pattern
- package-scripts.json - Script reference documentation
