@sklv-labs/ts-dev-configs 0.1.1 → 0.1.2
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/README.md +96 -5
- package/package.json +28 -4
- package/presets/base/tsconfig.json +1 -5
- package/presets/nestjs/eslint.config.mjs +11 -7
- package/presets/nestjs/jest.config.js +9 -0
- package/presets/nestjs/tsconfig.json +1 -9
- package/presets/nestjs/tsconfig.spec.json +16 -0
- package/presets/react/tsconfig.json +10 -5
- package/configs/build/index.js +0 -6
- package/configs/build/vite.base.ts +0 -35
- package/configs/build/webpack.base.js +0 -27
- package/configs/git/husky/commit-msg +0 -4
- package/configs/git/husky/pre-commit +0 -4
package/README.md
CHANGED
|
@@ -32,8 +32,8 @@ npm install --save-dev @eslint/js typescript-eslint globals eslint-config-pretti
|
|
|
32
32
|
# For React preset
|
|
33
33
|
npm install --save-dev eslint-plugin-react eslint-plugin-react-hooks @vitejs/plugin-react
|
|
34
34
|
|
|
35
|
-
# For NestJS preset
|
|
36
|
-
npm install --save-dev @
|
|
35
|
+
# For NestJS preset (optional but recommended)
|
|
36
|
+
npm install --save-dev @darraghor/eslint-plugin-nestjs-typed
|
|
37
37
|
|
|
38
38
|
# For testing
|
|
39
39
|
npm install --save-dev jest@^29.7.0 ts-jest@^29.2.0 @types/jest
|
|
@@ -61,10 +61,14 @@ The base preset includes configurations for TypeScript, ESLint, Prettier, Jest,
|
|
|
61
61
|
"compilerOptions": {
|
|
62
62
|
"outDir": "./dist",
|
|
63
63
|
"rootDir": "./src"
|
|
64
|
-
}
|
|
64
|
+
},
|
|
65
|
+
"include": ["src/**/*"],
|
|
66
|
+
"exclude": ["node_modules", "dist"]
|
|
65
67
|
}
|
|
66
68
|
```
|
|
67
69
|
|
|
70
|
+
**Note:** Preset configs only define `compilerOptions`. You must define `include` and `exclude` in your project's `tsconfig.json`.
|
|
71
|
+
|
|
68
72
|
#### ESLint Config (Flat Config - ESLint 9)
|
|
69
73
|
|
|
70
74
|
```js
|
|
@@ -131,10 +135,14 @@ The React preset extends the base preset with React-specific configurations.
|
|
|
131
135
|
"compilerOptions": {
|
|
132
136
|
"outDir": "./dist",
|
|
133
137
|
"rootDir": "./src"
|
|
134
|
-
}
|
|
138
|
+
},
|
|
139
|
+
"include": ["src/**/*", "**/*.ts", "**/*.tsx"],
|
|
140
|
+
"exclude": ["node_modules", "dist", "build"]
|
|
135
141
|
}
|
|
136
142
|
```
|
|
137
143
|
|
|
144
|
+
**Note:** Preset configs only define `compilerOptions`. You must define `include` and `exclude` in your project's `tsconfig.json`.
|
|
145
|
+
|
|
138
146
|
#### ESLint Config (Flat Config - ESLint 9)
|
|
139
147
|
|
|
140
148
|
```js
|
|
@@ -170,10 +178,14 @@ The NestJS preset extends the base preset with NestJS-specific configurations.
|
|
|
170
178
|
"compilerOptions": {
|
|
171
179
|
"outDir": "./dist",
|
|
172
180
|
"rootDir": "./src"
|
|
173
|
-
}
|
|
181
|
+
},
|
|
182
|
+
"include": ["src/**/*"],
|
|
183
|
+
"exclude": ["node_modules", "dist", "test"]
|
|
174
184
|
}
|
|
175
185
|
```
|
|
176
186
|
|
|
187
|
+
**Note:** Preset configs only define `compilerOptions`. You must define `include` and `exclude` in your project's `tsconfig.json`.
|
|
188
|
+
|
|
177
189
|
#### ESLint Config (Flat Config - ESLint 9)
|
|
178
190
|
|
|
179
191
|
```js
|
|
@@ -190,6 +202,22 @@ export default nestjsEslint;
|
|
|
190
202
|
module.exports = require('@sklv-labs/ts-dev-configs/presets/nestjs/jest.config.js');
|
|
191
203
|
```
|
|
192
204
|
|
|
205
|
+
#### TypeScript Config for Tests
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
// tsconfig.spec.json
|
|
209
|
+
{
|
|
210
|
+
"extends": "@sklv-labs/ts-dev-configs/presets/nestjs/tsconfig.spec.json",
|
|
211
|
+
"compilerOptions": {
|
|
212
|
+
"rootDir": "./src"
|
|
213
|
+
},
|
|
214
|
+
"include": [
|
|
215
|
+
"src/**/*.spec.ts",
|
|
216
|
+
"src/**/*.test.ts"
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
193
221
|
## Additional Configs
|
|
194
222
|
|
|
195
223
|
### Git Hooks
|
|
@@ -326,6 +354,69 @@ const viteBasePath = configs.build.vite;
|
|
|
326
354
|
└── index.ts # Main exports
|
|
327
355
|
```
|
|
328
356
|
|
|
357
|
+
## Local Development with Yalc
|
|
358
|
+
|
|
359
|
+
For local development and testing, this package uses [yalc](https://github.com/wclr/yalc) to link the package locally without publishing to npm.
|
|
360
|
+
|
|
361
|
+
### Setup
|
|
362
|
+
|
|
363
|
+
1. **In the `ts-dev-configs` package directory:**
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
cd ts-dev-configs
|
|
367
|
+
npm install
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
2. **Publish to yalc local repository:**
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
npm run yalc:publish
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Or force update if already published:
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
npm run yalc:publish:force
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
3. **In your consuming project (e.g., `ts-nestjs-openapi`):**
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
cd ../ts-nestjs-openapi
|
|
386
|
+
npm run yalc:link
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
This will replace the npm version with the local yalc version.
|
|
390
|
+
|
|
391
|
+
4. **Update when you make changes:**
|
|
392
|
+
|
|
393
|
+
In `ts-dev-configs`:
|
|
394
|
+
```bash
|
|
395
|
+
npm run yalc:publish
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
In the consuming project:
|
|
399
|
+
```bash
|
|
400
|
+
npm run yalc:update
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
5. **Remove yalc link and restore npm version:**
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
npm run yalc:remove
|
|
407
|
+
npm install
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Workflow
|
|
411
|
+
|
|
412
|
+
1. Make changes to `ts-dev-configs`
|
|
413
|
+
2. Run `npm run yalc:publish` in `ts-dev-configs`
|
|
414
|
+
3. Run `npm run yalc:update` in consuming projects
|
|
415
|
+
4. Test your changes
|
|
416
|
+
5. Repeat as needed
|
|
417
|
+
|
|
418
|
+
**Note:** After using yalc, remember to remove the link before committing changes to ensure the package.json doesn't reference the local yalc version.
|
|
419
|
+
|
|
329
420
|
## Contributing
|
|
330
421
|
|
|
331
422
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sklv-labs/ts-dev-configs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Unified development configurations for TypeScript projects with support for React, NestJS, and more",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -29,11 +29,24 @@
|
|
|
29
29
|
"./presets/base": "./presets/base/index.js",
|
|
30
30
|
"./presets/react": "./presets/react/index.js",
|
|
31
31
|
"./presets/nestjs": "./presets/nestjs/index.js",
|
|
32
|
+
"./presets/base/tsconfig.json": "./presets/base/tsconfig.json",
|
|
33
|
+
"./presets/react/tsconfig.json": "./presets/react/tsconfig.json",
|
|
34
|
+
"./presets/nestjs/tsconfig.json": "./presets/nestjs/tsconfig.json",
|
|
35
|
+
"./presets/nestjs/tsconfig.spec.json": "./presets/nestjs/tsconfig.spec.json",
|
|
36
|
+
"./presets/base/prettier.js": "./presets/base/prettier.js",
|
|
37
|
+
"./presets/base/jest.config.js": "./presets/base/jest.config.js",
|
|
38
|
+
"./presets/nestjs/jest.config.js": "./presets/nestjs/jest.config.js",
|
|
39
|
+
"./presets/base/vitest.config.ts": "./presets/base/vitest.config.ts",
|
|
40
|
+
"./presets/react/vite.config.ts": "./presets/react/vite.config.ts",
|
|
32
41
|
"./eslint/base": "./presets/base/eslint.config.mjs",
|
|
33
42
|
"./eslint/react": "./presets/react/eslint.config.mjs",
|
|
34
43
|
"./eslint/nestjs": "./presets/nestjs/eslint.config.mjs",
|
|
35
44
|
"./configs/git": "./configs/git/index.js",
|
|
45
|
+
"./configs/git/commitlint.js": "./configs/git/commitlint.js",
|
|
46
|
+
"./configs/git/lint-staged.js": "./configs/git/lint-staged.js",
|
|
36
47
|
"./configs/build": "./configs/build/index.js",
|
|
48
|
+
"./configs/build/vite.base.ts": "./configs/build/vite.base.ts",
|
|
49
|
+
"./configs/build/webpack.base.js": "./configs/build/webpack.base.js",
|
|
37
50
|
"./configs/editor": "./configs/editor/index.js"
|
|
38
51
|
},
|
|
39
52
|
"files": [
|
|
@@ -46,7 +59,9 @@
|
|
|
46
59
|
"peerDependencies": {
|
|
47
60
|
"typescript": "^5.9.0",
|
|
48
61
|
"eslint": "^9.0.0",
|
|
49
|
-
"prettier": "^3.6.0"
|
|
62
|
+
"prettier": "^3.6.0",
|
|
63
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
64
|
+
"@darraghor/eslint-plugin-nestjs-typed": "^7.0.0"
|
|
50
65
|
},
|
|
51
66
|
"peerDependenciesMeta": {
|
|
52
67
|
"typescript": {
|
|
@@ -57,19 +72,28 @@
|
|
|
57
72
|
},
|
|
58
73
|
"prettier": {
|
|
59
74
|
"optional": false
|
|
75
|
+
},
|
|
76
|
+
"eslint-plugin-prettier": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"@darraghor/eslint-plugin-nestjs-typed": {
|
|
80
|
+
"optional": true
|
|
60
81
|
}
|
|
61
82
|
},
|
|
62
83
|
"devDependencies": {
|
|
63
84
|
"@types/node": "^24.0.0",
|
|
64
85
|
"typescript": "^5.9.2",
|
|
65
|
-
"vitest": "^4.0.7"
|
|
86
|
+
"vitest": "^4.0.7",
|
|
87
|
+
"yalc": "^1.0.0-pre.53"
|
|
66
88
|
},
|
|
67
89
|
"scripts": {
|
|
68
90
|
"type-check": "tsc --noEmit",
|
|
69
91
|
"prepublishOnly": "npm run type-check",
|
|
70
92
|
"version:patch": "npm version patch && git push --follow-tags",
|
|
71
93
|
"version:minor": "npm version minor && git push --follow-tags",
|
|
72
|
-
"version:major": "npm version major && git push --follow-tags"
|
|
94
|
+
"version:major": "npm version major && git push --follow-tags",
|
|
95
|
+
"yalc:publish": "yalc push",
|
|
96
|
+
"yalc:publish:force": "yalc push --force"
|
|
73
97
|
},
|
|
74
98
|
"engines": {
|
|
75
99
|
"node": ">=24.0.0"
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import eslint from '@eslint/js';
|
|
2
2
|
import { defineConfig } from 'eslint/config';
|
|
3
3
|
import tseslint from 'typescript-eslint';
|
|
4
|
-
import nestjsPlugin from '@nestjs/eslint-plugin-nestjs';
|
|
5
4
|
import importPlugin from 'eslint-plugin-import-x';
|
|
6
5
|
import globals from 'globals';
|
|
7
6
|
import prettier from 'eslint-config-prettier';
|
|
7
|
+
import prettierPlugin from 'eslint-plugin-prettier';
|
|
8
|
+
|
|
9
|
+
import eslintNestJs from '@darraghor/eslint-plugin-nestjs-typed';
|
|
8
10
|
|
|
9
11
|
export default defineConfig([
|
|
10
12
|
// Base recommended configs
|
|
@@ -12,6 +14,9 @@ export default defineConfig([
|
|
|
12
14
|
...tseslint.configs.recommended,
|
|
13
15
|
...tseslint.configs.recommendedTypeChecked,
|
|
14
16
|
|
|
17
|
+
// NestJS Typed plugin recommended rules
|
|
18
|
+
...eslintNestJs.configs.flatRecommended,
|
|
19
|
+
|
|
15
20
|
// Global ignores
|
|
16
21
|
{
|
|
17
22
|
ignores: ['dist/**', 'build/**', 'node_modules/**', '*.config.js', '*.config.ts', '*.config.mjs'],
|
|
@@ -35,8 +40,8 @@ export default defineConfig([
|
|
|
35
40
|
},
|
|
36
41
|
plugins: {
|
|
37
42
|
'@typescript-eslint': tseslint.plugin,
|
|
38
|
-
'@nestjs': nestjsPlugin,
|
|
39
43
|
'import-x': importPlugin,
|
|
44
|
+
prettier: prettierPlugin,
|
|
40
45
|
},
|
|
41
46
|
rules: {
|
|
42
47
|
// TypeScript specific rules
|
|
@@ -50,14 +55,10 @@ export default defineConfig([
|
|
|
50
55
|
varsIgnorePattern: '^_',
|
|
51
56
|
},
|
|
52
57
|
],
|
|
53
|
-
'
|
|
58
|
+
'prefer-const': 'error',
|
|
54
59
|
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
55
60
|
'@typescript-eslint/interface-name-prefix': 'off',
|
|
56
61
|
|
|
57
|
-
// NestJS specific rules
|
|
58
|
-
'@nestjs/use-validation-pipe': 'warn',
|
|
59
|
-
'@nestjs/use-pipes-decorator': 'warn',
|
|
60
|
-
|
|
61
62
|
// General best practices
|
|
62
63
|
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
63
64
|
'no-debugger': 'error',
|
|
@@ -90,6 +91,9 @@ export default defineConfig([
|
|
|
90
91
|
],
|
|
91
92
|
'import-x/no-duplicates': 'error',
|
|
92
93
|
'import-x/no-unresolved': 'off', // TypeScript handles this
|
|
94
|
+
|
|
95
|
+
// Prettier rules
|
|
96
|
+
'prettier/prettier': 'error',
|
|
93
97
|
},
|
|
94
98
|
},
|
|
95
99
|
|
|
@@ -2,10 +2,19 @@ const baseJest = require('../base/jest.config.js');
|
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
...baseJest,
|
|
5
|
+
roots: ['<rootDir>/src'],
|
|
5
6
|
moduleNameMapper: {
|
|
6
7
|
'^src/(.*)$': '<rootDir>/src/$1',
|
|
7
8
|
},
|
|
8
9
|
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
|
|
10
|
+
transform: {
|
|
11
|
+
'^.+\\.ts$': [
|
|
12
|
+
'ts-jest',
|
|
13
|
+
{
|
|
14
|
+
tsconfig: 'tsconfig.spec.json',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
9
18
|
collectCoverageFrom: [
|
|
10
19
|
'src/**/*.ts',
|
|
11
20
|
'!src/**/*.d.ts',
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"types": [
|
|
6
|
+
"jest",
|
|
7
|
+
"node"
|
|
8
|
+
],
|
|
9
|
+
"noEmit": true
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"**/*.spec.ts",
|
|
13
|
+
"**/*.test.ts"
|
|
14
|
+
],
|
|
15
|
+
"exclude": []
|
|
16
|
+
}
|
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
"extends": "../base/tsconfig.json",
|
|
4
4
|
"compilerOptions": {
|
|
5
5
|
"jsx": "react-jsx",
|
|
6
|
-
"lib": [
|
|
6
|
+
"lib": [
|
|
7
|
+
"ES2024",
|
|
8
|
+
"DOM",
|
|
9
|
+
"DOM.Iterable"
|
|
10
|
+
],
|
|
7
11
|
"module": "ESNext",
|
|
8
12
|
"moduleResolution": "bundler",
|
|
9
|
-
"types": [
|
|
13
|
+
"types": [
|
|
14
|
+
"vite/client"
|
|
15
|
+
],
|
|
10
16
|
"rootDir": "./"
|
|
11
17
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
}
|
|
18
|
+
"files": []
|
|
19
|
+
}
|
package/configs/build/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck - Template file for consuming projects, peer dependencies not installed here
|
|
2
|
-
import { defineConfig } from 'vite';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
resolve: {
|
|
10
|
-
alias: {
|
|
11
|
-
'@': path.resolve(__dirname, '../../src'),
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
build: {
|
|
15
|
-
outDir: 'dist',
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
minify: 'esbuild',
|
|
18
|
-
target: 'esnext',
|
|
19
|
-
rollupOptions: {
|
|
20
|
-
output: {
|
|
21
|
-
manualChunks: undefined,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
server: {
|
|
26
|
-
port: 3000,
|
|
27
|
-
open: false,
|
|
28
|
-
cors: true,
|
|
29
|
-
strictPort: false,
|
|
30
|
-
},
|
|
31
|
-
preview: {
|
|
32
|
-
port: 3000,
|
|
33
|
-
strictPort: false,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
entry: './src/index.ts',
|
|
5
|
-
output: {
|
|
6
|
-
path: path.resolve(__dirname, '../../dist'),
|
|
7
|
-
filename: 'bundle.js',
|
|
8
|
-
clean: true,
|
|
9
|
-
},
|
|
10
|
-
resolve: {
|
|
11
|
-
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
12
|
-
alias: {
|
|
13
|
-
'@': path.resolve(__dirname, '../../src'),
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
module: {
|
|
17
|
-
rules: [
|
|
18
|
-
{
|
|
19
|
-
test: /\.tsx?$/,
|
|
20
|
-
use: 'ts-loader',
|
|
21
|
-
exclude: /node_modules/,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
devtool: 'source-map',
|
|
26
|
-
mode: process.env.NODE_ENV || 'development',
|
|
27
|
-
};
|