@sicoti/tsconfig 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +331 -0
- package/base.json +89 -0
- package/bun.json +39 -0
- package/nestjs.json +47 -0
- package/nextjs.json +47 -0
- package/package.json +65 -0
- package/react-library.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SICOTI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
# @sicoti/tsconfig
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@sicoti/tsconfig)
|
|
4
|
+
[](https://www.npmjs.com/package/@sicoti/tsconfig)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
> Shareable TypeScript configuration presets with strict type checking for modern projects.
|
|
9
|
+
|
|
10
|
+
## ✨ Features
|
|
11
|
+
|
|
12
|
+
- 🔒 **Maximum Type Safety** — Strict mode plus additional safety checks beyond `strict: true`
|
|
13
|
+
- 📦 **Environment-Specific Presets** — Optimized configs for Next.js, NestJS, React libraries, and Bun
|
|
14
|
+
- 🎯 **Zero Configuration** — Works out of the box with sensible defaults
|
|
15
|
+
- 🔧 **Fully Extensible** — Easy to override any setting for your specific needs
|
|
16
|
+
- 📚 **Well Documented** — Clear comments explaining every option
|
|
17
|
+
|
|
18
|
+
## 📦 Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# npm
|
|
22
|
+
npm install -D @sicoti/tsconfig typescript
|
|
23
|
+
|
|
24
|
+
# yarn
|
|
25
|
+
yarn add -D @sicoti/tsconfig typescript
|
|
26
|
+
|
|
27
|
+
# pnpm
|
|
28
|
+
pnpm add -D @sicoti/tsconfig typescript
|
|
29
|
+
|
|
30
|
+
# bun
|
|
31
|
+
bun add -D @sicoti/tsconfig typescript
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🚀 Quick Start
|
|
35
|
+
|
|
36
|
+
Choose the preset that matches your project type and extend it in your `tsconfig.json`:
|
|
37
|
+
|
|
38
|
+
### Next.js Applications
|
|
39
|
+
|
|
40
|
+
```jsonc
|
|
41
|
+
{
|
|
42
|
+
"extends": "@sicoti/tsconfig/nextjs.json",
|
|
43
|
+
"compilerOptions": {
|
|
44
|
+
"baseUrl": ".",
|
|
45
|
+
"paths": {
|
|
46
|
+
"@/*": ["./src/*"]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
50
|
+
"exclude": ["node_modules"]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### NestJS Applications
|
|
55
|
+
|
|
56
|
+
```jsonc
|
|
57
|
+
{
|
|
58
|
+
"extends": "@sicoti/tsconfig/nestjs.json",
|
|
59
|
+
"compilerOptions": {
|
|
60
|
+
"outDir": "./dist",
|
|
61
|
+
"baseUrl": ".",
|
|
62
|
+
"paths": {
|
|
63
|
+
"@/*": ["./src/*"]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"include": ["src/**/*"],
|
|
67
|
+
"exclude": ["node_modules", "dist"]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### React Component Libraries
|
|
72
|
+
|
|
73
|
+
```jsonc
|
|
74
|
+
{
|
|
75
|
+
"extends": "@sicoti/tsconfig/react-library.json",
|
|
76
|
+
"compilerOptions": {
|
|
77
|
+
"outDir": "./dist",
|
|
78
|
+
"rootDir": "./src",
|
|
79
|
+
"baseUrl": ".",
|
|
80
|
+
"paths": {
|
|
81
|
+
"@/*": ["./src/*"]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"include": ["src/**/*"],
|
|
85
|
+
"exclude": ["dist", "node_modules"]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Bun Packages & CLI Tools
|
|
90
|
+
|
|
91
|
+
```jsonc
|
|
92
|
+
{
|
|
93
|
+
"extends": "@sicoti/tsconfig/bun.json",
|
|
94
|
+
"compilerOptions": {
|
|
95
|
+
"outDir": "./dist",
|
|
96
|
+
"rootDir": "./src",
|
|
97
|
+
"baseUrl": ".",
|
|
98
|
+
"paths": {
|
|
99
|
+
"@/*": ["./src/*"]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"include": ["src/**/*"],
|
|
103
|
+
"exclude": ["dist", "node_modules"]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 📋 Available Presets
|
|
108
|
+
|
|
109
|
+
| Preset | Use Case | Key Features |
|
|
110
|
+
|:-------|:---------|:-------------|
|
|
111
|
+
| `nextjs.json` | Next.js apps (App Router / Pages Router) | `jsx: preserve`, `noEmit`, Next.js plugin |
|
|
112
|
+
| `nestjs.json` | NestJS backend applications | Decorator metadata, source maps, DI support |
|
|
113
|
+
| `react-library.json` | React component libraries | `jsx: react-jsx`, declaration files, source maps |
|
|
114
|
+
| `bun.json` | Bun runtime packages & CLI tools | Declaration files, optimized for Bun bundler |
|
|
115
|
+
| `base.json` | ⚠️ Internal foundation (not for direct use) | Universal strict settings |
|
|
116
|
+
|
|
117
|
+
## 🔒 Strict Type Checking
|
|
118
|
+
|
|
119
|
+
All presets inherit from `base.json` which enables maximum type safety:
|
|
120
|
+
|
|
121
|
+
### Enabled by `strict: true`
|
|
122
|
+
|
|
123
|
+
| Option | Description |
|
|
124
|
+
|:-------|:------------|
|
|
125
|
+
| `strictNullChecks` | Check null/undefined assignments |
|
|
126
|
+
| `strictFunctionTypes` | Strict function type checking |
|
|
127
|
+
| `strictBindCallApply` | Type checking for bind/call/apply |
|
|
128
|
+
| `strictPropertyInitialization` | Ensure class properties are initialized |
|
|
129
|
+
| `noImplicitThis` | Error on implicit 'this' types |
|
|
130
|
+
| `noImplicitAny` | Error on implicit 'any' types |
|
|
131
|
+
| `alwaysStrict` | Emit "use strict" in all files |
|
|
132
|
+
| `useUnknownInCatchVariables` | Use 'unknown' instead of 'any' in catch |
|
|
133
|
+
|
|
134
|
+
### Additional Safety Checks (Not in `strict: true`)
|
|
135
|
+
|
|
136
|
+
| Option | Description |
|
|
137
|
+
|:-------|:------------|
|
|
138
|
+
| `noUnusedLocals` | Error on unused local variables |
|
|
139
|
+
| `noUnusedParameters` | Error on unused function parameters |
|
|
140
|
+
| `noImplicitReturns` | Error when not all paths return a value |
|
|
141
|
+
| `noFallthroughCasesInSwitch` | Error on switch case fall-through |
|
|
142
|
+
| `allowUnreachableCode` | Error on unreachable code |
|
|
143
|
+
| `noUncheckedIndexedAccess` | Add `undefined` to index signature results |
|
|
144
|
+
| `exactOptionalPropertyTypes` | Distinguish between `undefined` and missing |
|
|
145
|
+
| `noPropertyAccessFromIndexSignature` | Require bracket notation for index access |
|
|
146
|
+
| `noImplicitOverride` | Require 'override' keyword for overrides |
|
|
147
|
+
| `noUncheckedSideEffectImports` | Validate side-effect imports exist |
|
|
148
|
+
|
|
149
|
+
## 💡 Why These Checks Matter
|
|
150
|
+
|
|
151
|
+
### `noUncheckedIndexedAccess`
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// ❌ Without: No error, crashes at runtime
|
|
155
|
+
const users: User[] = [];
|
|
156
|
+
const first = users[0]; // Type: User (WRONG!)
|
|
157
|
+
first.name; // 💥 Runtime error: Cannot read property 'name' of undefined
|
|
158
|
+
|
|
159
|
+
// ✅ With: Compiler catches it
|
|
160
|
+
const first = users[0]; // Type: User | undefined
|
|
161
|
+
if (first) {
|
|
162
|
+
first.name; // ✓ Safe access
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### `noFallthroughCasesInSwitch`
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// ❌ Without: Silent fall-through bug
|
|
170
|
+
switch (action) {
|
|
171
|
+
case "login":
|
|
172
|
+
login();
|
|
173
|
+
// Oops! Falls through to logout!
|
|
174
|
+
case "logout":
|
|
175
|
+
logout();
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ✅ With: TS7029 error prevents the bug
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### `exactOptionalPropertyTypes`
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
interface Config {
|
|
186
|
+
cache?: { ttl: number };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ❌ Without: Both accepted but have different semantics
|
|
190
|
+
setConfig({}); // OK - cache is missing
|
|
191
|
+
setConfig({ cache: undefined }); // OK - but this explicitly sets cache to undefined!
|
|
192
|
+
|
|
193
|
+
// ✅ With: Explicit undefined is an error
|
|
194
|
+
// TS2379: Type 'undefined' is not assignable to type '{ ttl: number }'
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Why `strict: true` Alone Is Not Enough
|
|
198
|
+
|
|
199
|
+
Many developers assume that `"strict": true` enables all TypeScript safety checks. **This is a common misconception.** The `strict` flag only enables 8 specific checks, leaving many critical safety features disabled by default.
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// ❌ This code compiles with ONLY strict: true
|
|
203
|
+
|
|
204
|
+
// 1. Unused variables? No error.
|
|
205
|
+
const unusedVar = "I'm never used";
|
|
206
|
+
|
|
207
|
+
// 2. Array access without bounds checking? No error.
|
|
208
|
+
const users: string[] = [];
|
|
209
|
+
const first = users[0]; // Type: string (but it's actually undefined!)
|
|
210
|
+
first.toUpperCase(); // 💥 Runtime crash!
|
|
211
|
+
|
|
212
|
+
// 3. Switch fall-through? No error.
|
|
213
|
+
function handle(action: "save" | "delete") {
|
|
214
|
+
switch (action) {
|
|
215
|
+
case "save":
|
|
216
|
+
save();
|
|
217
|
+
// Oops! Falls through to delete!
|
|
218
|
+
case "delete":
|
|
219
|
+
deleteAll(); // 💥 Unintended deletion!
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 4. Missing return in some branches? No error.
|
|
224
|
+
function getValue(condition: boolean): string {
|
|
225
|
+
if (condition) {
|
|
226
|
+
return "value";
|
|
227
|
+
}
|
|
228
|
+
// 💥 Returns undefined, but TypeScript says it returns string!
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// ✅ With @sicoti/tsconfig - ALL of these are caught at compile time!
|
|
234
|
+
|
|
235
|
+
// 1. TS6133: 'unusedVar' is declared but never used
|
|
236
|
+
const unusedVar = "I'm never used";
|
|
237
|
+
|
|
238
|
+
// 2. TS18048: 'first' is possibly 'undefined'
|
|
239
|
+
const users: string[] = [];
|
|
240
|
+
const first = users[0]; // Type: string | undefined
|
|
241
|
+
if (first) {
|
|
242
|
+
first.toUpperCase(); // ✓ Safe!
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 3. TS7029: Fallthrough case in switch
|
|
246
|
+
function handle(action: "save" | "delete") {
|
|
247
|
+
switch (action) {
|
|
248
|
+
case "save":
|
|
249
|
+
save();
|
|
250
|
+
break; // ✓ Required!
|
|
251
|
+
case "delete":
|
|
252
|
+
deleteAll();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 4. TS7030: Not all code paths return a value
|
|
257
|
+
function getValue(condition: boolean): string {
|
|
258
|
+
if (condition) {
|
|
259
|
+
return "value";
|
|
260
|
+
}
|
|
261
|
+
return "default"; // ✓ Required!
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**Bottom line:** `strict: true` is just the starting point. This package enables **10+ additional checks** that catch real bugs before they reach production.
|
|
266
|
+
|
|
267
|
+
## 🏗️ Architecture
|
|
268
|
+
|
|
269
|
+
```plaintext
|
|
270
|
+
@sicoti/tsconfig/
|
|
271
|
+
├── base.json ← Foundation (DO NOT extend directly)
|
|
272
|
+
│ ├── nextjs.json ← Next.js applications
|
|
273
|
+
│ ├── nestjs.json ← NestJS applications
|
|
274
|
+
│ ├── bun.json ← Bun runtime packages
|
|
275
|
+
│ └── react-library.json ← React component libraries
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Design Philosophy
|
|
279
|
+
|
|
280
|
+
**`base.json` includes:**
|
|
281
|
+
|
|
282
|
+
- Universal strict type checking settings
|
|
283
|
+
- Modern ES module configuration
|
|
284
|
+
- Code quality checks (unused code, control flow)
|
|
285
|
+
- Import safety validations
|
|
286
|
+
|
|
287
|
+
**`base.json` intentionally excludes:**
|
|
288
|
+
|
|
289
|
+
- `lib` (DOM, ESNext) — Varies by runtime environment
|
|
290
|
+
- `jsx` settings — Only for React-based projects
|
|
291
|
+
- `sourceMap`, `declaration` — Build output varies by project
|
|
292
|
+
- `emitDecoratorMetadata` — Only for NestJS/decorator-based DI
|
|
293
|
+
|
|
294
|
+
## 🔧 Customization
|
|
295
|
+
|
|
296
|
+
You can override any setting in your project's `tsconfig.json`:
|
|
297
|
+
|
|
298
|
+
```jsonc
|
|
299
|
+
{
|
|
300
|
+
"extends": "@sicoti/tsconfig/nextjs.json",
|
|
301
|
+
"compilerOptions": {
|
|
302
|
+
// Override specific settings
|
|
303
|
+
"noUncheckedIndexedAccess": false, // Disable if too strict for your codebase
|
|
304
|
+
"baseUrl": ".",
|
|
305
|
+
"paths": {
|
|
306
|
+
"@/*": ["./src/*"],
|
|
307
|
+
"@components/*": ["./src/components/*"]
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## 🤝 Contributing
|
|
314
|
+
|
|
315
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
316
|
+
|
|
317
|
+
1. Fork the repository
|
|
318
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
319
|
+
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
|
|
320
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
321
|
+
5. Open a Pull Request
|
|
322
|
+
|
|
323
|
+
## 📄 License
|
|
324
|
+
|
|
325
|
+
[MIT](LICENSE) © [SICOTI Team](https://github.com/SICOTI-Peru)
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
<p align="center">
|
|
330
|
+
Made with ❤️ by the <a href="https://github.com/SICOTI-Peru">SICOTI Team</a>
|
|
331
|
+
</p>
|
package/base.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"display": "Base Configuration",
|
|
4
|
+
|
|
5
|
+
/* ═══════════════════════════════════════════════════════════════════════════════════
|
|
6
|
+
* @sicoti/tsconfig - Base Configuration
|
|
7
|
+
* ═══════════════════════════════════════════════════════════════════════════════════
|
|
8
|
+
*
|
|
9
|
+
* Foundation configuration that ALL other presets extend.
|
|
10
|
+
* Contains ONLY universal settings applicable to every TypeScript project.
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ INTENTIONALLY EXCLUDED (delegated to environment-specific configs):
|
|
13
|
+
* - Source maps, declarations, emit settings → Build-target specific
|
|
14
|
+
* - skipLibCheck → Performance optimization per environment
|
|
15
|
+
* - lib targets (DOM, ESNext) → Varies by runtime (browser vs server)
|
|
16
|
+
* - JSX settings → Only for React-based projects
|
|
17
|
+
*
|
|
18
|
+
* Available Presets:
|
|
19
|
+
* base.json
|
|
20
|
+
* ├── nextjs.json → Next.js applications
|
|
21
|
+
* ├── nestjs.json → NestJS backend applications
|
|
22
|
+
* ├── bun.json → Bun runtime packages & CLI tools
|
|
23
|
+
* └── react-library.json → React component libraries
|
|
24
|
+
*
|
|
25
|
+
* Reference: https://www.typescriptlang.org/tsconfig
|
|
26
|
+
* ═══════════════════════════════════════════════════════════════════════════════════ */
|
|
27
|
+
|
|
28
|
+
"compilerOptions": {
|
|
29
|
+
/* ═══════════════════════════════════════════════════════════════════════════════
|
|
30
|
+
* STRICT TYPE CHECKING
|
|
31
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
32
|
+
* "strict: true" enables these 8 fundamental rules:
|
|
33
|
+
* → strictNullChecks: Check null/undefined assignments
|
|
34
|
+
* → strictFunctionTypes: Strict function type checking
|
|
35
|
+
* → strictBindCallApply: Type checking for bind/call/apply
|
|
36
|
+
* → strictPropertyInitialization: Ensure class properties are initialized
|
|
37
|
+
* → noImplicitThis: Error on implicit 'this' types
|
|
38
|
+
* → noImplicitAny: Error on implicit 'any' types
|
|
39
|
+
* → alwaysStrict: Emit "use strict" in all files
|
|
40
|
+
* → useUnknownInCatchVariables: Use 'unknown' instead of 'any' in catch
|
|
41
|
+
* ═══════════════════════════════════════════════════════════════════════════════ */
|
|
42
|
+
"strict": true,
|
|
43
|
+
|
|
44
|
+
/* ═══════════════════════════════════════════════════════════════════════════════
|
|
45
|
+
* ADDITIONAL TYPE SAFETY (Not included in strict: true)
|
|
46
|
+
* ═══════════════════════════════════════════════════════════════════════════════ */
|
|
47
|
+
|
|
48
|
+
// ─── Unused Code Detection ───────────────────────────────────────────────────
|
|
49
|
+
"noUnusedLocals": true, // Error on unused local variables
|
|
50
|
+
"noUnusedParameters": true, // Error on unused function parameters
|
|
51
|
+
|
|
52
|
+
// ─── Control Flow Analysis ───────────────────────────────────────────────────
|
|
53
|
+
"noImplicitReturns": true, // Error when not all paths return a value
|
|
54
|
+
"noFallthroughCasesInSwitch": true, // Error on switch case fall-through
|
|
55
|
+
"allowUnreachableCode": false, // Error on unreachable code
|
|
56
|
+
|
|
57
|
+
// ─── Index Signature Safety ──────────────────────────────────────────────────
|
|
58
|
+
"noUncheckedIndexedAccess": true, // Add undefined to index signature results
|
|
59
|
+
"exactOptionalPropertyTypes": true, // Distinguish between undefined and missing
|
|
60
|
+
"noPropertyAccessFromIndexSignature": true, // Require bracket notation for index access
|
|
61
|
+
|
|
62
|
+
// ─── Class & Override Safety ─────────────────────────────────────────────────
|
|
63
|
+
"noImplicitOverride": true, // Require 'override' keyword for overrides
|
|
64
|
+
|
|
65
|
+
// ─── Import Validation ───────────────────────────────────────────────────────
|
|
66
|
+
"noUncheckedSideEffectImports": true, // Validate side-effect imports exist
|
|
67
|
+
|
|
68
|
+
/* ═══════════════════════════════════════════════════════════════════════════════
|
|
69
|
+
* MODULE SYSTEM (Universal Settings)
|
|
70
|
+
* ═══════════════════════════════════════════════════════════════════════════════ */
|
|
71
|
+
"target": "ESNext", // Emit modern JavaScript
|
|
72
|
+
"module": "ESNext", // Use ES modules
|
|
73
|
+
"moduleResolution": "bundler", // Modern bundler resolution (Vite, esbuild, etc.)
|
|
74
|
+
"moduleDetection": "force", // Treat all files as modules
|
|
75
|
+
|
|
76
|
+
// ─── Module Interoperability ─────────────────────────────────────────────────
|
|
77
|
+
"esModuleInterop": true, // Enable CommonJS/ESM interop
|
|
78
|
+
"allowSyntheticDefaultImports": true, // Allow default imports from CJS modules
|
|
79
|
+
"resolveJsonModule": true, // Allow importing JSON files
|
|
80
|
+
"isolatedModules": true, // Ensure safe transpilation by tools
|
|
81
|
+
|
|
82
|
+
/* ═══════════════════════════════════════════════════════════════════════════════
|
|
83
|
+
* CODE QUALITY & CONSISTENCY
|
|
84
|
+
* ═══════════════════════════════════════════════════════════════════════════════ */
|
|
85
|
+
"forceConsistentCasingInFileNames": true, // Enforce consistent file name casing
|
|
86
|
+
"allowImportingTsExtensions": false, // Disallow .ts/.tsx extensions in imports
|
|
87
|
+
"verbatimModuleSyntax": false // Allow flexible import/export syntax
|
|
88
|
+
}
|
|
89
|
+
}
|
package/bun.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"display": "Bun Runtime Configuration",
|
|
4
|
+
"extends": "./base.json",
|
|
5
|
+
|
|
6
|
+
/* ═══════════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
* @sicoti/tsconfig - Bun Preset
|
|
8
|
+
* ═══════════════════════════════════════════════════════════════════════════════════
|
|
9
|
+
*
|
|
10
|
+
* Optimized for Bun runtime packages, CLI tools, and utilities.
|
|
11
|
+
*
|
|
12
|
+
* Key characteristics:
|
|
13
|
+
* - Server-side only (no DOM libs)
|
|
14
|
+
* - Declaration files for library consumers
|
|
15
|
+
* - Optimized for Bun's native bundler
|
|
16
|
+
* - Incremental builds for faster development
|
|
17
|
+
* - Relaxed unused checks for library exports
|
|
18
|
+
*
|
|
19
|
+
* ═══════════════════════════════════════════════════════════════════════════════════ */
|
|
20
|
+
|
|
21
|
+
"compilerOptions": {
|
|
22
|
+
/* ─── Runtime Environment ───────────────────────────────────────────────────── */
|
|
23
|
+
"lib": ["ESNext"], // Server-side only, no DOM
|
|
24
|
+
"target": "ESNext", // Bun supports latest ECMAScript
|
|
25
|
+
|
|
26
|
+
/* ─── Output Settings ───────────────────────────────────────────────────── */
|
|
27
|
+
"noEmit": false, // Emit compiled output
|
|
28
|
+
"declaration": true, // Generate .d.ts for consumers
|
|
29
|
+
"declarationMap": true, // Source maps for declarations
|
|
30
|
+
"skipLibCheck": true, // Skip .d.ts checking for performance
|
|
31
|
+
"incremental": true, // Faster rebuilds
|
|
32
|
+
"tsBuildInfoFile": "./.cache/tsconfig.tsbuildinfo", // Keep build artifacts out of root
|
|
33
|
+
|
|
34
|
+
/* ─── Relaxed Checks for Library Development ─────────────────────────── */
|
|
35
|
+
// Libraries may export utilities that appear unused locally
|
|
36
|
+
"noUnusedLocals": false,
|
|
37
|
+
"noUnusedParameters": false
|
|
38
|
+
}
|
|
39
|
+
}
|
package/nestjs.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"display": "NestJS Configuration",
|
|
4
|
+
"extends": "./base.json",
|
|
5
|
+
|
|
6
|
+
/* ═══════════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
* @sicoti/tsconfig - NestJS Preset
|
|
8
|
+
* ═══════════════════════════════════════════════════════════════════════════════════
|
|
9
|
+
*
|
|
10
|
+
* Optimized for NestJS applications with decorator-based dependency injection.
|
|
11
|
+
*
|
|
12
|
+
* Key characteristics:
|
|
13
|
+
* - Server-side only (no DOM libs)
|
|
14
|
+
* - Decorator metadata emission for DI container
|
|
15
|
+
* - Source maps for debugging in production
|
|
16
|
+
* - Compiled output with incremental builds
|
|
17
|
+
* - Relaxed settings for NestJS-specific patterns
|
|
18
|
+
*
|
|
19
|
+
* ═══════════════════════════════════════════════════════════════════════════════════ */
|
|
20
|
+
|
|
21
|
+
"compilerOptions": {
|
|
22
|
+
/* ─── Runtime Environment ───────────────────────────────────────────────────── */
|
|
23
|
+
"lib": ["ESNext"], // Server-side only, no DOM
|
|
24
|
+
"target": "ESNext", // Modern Node.js supports latest features
|
|
25
|
+
|
|
26
|
+
/* ─── NestJS Decorator Support ──────────────────────────────────────────────── */
|
|
27
|
+
"emitDecoratorMetadata": true, // Required for NestJS dependency injection
|
|
28
|
+
"experimentalDecorators": true, // Enable decorator syntax
|
|
29
|
+
|
|
30
|
+
/* ─── Output Settings ───────────────────────────────────────────────────── */
|
|
31
|
+
"noEmit": false, // Emit compiled JavaScript
|
|
32
|
+
"declaration": false, // No .d.ts files needed for apps
|
|
33
|
+
"removeComments": true, // Smaller output bundles
|
|
34
|
+
"skipLibCheck": true, // Skip .d.ts checking for performance
|
|
35
|
+
"incremental": true, // Faster rebuilds
|
|
36
|
+
"tsBuildInfoFile": "./.cache/tsconfig.tsbuildinfo", // Keep build artifacts out of root
|
|
37
|
+
|
|
38
|
+
/* ─── Source Maps for Debugging ─────────────────────────────────────────────── */
|
|
39
|
+
"sourceMap": true, // Enable source maps
|
|
40
|
+
"inlineSources": true, // Include sources in source maps
|
|
41
|
+
|
|
42
|
+
/* ─── Relaxed Checks for NestJS Patterns ────────────────────────────── */
|
|
43
|
+
// NestJS decorators and DI patterns require these relaxations
|
|
44
|
+
"strictBindCallApply": false,
|
|
45
|
+
"noPropertyAccessFromIndexSignature": false
|
|
46
|
+
}
|
|
47
|
+
}
|
package/nextjs.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"display": "Next.js Configuration",
|
|
4
|
+
"extends": "./base.json",
|
|
5
|
+
|
|
6
|
+
/* ═══════════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
* @sicoti/tsconfig - Next.js Preset
|
|
8
|
+
* ═══════════════════════════════════════════════════════════════════════════════════
|
|
9
|
+
*
|
|
10
|
+
* Optimized for Next.js applications (App Router & Pages Router).
|
|
11
|
+
*
|
|
12
|
+
* Key characteristics:
|
|
13
|
+
* - Browser + Server rendering (DOM + ESNext libs)
|
|
14
|
+
* - JSX preserved for Next.js compiler (SWC/Turbopack)
|
|
15
|
+
* - No emit (Next.js handles all compilation)
|
|
16
|
+
* - Next.js language service plugin for enhanced DX
|
|
17
|
+
* - Incremental type checking for faster builds
|
|
18
|
+
*
|
|
19
|
+
* ═══════════════════════════════════════════════════════════════════════════════════ */
|
|
20
|
+
|
|
21
|
+
"compilerOptions": {
|
|
22
|
+
/* ─── Runtime Environment ───────────────────────────────────────────────────── */
|
|
23
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"], // Browser APIs + Modern JavaScript
|
|
24
|
+
"target": "ES2017", // Compatibility target for older browsers
|
|
25
|
+
|
|
26
|
+
/* ─── JSX Handling ──────────────────────────────────────────────────────────── */
|
|
27
|
+
"jsx": "preserve", // Let Next.js/SWC handle JSX transformation
|
|
28
|
+
"allowJs": true, // Allow JavaScript files in the project
|
|
29
|
+
|
|
30
|
+
/* ─── Output Settings ───────────────────────────────────────────────────── */
|
|
31
|
+
"noEmit": true, // Next.js handles all compilation
|
|
32
|
+
"skipLibCheck": true, // Skip .d.ts checking for performance
|
|
33
|
+
"incremental": true, // Enable incremental type checking
|
|
34
|
+
"tsBuildInfoFile": "./.cache/tsconfig.tsbuildinfo", // Keep build artifacts out of root
|
|
35
|
+
|
|
36
|
+
/* ─── Next.js Plugin ────────────────────────────────────────────────────────── */
|
|
37
|
+
"plugins": [
|
|
38
|
+
{
|
|
39
|
+
"name": "next" // Enhanced autocomplete & type checking
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
/* ─── Relaxed Checks for Next.js Patterns ────────────────────────────── */
|
|
44
|
+
// Allow dot notation for dynamic route params and config objects
|
|
45
|
+
"noPropertyAccessFromIndexSignature": false
|
|
46
|
+
}
|
|
47
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://www.schemastore.org/package.json",
|
|
3
|
+
"name": "@sicoti/tsconfig",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Centralized, shareable TypeScript configuration presets for monorepos and multi-project setups — provides consistent, battle-tested tsconfig bases (Base, Next.js, React libraries, Bun, NestJS) to reduce duplication, enforce best practices, and simplify upgrades.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "SICOTI Team <dev@sicoti.org>",
|
|
8
|
+
"contributors": [
|
|
9
|
+
{
|
|
10
|
+
"name": "Yuzu02",
|
|
11
|
+
"url": "https://github.com/Yuzu02"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/SICOTI-Peru/tsconfig#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/SICOTI-Peru/tsconfig.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/SICOTI-Peru/tsconfig/issues",
|
|
22
|
+
"email": "dev@sicoti.org"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.0.0",
|
|
26
|
+
"bun": ">=1.3.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"typescript": ">=5.9.0 <6"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"typescript",
|
|
33
|
+
"tsconfig",
|
|
34
|
+
"configs",
|
|
35
|
+
"sicoti",
|
|
36
|
+
"monorepo",
|
|
37
|
+
"shareable-config"
|
|
38
|
+
],
|
|
39
|
+
"files": [
|
|
40
|
+
"base.json",
|
|
41
|
+
"nextjs.json",
|
|
42
|
+
"react-library.json",
|
|
43
|
+
"bun.json",
|
|
44
|
+
"nestjs.json",
|
|
45
|
+
"CHANGELOG.md",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"exports": {
|
|
50
|
+
"./base.json": "./base.json",
|
|
51
|
+
"./nextjs.json": "./nextjs.json",
|
|
52
|
+
"./react-library.json": "./react-library.json",
|
|
53
|
+
"./bun.json": "./bun.json",
|
|
54
|
+
"./nestjs.json": "./nestjs.json"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"pack": "bun pm pack",
|
|
61
|
+
"publish:dry": "bun publish --dry-run",
|
|
62
|
+
"publish": "bun publish --access public",
|
|
63
|
+
"release": "bun run pack && bun publish --access public"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"display": "React Library Configuration",
|
|
4
|
+
"extends": "./base.json",
|
|
5
|
+
|
|
6
|
+
/* ═══════════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
* @sicoti/tsconfig - React Library Preset
|
|
8
|
+
* ═══════════════════════════════════════════════════════════════════════════════════
|
|
9
|
+
*
|
|
10
|
+
* Optimized for React component libraries consumed by other applications.
|
|
11
|
+
*
|
|
12
|
+
* Key characteristics:
|
|
13
|
+
* - Browser APIs (DOM libs) for component development
|
|
14
|
+
* - React 17+ JSX runtime (automatic import)
|
|
15
|
+
* - Declaration files & source maps for consumers
|
|
16
|
+
* - Relaxed unused checks for flexible component exports
|
|
17
|
+
*
|
|
18
|
+
* ═══════════════════════════════════════════════════════════════════════════════════ */
|
|
19
|
+
|
|
20
|
+
"compilerOptions": {
|
|
21
|
+
/* ─── Runtime Environment ───────────────────────────────────────────────────── */
|
|
22
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"], // Browser APIs + Modern JavaScript
|
|
23
|
+
"target": "ESNext", // Modern bundlers handle transpilation
|
|
24
|
+
|
|
25
|
+
/* ─── JSX Handling ──────────────────────────────────────────────────────────── */
|
|
26
|
+
"jsx": "react-jsx", // New React 17+ JSX transform
|
|
27
|
+
|
|
28
|
+
/* ─── Output Settings ───────────────────────────────────────────────────── */
|
|
29
|
+
"noEmit": false, // Emit compiled output
|
|
30
|
+
"declaration": true, // Generate .d.ts for consumers
|
|
31
|
+
"declarationMap": true, // Source maps for declarations
|
|
32
|
+
"skipLibCheck": true, // Skip .d.ts checking for performance
|
|
33
|
+
"incremental": true, // Faster rebuilds
|
|
34
|
+
"tsBuildInfoFile": "./.cache/tsconfig.tsbuildinfo", // Keep build artifacts out of root
|
|
35
|
+
|
|
36
|
+
/* ─── Relaxed Checks for Component Libraries ────────────────────────── */
|
|
37
|
+
// Libraries may export components that appear unused locally
|
|
38
|
+
"noUnusedLocals": false,
|
|
39
|
+
"noUnusedParameters": false,
|
|
40
|
+
"noPropertyAccessFromIndexSignature": false
|
|
41
|
+
}
|
|
42
|
+
}
|