Skip to content

Commit b668240

Browse files
authored
feat: enable typescript eslint rules requiring type information (#62)
- Added type-aware rules from @typescript-eslint/recommended-type-checked - Configured ESLint to use TypeScript compiler for enhanced type checking - Rules catch floating promises, unsafe type assertions, and other subtle issues - Applied to src/**/*.ts and tests/**/*.ts files only - Performance impact minimal (~1.5s for full project lint) Closes #61
1 parent 69119af commit b668240

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'agentic-node-ts-starter': minor
3+
---
4+
5+
feat: Enable TypeScript ESLint rules requiring type information
6+
7+
- Added TypeScript ESLint type-aware rules (@typescript-eslint/recommended-type-checked)
8+
- Configured ESLint to use TypeScript compiler for enhanced type checking
9+
- Type-aware rules now catch floating promises, unsafe type assertions, and other subtle type-safety issues
10+
- Rules apply to src/**/\*.ts and tests/**/\*.ts files
11+
- Minimal performance impact (~1.5s for full project lint)
12+
- Improved code quality and runtime safety through compile-time checks
13+
14+
Closes #61

CLAUDE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4545

4646
- **Test-as-contract**: Property-based testing with fast-check for invariants, unit tests with Vitest
4747
- **Type safety**: Strict TypeScript with runtime validation using Zod for external boundaries
48+
- **Advanced linting**: TypeScript ESLint with type-aware rules for catching subtle type-safety issues
4849
- **Module system**: ES modules (`"type": "module"`) with NodeNext resolution
4950
- **Claude Commands**: Custom commands in `.claude/commands/` for common workflows
5051
- **Git Hooks**: Custom pre-commit verification via `.claude/hooks/`
@@ -153,7 +154,10 @@ Available slash commands in `.claude/commands/`:
153154
- **Node Version**: >=22.0.0 (engines requirement)
154155
- **TypeScript**: Strict mode with NodeNext module resolution
155156
- **Testing**: Vitest with V8 coverage provider
156-
- **Linting**: ESLint 9 with TypeScript support
157+
- **Linting**: ESLint 9 with TypeScript support and type-aware rules enabled
158+
- Catches floating promises, unsafe type assertions, and other type-safety issues
159+
- Type-aware rules apply to `src/**/*.ts` and `tests/**/*.ts` files
160+
- Performance impact: ~1.5s for full project lint (acceptable trade-off for improved safety)
157161
- **Formatting**: Prettier 3 with ESLint integration
158162
- **Versioning**: Changesets for automated version management
159163

eslint.config.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22
import tseslint from '@typescript-eslint/eslint-plugin';
33
import tsParser from '@typescript-eslint/parser';
44
import eslintConfigPrettier from 'eslint-config-prettier';
5+
import { fileURLToPath } from 'node:url';
6+
import { dirname } from 'node:path';
7+
8+
const __dirname = dirname(fileURLToPath(import.meta.url));
59

610
/** @type {import('eslint').Linter.FlatConfig[]} */
711
export default [
12+
// Base configuration for all JS/TS files
813
{
914
files: ['**/*.{ts,tsx,js}'],
1015
languageOptions: {
1116
parser: tsParser,
12-
parserOptions: { ecmaVersion: 2024, sourceType: 'module' },
17+
parserOptions: {
18+
ecmaVersion: 2024,
19+
sourceType: 'module',
20+
},
1321
},
1422
plugins: { '@typescript-eslint': tseslint },
1523
rules: {
@@ -18,6 +26,22 @@ export default [
1826
'no-debugger': 'error',
1927
},
2028
},
29+
// Type-aware rules for TypeScript files only
30+
{
31+
files: ['src/**/*.ts', 'tests/**/*.ts'],
32+
languageOptions: {
33+
parser: tsParser,
34+
parserOptions: {
35+
ecmaVersion: 2024,
36+
sourceType: 'module',
37+
project: true,
38+
tsconfigRootDir: __dirname,
39+
},
40+
},
41+
rules: {
42+
...tseslint.configs['recommended-type-checked'].rules,
43+
},
44+
},
2145
// Keep Prettier last
2246
eslintConfigPrettier,
2347
];

0 commit comments

Comments
 (0)