Prompt file imported from mcurcio/rasl (
.windsurf/workflows/bootstrap-typescript.md). Fill in{{name}}before use. Copyright stays with the author.
Bootstrap TypeScript Project
Bootstrap a modern TypeScript project with tsx, eslint, prettier, and vitest configured according to best practices.
Steps
-
Initialize package.json
- Create a
package.jsonfile in the current workspace root - Set
"type": "module"for ES modules - Set
"private": true - Add the following scripts:
"scripts": { "build": "tsc", "test": "vitest", "dev": "tsx watch src/index.ts", "lint": "eslint src", "lint:fix": "eslint src --fix", "format": "prettier -w .", "format:check": "prettier -c .", "typecheck": "tsc --noEmit" } - Add these devDependencies:
@types/node@^20.10.0@typescript-eslint/eslint-plugin@^8.19.0@typescript-eslint/parser@^8.19.0eslint@^8.55.0eslint-config-prettier@^9.1.0eslint-plugin-simple-import-sort@^12.1.1prettier@^3.1.0tsx@^4.19.2typescript@^5.3.0vitest@^1.0.0
- Set
"engines": { "node": ">=18.0.0" }
- Create a
-
Create tsconfig.json
- Create a
tsconfig.jsonfile with the following configuration:{ "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", "lib": ["ES2022"], "experimentalDecorators": true, "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "dist", "rootDir": "src", "resolveJsonModule": true, "isolatedModules": true, "noEmit": false, "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true }, "include": ["src/**/*"] }
- Create a
-
Create eslint.config.js
- Create an
eslint.config.jsfile with flat config format:import tsParser from "@typescript-eslint/parser"; import tsPlugin from "@typescript-eslint/eslint-plugin"; import simpleImportSort from "eslint-plugin-simple-import-sort"; import prettierConfig from "eslint-config-prettier"; export default [ { ignores: ["**/dist/**", "**/node_modules/**"], }, prettierConfig, { files: ["**/*.ts", "**/*.tsx"], languageOptions: { parser: tsParser, parserOptions: { ecmaVersion: "latest", sourceType: "module", }, }, plugins: { "@typescript-eslint": tsPlugin, "simple-import-sort": simpleImportSort, }, rules: { quotes: ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }], semi: ["error", "always"], "@typescript-eslint/consistent-type-imports": [ "error", { prefer: "type-imports", fixStyle: "separate-type-imports" }, ], "simple-import-sort/imports": "error", "simple-import-sort/exports": "error", }, }, ];
- Create an
-
Create prettier.config.cjs
- Create a
prettier.config.cjsfile:/** @type {import("prettier").Config} */ module.exports = { printWidth: 120, semi: true, singleQuote: false, trailingComma: "all", };
- Create a
-
Create .prettierignore
- Create a
.prettierignorefile with:dist node_modules coverage .pnpm-store
- Create a
-
Create src directory and sample file
- Create a
src/directory - Create
src/index.tswith a simple example:export function greet(name: string): string { return `Hello, {{name}}!`; } console.log(greet("World"));
- Create a
-
Create .gitignore
- If
.gitignoredoesn't exist, create it with:node_modules dist coverage .pnpm-store *.log .DS_Store
- If
-
Install dependencies
- Run
npm installto install all dependencies - Confirm installation was successful
- Run
-
Verify setup
- Run
npm run typecheckto verify TypeScript configuration - Run
npm run lintto verify ESLint configuration - Run
npm run format:checkto verify Prettier configuration - Report any errors to the user
- Run
-
Summary
- Print a summary of what was created
- List the available npm scripts
- Suggest next steps (e.g., "Run
npm run devto start development")
