@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 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 @nestjs/eslint-plugin-nestjs
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.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"
@@ -26,9 +26,5 @@
26
26
  "isolatedModules": true,
27
27
  "allowSyntheticDefaultImports": true
28
28
  },
29
- "exclude": [
30
- "node_modules",
31
- "dist",
32
- "build"
33
- ]
29
+ "files": []
34
30
  }
@@ -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
- '@typescript-eslint/prefer-const': 'error',
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',
@@ -24,13 +24,5 @@
24
24
  "forceConsistentCasingInFileNames": true,
25
25
  "noFallthroughCasesInSwitch": true
26
26
  },
27
- "include": [
28
- "src/**/*"
29
- ],
30
- "exclude": [
31
- "node_modules",
32
- "dist",
33
- "test",
34
- "**/*spec.ts"
35
- ]
27
+ "files": []
36
28
  }
@@ -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": ["ES2024", "DOM", "DOM.Iterable"],
6
+ "lib": [
7
+ "ES2024",
8
+ "DOM",
9
+ "DOM.Iterable"
10
+ ],
7
11
  "module": "ESNext",
8
12
  "moduleResolution": "bundler",
9
- "types": ["vite/client"],
13
+ "types": [
14
+ "vite/client"
15
+ ],
10
16
  "rootDir": "./"
11
17
  },
12
- "include": ["src/**/*", "**/*.ts", "**/*.tsx"],
13
- "exclude": ["node_modules", "dist", "build"]
14
- }
18
+ "files": []
19
+ }
@@ -1,6 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
- vite: path.resolve(__dirname, 'vite.base.ts'),
5
- webpack: path.resolve(__dirname, 'webpack.base.js'),
6
- };
@@ -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
- };
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npx --no -- commitlint --edit ${1}
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npx lint-staged