| name | nodejs-typescript-foundation |
| description | Sets the baseline tooling and tsconfig for any Node.js TypeScript project: strict compiler flags, ESLint, Prettier, package layout, npm scripts. Use when bootstrapping a new project or auditing an existing one for foundational quality. |
Node.js TypeScript Foundation
When to use
- Bootstrapping a new Node.js TypeScript project
- Auditing an existing project's foundational tooling
- Adding strict type-checking and linting
Core rules
tsconfig.json must enable strict: true, noImplicitAny: true, strictNullChecks: true
- ESLint with
@typescript-eslint parser, no any, no console.log in production
- Prettier for formatting, integrated with ESLint
- Package layout:
src/, dist/, tests/, npm scripts for build/lint/test
- All third-party libs must have
@types/* packages installed
Reference shape (TypeScript)
tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "tests"]
}
ESLint config (.eslintrc.json)
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": "error",
"no-console": ["warn", { "allow": ["warn", "error"] }]
}
}
Examples — Do
class UserService {
constructor(private readonly repository: UserRepository) {}
async findById(id: string): Promise<User | null> {
return this.repository.findById(id);
}
}
Examples — Don't
function getUser(id) {
return db.query(`SELECT * FROM users WHERE id = ${id}`);
}
Checklist
See reference/foundation-setup.md for full setup guide.