@sklv-labs/ts-dev-configs 0.1.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/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +335 -0
- package/configs/build/index.js +6 -0
- package/configs/build/vite.base.ts +35 -0
- package/configs/build/webpack.base.js +27 -0
- package/configs/editor/.editorconfig +35 -0
- package/configs/editor/index.js +9 -0
- package/configs/editor/vscode/extensions.json +7 -0
- package/configs/editor/vscode/settings.json +36 -0
- package/configs/git/commitlint.js +28 -0
- package/configs/git/husky/commit-msg +4 -0
- package/configs/git/husky/pre-commit +4 -0
- package/configs/git/index.js +10 -0
- package/configs/git/lint-staged.js +9 -0
- package/package.json +74 -0
- package/presets/base/eslint.config.mjs +91 -0
- package/presets/base/index.js +9 -0
- package/presets/base/jest.config.js +33 -0
- package/presets/base/prettier.js +12 -0
- package/presets/base/tsconfig.json +34 -0
- package/presets/base/vitest.config.ts +48 -0
- package/presets/nestjs/eslint.config.mjs +98 -0
- package/presets/nestjs/index.js +9 -0
- package/presets/nestjs/jest.config.js +24 -0
- package/presets/nestjs/tsconfig.json +36 -0
- package/presets/react/eslint.config.mjs +111 -0
- package/presets/react/index.js +10 -0
- package/presets/react/tsconfig.json +14 -0
- package/presets/react/vite.config.ts +38 -0
- package/src/index.ts +60 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-01-XX
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release of @sklv-labs/ts-dev-configs
|
|
13
|
+
- Base preset with ESLint 9 (flat config), Prettier 3.6, TypeScript 5.9, Jest 29, and Vitest 4 configurations
|
|
14
|
+
- React preset extending base with React-specific configurations
|
|
15
|
+
- NestJS preset extending base with NestJS-specific configurations
|
|
16
|
+
- Git configs: lint-staged, commitlint, and husky hooks
|
|
17
|
+
- Build tool configs: Vite 7 and Webpack base configurations
|
|
18
|
+
- Editor configs: .editorconfig and VS Code settings
|
|
19
|
+
- Main TypeScript exports with type definitions
|
|
20
|
+
- Comprehensive documentation and usage examples
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
- **ESLint 9 Flat Config**: All ESLint configs use the modern flat config format (eslint.config.mjs)
|
|
25
|
+
- **Node.js 24 LTS**: Optimized for Node.js 24 with ES2024 target and nodenext module resolution
|
|
26
|
+
- **Latest Tooling**: All configs use the latest stable versions of development tools
|
|
27
|
+
- **TypeScript 5.9**: Latest TypeScript features and compiler options
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sklv-labs
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# @sklv-labs/ts-dev-configs
|
|
2
|
+
|
|
3
|
+
Unified development configurations for TypeScript projects with support for React, NestJS, and more. This package provides a consistent set of ESLint, Prettier, TypeScript, Jest, Vitest, and other development tool configurations that can be easily extended and reused across projects.
|
|
4
|
+
|
|
5
|
+
**Latest versions:** Node.js 24 LTS, TypeScript 5.9+, ESLint 9 (flat config), Prettier 3.6+, Vitest 4+, Vite 7+
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🎯 **Preset-based architecture** - Choose from base, React, or NestJS presets
|
|
10
|
+
- 🔧 **Extensible configs** - All configs use the `extends` pattern for easy customization
|
|
11
|
+
- 📦 **Zero dependencies** - Uses peer dependencies to avoid version conflicts
|
|
12
|
+
- 🚀 **Framework support** - Optimized configs for React and NestJS
|
|
13
|
+
- 🛠️ **Additional tooling** - Includes git hooks, build tools, and editor configs
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev @sklv-labs/ts-dev-configs
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Peer Dependencies
|
|
22
|
+
|
|
23
|
+
This package requires the following peer dependencies. Install them based on your needs:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Required (latest versions)
|
|
27
|
+
npm install --save-dev typescript@^5.9.0 eslint@^9.0.0 prettier@^3.6.0
|
|
28
|
+
|
|
29
|
+
# For ESLint flat config (ESLint 9)
|
|
30
|
+
npm install --save-dev @eslint/js typescript-eslint globals eslint-config-prettier eslint-plugin-import-x
|
|
31
|
+
|
|
32
|
+
# For React preset
|
|
33
|
+
npm install --save-dev eslint-plugin-react eslint-plugin-react-hooks @vitejs/plugin-react
|
|
34
|
+
|
|
35
|
+
# For NestJS preset
|
|
36
|
+
npm install --save-dev @nestjs/eslint-plugin-nestjs
|
|
37
|
+
|
|
38
|
+
# For testing
|
|
39
|
+
npm install --save-dev jest@^29.7.0 ts-jest@^29.2.0 @types/jest
|
|
40
|
+
# or
|
|
41
|
+
npm install --save-dev vitest@^4.0.0 @vitest/ui
|
|
42
|
+
|
|
43
|
+
# For Vite (React preset)
|
|
44
|
+
npm install --save-dev vite@^7.0.0
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Note:** This package requires Node.js 24 LTS or higher.
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### Base Preset
|
|
52
|
+
|
|
53
|
+
The base preset includes configurations for TypeScript, ESLint, Prettier, Jest, and Vitest.
|
|
54
|
+
|
|
55
|
+
#### TypeScript Config
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
// tsconfig.json
|
|
59
|
+
{
|
|
60
|
+
"extends": "@sklv-labs/ts-dev-configs/presets/base/tsconfig.json",
|
|
61
|
+
"compilerOptions": {
|
|
62
|
+
"outDir": "./dist",
|
|
63
|
+
"rootDir": "./src"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### ESLint Config (Flat Config - ESLint 9)
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
// eslint.config.mjs
|
|
72
|
+
import baseEslint from '@sklv-labs/ts-dev-configs/eslint/base';
|
|
73
|
+
|
|
74
|
+
export default baseEslint;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or extend it:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
// eslint.config.mjs
|
|
81
|
+
import { defineConfig } from 'eslint/config';
|
|
82
|
+
import baseEslint from '@sklv-labs/ts-dev-configs/eslint/base';
|
|
83
|
+
|
|
84
|
+
export default defineConfig([
|
|
85
|
+
...baseEslint,
|
|
86
|
+
{
|
|
87
|
+
rules: {
|
|
88
|
+
// Your custom rules
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Prettier Config
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
// .prettierrc.js
|
|
98
|
+
module.exports = require('@sklv-labs/ts-dev-configs/presets/base/prettier.js');
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Jest Config
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
// jest.config.js
|
|
105
|
+
module.exports = require('@sklv-labs/ts-dev-configs/presets/base/jest.config.js');
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Vitest Config
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// vitest.config.ts
|
|
112
|
+
import { defineConfig } from 'vitest/config';
|
|
113
|
+
import baseVitest from '@sklv-labs/ts-dev-configs/presets/base/vitest.config.ts';
|
|
114
|
+
|
|
115
|
+
export default defineConfig({
|
|
116
|
+
...baseVitest,
|
|
117
|
+
// Your custom config
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### React Preset
|
|
122
|
+
|
|
123
|
+
The React preset extends the base preset with React-specific configurations.
|
|
124
|
+
|
|
125
|
+
#### TypeScript Config
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
// tsconfig.json
|
|
129
|
+
{
|
|
130
|
+
"extends": "@sklv-labs/ts-dev-configs/presets/react/tsconfig.json",
|
|
131
|
+
"compilerOptions": {
|
|
132
|
+
"outDir": "./dist",
|
|
133
|
+
"rootDir": "./src"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### ESLint Config (Flat Config - ESLint 9)
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
// eslint.config.mjs
|
|
142
|
+
import reactEslint from '@sklv-labs/ts-dev-configs/eslint/react';
|
|
143
|
+
|
|
144
|
+
export default reactEslint;
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Vite Config
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// vite.config.ts
|
|
151
|
+
import { defineConfig } from 'vite';
|
|
152
|
+
import reactVite from '@sklv-labs/ts-dev-configs/presets/react/vite.config.ts';
|
|
153
|
+
|
|
154
|
+
export default defineConfig({
|
|
155
|
+
...reactVite,
|
|
156
|
+
// Your custom config
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### NestJS Preset
|
|
161
|
+
|
|
162
|
+
The NestJS preset extends the base preset with NestJS-specific configurations.
|
|
163
|
+
|
|
164
|
+
#### TypeScript Config
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
// tsconfig.json
|
|
168
|
+
{
|
|
169
|
+
"extends": "@sklv-labs/ts-dev-configs/presets/nestjs/tsconfig.json",
|
|
170
|
+
"compilerOptions": {
|
|
171
|
+
"outDir": "./dist",
|
|
172
|
+
"rootDir": "./src"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### ESLint Config (Flat Config - ESLint 9)
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
// eslint.config.mjs
|
|
181
|
+
import nestjsEslint from '@sklv-labs/ts-dev-configs/eslint/nestjs';
|
|
182
|
+
|
|
183
|
+
export default nestjsEslint;
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### Jest Config
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
// jest.config.js
|
|
190
|
+
module.exports = require('@sklv-labs/ts-dev-configs/presets/nestjs/jest.config.js');
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Additional Configs
|
|
194
|
+
|
|
195
|
+
### Git Hooks
|
|
196
|
+
|
|
197
|
+
#### Lint-Staged
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
// .lintstagedrc.js
|
|
201
|
+
module.exports = require('@sklv-labs/ts-dev-configs/configs/git/lint-staged.js');
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Commitlint
|
|
205
|
+
|
|
206
|
+
```js
|
|
207
|
+
// commitlint.config.js
|
|
208
|
+
module.exports = require('@sklv-labs/ts-dev-configs/configs/git/commitlint.js');
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### Husky Hooks
|
|
212
|
+
|
|
213
|
+
Copy the husky hooks from `@sklv-labs/ts-dev-configs/configs/git/husky/` to your `.husky/` directory.
|
|
214
|
+
|
|
215
|
+
### Build Tools
|
|
216
|
+
|
|
217
|
+
#### Vite Base Config
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
// vite.config.ts
|
|
221
|
+
import { defineConfig } from 'vite';
|
|
222
|
+
import viteBase from '@sklv-labs/ts-dev-configs/configs/build/vite.base';
|
|
223
|
+
|
|
224
|
+
export default defineConfig({
|
|
225
|
+
...viteBase,
|
|
226
|
+
// Your custom config
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### Webpack Base Config
|
|
231
|
+
|
|
232
|
+
```js
|
|
233
|
+
// webpack.config.js
|
|
234
|
+
const webpackBase = require('@sklv-labs/ts-dev-configs/configs/build/webpack.base');
|
|
235
|
+
|
|
236
|
+
module.exports = {
|
|
237
|
+
...webpackBase,
|
|
238
|
+
// Your custom config
|
|
239
|
+
};
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Editor Configs
|
|
243
|
+
|
|
244
|
+
#### EditorConfig
|
|
245
|
+
|
|
246
|
+
Copy `.editorconfig` from `@sklv-labs/ts-dev-configs/configs/editor/.editorconfig` to your project root.
|
|
247
|
+
|
|
248
|
+
#### VS Code Settings
|
|
249
|
+
|
|
250
|
+
Copy the VS Code settings from `@sklv-labs/ts-dev-configs/configs/editor/vscode/` to your `.vscode/` directory.
|
|
251
|
+
|
|
252
|
+
## Extending Configs
|
|
253
|
+
|
|
254
|
+
All configs are designed to be extended. You can override specific rules or settings:
|
|
255
|
+
|
|
256
|
+
### Extending ESLint (Flat Config)
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
// eslint.config.mjs
|
|
260
|
+
import { defineConfig } from 'eslint/config';
|
|
261
|
+
import reactEslint from '@sklv-labs/ts-dev-configs/eslint/react';
|
|
262
|
+
|
|
263
|
+
export default defineConfig([
|
|
264
|
+
...reactEslint,
|
|
265
|
+
{
|
|
266
|
+
rules: {
|
|
267
|
+
// Override or add rules
|
|
268
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
]);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Extending TypeScript Config
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
// tsconfig.json
|
|
278
|
+
{
|
|
279
|
+
"extends": "@sklv-labs/ts-dev-configs/presets/react/tsconfig.json",
|
|
280
|
+
"compilerOptions": {
|
|
281
|
+
"strict": true,
|
|
282
|
+
"noUnusedLocals": true
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Extending Prettier
|
|
288
|
+
|
|
289
|
+
```js
|
|
290
|
+
// .prettierrc.js
|
|
291
|
+
module.exports = {
|
|
292
|
+
...require('@sklv-labs/ts-dev-configs/presets/base/prettier.js'),
|
|
293
|
+
printWidth: 120, // Override
|
|
294
|
+
};
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Programmatic Usage
|
|
298
|
+
|
|
299
|
+
You can also import configs programmatically:
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
import { presets, configs } from '@sklv-labs/ts-dev-configs';
|
|
303
|
+
|
|
304
|
+
// Access preset paths
|
|
305
|
+
const baseEslintPath = presets.base.eslint;
|
|
306
|
+
const reactTsconfigPath = presets.react.tsconfig;
|
|
307
|
+
|
|
308
|
+
// Access config paths
|
|
309
|
+
const lintStagedPath = configs.git.lintStaged;
|
|
310
|
+
const viteBasePath = configs.build.vite;
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Project Structure
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
@sklv-labs/ts-dev-configs/
|
|
317
|
+
├── presets/
|
|
318
|
+
│ ├── base/ # Base preset (ESLint, Prettier, TypeScript, Jest, Vitest)
|
|
319
|
+
│ ├── react/ # React preset (extends base + React-specific)
|
|
320
|
+
│ └── nestjs/ # NestJS preset (extends base + NestJS-specific)
|
|
321
|
+
├── configs/
|
|
322
|
+
│ ├── git/ # Git hooks (husky, lint-staged, commitlint)
|
|
323
|
+
│ ├── build/ # Build tools (Vite, Webpack)
|
|
324
|
+
│ └── editor/ # Editor configs (.editorconfig, VS Code)
|
|
325
|
+
└── src/
|
|
326
|
+
└── index.ts # Main exports
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Contributing
|
|
330
|
+
|
|
331
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT © [sklv-labs](https://github.com/sklv-labs)
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# EditorConfig is awesome: https://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
# Unix-style newlines with a newline ending every file
|
|
7
|
+
[*]
|
|
8
|
+
end_of_line = lf
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
charset = utf-8
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
|
|
13
|
+
# TypeScript and JavaScript files
|
|
14
|
+
[*.{ts,tsx,js,jsx}]
|
|
15
|
+
indent_style = space
|
|
16
|
+
indent_size = 2
|
|
17
|
+
|
|
18
|
+
# JSON files
|
|
19
|
+
[*.json]
|
|
20
|
+
indent_style = space
|
|
21
|
+
indent_size = 2
|
|
22
|
+
|
|
23
|
+
# YAML files
|
|
24
|
+
[*.{yml,yaml}]
|
|
25
|
+
indent_style = space
|
|
26
|
+
indent_size = 2
|
|
27
|
+
|
|
28
|
+
# Markdown files
|
|
29
|
+
[*.md]
|
|
30
|
+
trim_trailing_whitespace = false
|
|
31
|
+
|
|
32
|
+
# Package files
|
|
33
|
+
[{package.json,package-lock.json}]
|
|
34
|
+
indent_style = space
|
|
35
|
+
indent_size = 2
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": true,
|
|
3
|
+
"editor.defaultFormatter": "prettier.prettier-vscode",
|
|
4
|
+
"editor.codeActionsOnSave": {
|
|
5
|
+
"source.fixAll.eslint": "explicit"
|
|
6
|
+
},
|
|
7
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
8
|
+
"typescript.enablePromptUseWorkspaceTsdk": true,
|
|
9
|
+
"typescript.preferences.includePackageJsonAutoImports": "off",
|
|
10
|
+
"[typescript]": {
|
|
11
|
+
"editor.defaultFormatter": "prettier.prettier-vscode"
|
|
12
|
+
},
|
|
13
|
+
"[typescriptreact]": {
|
|
14
|
+
"editor.defaultFormatter": "prettier.prettier-vscode"
|
|
15
|
+
},
|
|
16
|
+
"[javascript]": {
|
|
17
|
+
"editor.defaultFormatter": "prettier.prettier-vscode"
|
|
18
|
+
},
|
|
19
|
+
"[javascriptreact]": {
|
|
20
|
+
"editor.defaultFormatter": "prettier.prettier-vscode"
|
|
21
|
+
},
|
|
22
|
+
"[json]": {
|
|
23
|
+
"editor.defaultFormatter": "prettier.prettier-vscode"
|
|
24
|
+
},
|
|
25
|
+
"[jsonc]": {
|
|
26
|
+
"editor.defaultFormatter": "prettier.prettier-vscode"
|
|
27
|
+
},
|
|
28
|
+
"files.eol": "\n",
|
|
29
|
+
"files.insertFinalNewline": true,
|
|
30
|
+
"files.trimTrailingWhitespace": true,
|
|
31
|
+
"files.exclude": {
|
|
32
|
+
"**/presets/**/tsconfig.json": false
|
|
33
|
+
},
|
|
34
|
+
"typescript.validate.enable": true,
|
|
35
|
+
"typescript.tsserver.experimental.enableProjectDiagnostics": false
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['@commitlint/config-conventional'],
|
|
3
|
+
rules: {
|
|
4
|
+
'type-enum': [
|
|
5
|
+
2,
|
|
6
|
+
'always',
|
|
7
|
+
[
|
|
8
|
+
'feat',
|
|
9
|
+
'fix',
|
|
10
|
+
'docs',
|
|
11
|
+
'style',
|
|
12
|
+
'refactor',
|
|
13
|
+
'perf',
|
|
14
|
+
'test',
|
|
15
|
+
'chore',
|
|
16
|
+
'revert',
|
|
17
|
+
'build',
|
|
18
|
+
'ci',
|
|
19
|
+
],
|
|
20
|
+
],
|
|
21
|
+
'type-case': [2, 'always', 'lower-case'],
|
|
22
|
+
'type-empty': [2, 'never'],
|
|
23
|
+
'scope-case': [2, 'always', 'lower-case'],
|
|
24
|
+
'subject-empty': [2, 'never'],
|
|
25
|
+
'subject-full-stop': [2, 'never', '.'],
|
|
26
|
+
'header-max-length': [2, 'always', 100],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
lintStaged: path.resolve(__dirname, 'lint-staged.js'),
|
|
5
|
+
commitlint: path.resolve(__dirname, 'commitlint.js'),
|
|
6
|
+
husky: {
|
|
7
|
+
preCommit: path.resolve(__dirname, 'husky/pre-commit'),
|
|
8
|
+
commitMsg: path.resolve(__dirname, 'husky/commit-msg'),
|
|
9
|
+
},
|
|
10
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sklv-labs/ts-dev-configs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unified development configurations for TypeScript projects with support for React, NestJS, and more",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript",
|
|
7
|
+
"eslint",
|
|
8
|
+
"prettier",
|
|
9
|
+
"jest",
|
|
10
|
+
"vitest",
|
|
11
|
+
"config",
|
|
12
|
+
"preset",
|
|
13
|
+
"react",
|
|
14
|
+
"nestjs"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "sklv-labs",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/sklv-labs/ts-dev-configs.git"
|
|
21
|
+
},
|
|
22
|
+
"main": "./src/index.ts",
|
|
23
|
+
"types": "./src/index.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./src/index.ts",
|
|
26
|
+
"./base": "./presets/base/index.js",
|
|
27
|
+
"./react": "./presets/react/index.js",
|
|
28
|
+
"./nestjs": "./presets/nestjs/index.js",
|
|
29
|
+
"./presets/base": "./presets/base/index.js",
|
|
30
|
+
"./presets/react": "./presets/react/index.js",
|
|
31
|
+
"./presets/nestjs": "./presets/nestjs/index.js",
|
|
32
|
+
"./eslint/base": "./presets/base/eslint.config.mjs",
|
|
33
|
+
"./eslint/react": "./presets/react/eslint.config.mjs",
|
|
34
|
+
"./eslint/nestjs": "./presets/nestjs/eslint.config.mjs",
|
|
35
|
+
"./configs/git": "./configs/git/index.js",
|
|
36
|
+
"./configs/build": "./configs/build/index.js",
|
|
37
|
+
"./configs/editor": "./configs/editor/index.js"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"src",
|
|
41
|
+
"presets",
|
|
42
|
+
"configs",
|
|
43
|
+
"README.md",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"typescript": "^5.9.0",
|
|
48
|
+
"eslint": "^9.0.0",
|
|
49
|
+
"prettier": "^3.6.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"typescript": {
|
|
53
|
+
"optional": false
|
|
54
|
+
},
|
|
55
|
+
"eslint": {
|
|
56
|
+
"optional": false
|
|
57
|
+
},
|
|
58
|
+
"prettier": {
|
|
59
|
+
"optional": false
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^24.0.0",
|
|
64
|
+
"typescript": "^5.9.2",
|
|
65
|
+
"vitest": "^4.0.7"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"type-check": "tsc --noEmit",
|
|
69
|
+
"prepublishOnly": "npm run type-check"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=24.0.0"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import importPlugin from 'eslint-plugin-import-x';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
import prettier from 'eslint-config-prettier';
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
// Base recommended configs
|
|
10
|
+
eslint.configs.recommended,
|
|
11
|
+
...tseslint.configs.recommended,
|
|
12
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
13
|
+
|
|
14
|
+
// Global ignores
|
|
15
|
+
{
|
|
16
|
+
ignores: ['dist/**', 'build/**', 'node_modules/**', '*.config.js', '*.config.ts', '*.config.mjs'],
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// TypeScript files configuration
|
|
20
|
+
{
|
|
21
|
+
files: ['**/*.{ts,tsx}'],
|
|
22
|
+
languageOptions: {
|
|
23
|
+
ecmaVersion: 2024,
|
|
24
|
+
sourceType: 'module',
|
|
25
|
+
globals: {
|
|
26
|
+
...globals.node,
|
|
27
|
+
...globals.es2024,
|
|
28
|
+
},
|
|
29
|
+
parser: tseslint.parser,
|
|
30
|
+
parserOptions: {
|
|
31
|
+
projectService: true,
|
|
32
|
+
tsconfigRootDir: import.meta.dirname,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
plugins: {
|
|
36
|
+
'@typescript-eslint': tseslint.plugin,
|
|
37
|
+
'import-x': importPlugin,
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
// TypeScript specific rules
|
|
41
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
42
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
43
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
44
|
+
'@typescript-eslint/no-unused-vars': [
|
|
45
|
+
'error',
|
|
46
|
+
{
|
|
47
|
+
argsIgnorePattern: '^_',
|
|
48
|
+
varsIgnorePattern: '^_',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
'@typescript-eslint/prefer-const': 'error',
|
|
52
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
53
|
+
|
|
54
|
+
// General best practices
|
|
55
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
56
|
+
'no-debugger': 'error',
|
|
57
|
+
'no-duplicate-imports': 'error',
|
|
58
|
+
'no-unused-expressions': 'error',
|
|
59
|
+
'prefer-const': 'error',
|
|
60
|
+
'prefer-arrow-callback': 'error',
|
|
61
|
+
'prefer-template': 'error',
|
|
62
|
+
|
|
63
|
+
// Import order rules
|
|
64
|
+
'import-x/order': [
|
|
65
|
+
'error',
|
|
66
|
+
{
|
|
67
|
+
groups: [
|
|
68
|
+
'builtin',
|
|
69
|
+
'external',
|
|
70
|
+
'internal',
|
|
71
|
+
'parent',
|
|
72
|
+
'sibling',
|
|
73
|
+
'index',
|
|
74
|
+
'object',
|
|
75
|
+
'type',
|
|
76
|
+
],
|
|
77
|
+
'newlines-between': 'always',
|
|
78
|
+
alphabetize: {
|
|
79
|
+
order: 'asc',
|
|
80
|
+
caseInsensitive: true,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
'import-x/no-duplicates': 'error',
|
|
85
|
+
'import-x/no-unresolved': 'off', // TypeScript handles this
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
// Prettier config (must be last to override formatting rules)
|
|
90
|
+
prettier,
|
|
91
|
+
]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
eslint: path.resolve(__dirname, 'eslint.config.mjs'),
|
|
5
|
+
prettier: path.resolve(__dirname, 'prettier.js'),
|
|
6
|
+
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
|
|
7
|
+
jest: path.resolve(__dirname, 'jest.config.js'),
|
|
8
|
+
vitest: path.resolve(__dirname, 'vitest.config.ts'),
|
|
9
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: 'ts-jest',
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
roots: ['<rootDir>/src', '<rootDir>/test'],
|
|
5
|
+
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
|
|
6
|
+
transform: {
|
|
7
|
+
'^.+\\.ts$': [
|
|
8
|
+
'ts-jest',
|
|
9
|
+
{
|
|
10
|
+
tsconfig: {
|
|
11
|
+
compilerOptions: {
|
|
12
|
+
module: 'nodenext',
|
|
13
|
+
target: 'ES2024',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
collectCoverageFrom: [
|
|
20
|
+
'src/**/*.ts',
|
|
21
|
+
'!src/**/*.d.ts',
|
|
22
|
+
'!src/**/*.test.ts',
|
|
23
|
+
'!src/**/*.spec.ts',
|
|
24
|
+
],
|
|
25
|
+
coverageDirectory: 'coverage',
|
|
26
|
+
coverageReporters: ['text', 'lcov', 'html', 'json'],
|
|
27
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
|
|
28
|
+
verbose: true,
|
|
29
|
+
clearMocks: true,
|
|
30
|
+
resetMocks: true,
|
|
31
|
+
restoreMocks: true,
|
|
32
|
+
testTimeout: 10000,
|
|
33
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2024",
|
|
5
|
+
"module": "nodenext",
|
|
6
|
+
"lib": [
|
|
7
|
+
"ES2024"
|
|
8
|
+
],
|
|
9
|
+
"moduleResolution": "nodenext",
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"checkJs": false,
|
|
13
|
+
"outDir": "./dist",
|
|
14
|
+
"rootDir": "./",
|
|
15
|
+
"strict": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"declarationMap": true,
|
|
21
|
+
"sourceMap": true,
|
|
22
|
+
"noUnusedLocals": true,
|
|
23
|
+
"noUnusedParameters": true,
|
|
24
|
+
"noImplicitReturns": true,
|
|
25
|
+
"noFallthroughCasesInSwitch": true,
|
|
26
|
+
"isolatedModules": true,
|
|
27
|
+
"allowSyntheticDefaultImports": true
|
|
28
|
+
},
|
|
29
|
+
"exclude": [
|
|
30
|
+
"node_modules",
|
|
31
|
+
"dist",
|
|
32
|
+
"build"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'node',
|
|
7
|
+
include: ['**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
|
8
|
+
exclude: ['**/node_modules/**', '**/dist/**', '**/build/**'],
|
|
9
|
+
pool: 'forks',
|
|
10
|
+
fileParallelism: true,
|
|
11
|
+
testTimeout: 5000,
|
|
12
|
+
hookTimeout: 10000,
|
|
13
|
+
reporters: ['default', 'json', 'html'],
|
|
14
|
+
outputFile: {
|
|
15
|
+
json: './test-results.json',
|
|
16
|
+
html: './test-results/index.html',
|
|
17
|
+
},
|
|
18
|
+
coverage: {
|
|
19
|
+
provider: 'v8',
|
|
20
|
+
enabled: false,
|
|
21
|
+
reporter: ['text', 'json', 'html', 'lcov'],
|
|
22
|
+
reportsDirectory: './coverage',
|
|
23
|
+
include: ['src/**/*.{ts,tsx}'],
|
|
24
|
+
exclude: [
|
|
25
|
+
'node_modules/',
|
|
26
|
+
'dist/',
|
|
27
|
+
'build/',
|
|
28
|
+
'**/*.d.ts',
|
|
29
|
+
'**/*.config.{ts,js,mjs}',
|
|
30
|
+
'**/*.test.{ts,tsx}',
|
|
31
|
+
'**/*.spec.{ts,tsx}',
|
|
32
|
+
],
|
|
33
|
+
thresholds: {
|
|
34
|
+
lines: 80,
|
|
35
|
+
functions: 80,
|
|
36
|
+
branches: 80,
|
|
37
|
+
statements: 80,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
clearMocks: true,
|
|
41
|
+
restoreMocks: true,
|
|
42
|
+
sequence: {
|
|
43
|
+
shuffle: false,
|
|
44
|
+
concurrent: false,
|
|
45
|
+
hooks: 'stack',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import nestjsPlugin from '@nestjs/eslint-plugin-nestjs';
|
|
5
|
+
import importPlugin from 'eslint-plugin-import-x';
|
|
6
|
+
import globals from 'globals';
|
|
7
|
+
import prettier from 'eslint-config-prettier';
|
|
8
|
+
|
|
9
|
+
export default defineConfig([
|
|
10
|
+
// Base recommended configs
|
|
11
|
+
eslint.configs.recommended,
|
|
12
|
+
...tseslint.configs.recommended,
|
|
13
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
14
|
+
|
|
15
|
+
// Global ignores
|
|
16
|
+
{
|
|
17
|
+
ignores: ['dist/**', 'build/**', 'node_modules/**', '*.config.js', '*.config.ts', '*.config.mjs'],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
// TypeScript files configuration
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.ts'],
|
|
23
|
+
languageOptions: {
|
|
24
|
+
ecmaVersion: 2024,
|
|
25
|
+
sourceType: 'module',
|
|
26
|
+
globals: {
|
|
27
|
+
...globals.node,
|
|
28
|
+
...globals.es2024,
|
|
29
|
+
},
|
|
30
|
+
parser: tseslint.parser,
|
|
31
|
+
parserOptions: {
|
|
32
|
+
projectService: true,
|
|
33
|
+
tsconfigRootDir: import.meta.dirname,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
plugins: {
|
|
37
|
+
'@typescript-eslint': tseslint.plugin,
|
|
38
|
+
'@nestjs': nestjsPlugin,
|
|
39
|
+
'import-x': importPlugin,
|
|
40
|
+
},
|
|
41
|
+
rules: {
|
|
42
|
+
// TypeScript specific rules
|
|
43
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
44
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
45
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
46
|
+
'@typescript-eslint/no-unused-vars': [
|
|
47
|
+
'error',
|
|
48
|
+
{
|
|
49
|
+
argsIgnorePattern: '^_',
|
|
50
|
+
varsIgnorePattern: '^_',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
'@typescript-eslint/prefer-const': 'error',
|
|
54
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
55
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
56
|
+
|
|
57
|
+
// NestJS specific rules
|
|
58
|
+
'@nestjs/use-validation-pipe': 'warn',
|
|
59
|
+
'@nestjs/use-pipes-decorator': 'warn',
|
|
60
|
+
|
|
61
|
+
// General best practices
|
|
62
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
63
|
+
'no-debugger': 'error',
|
|
64
|
+
'no-duplicate-imports': 'error',
|
|
65
|
+
'no-unused-expressions': 'error',
|
|
66
|
+
'prefer-const': 'error',
|
|
67
|
+
'prefer-arrow-callback': 'error',
|
|
68
|
+
'prefer-template': 'error',
|
|
69
|
+
|
|
70
|
+
// Import order rules
|
|
71
|
+
'import-x/order': [
|
|
72
|
+
'error',
|
|
73
|
+
{
|
|
74
|
+
groups: [
|
|
75
|
+
'builtin',
|
|
76
|
+
'external',
|
|
77
|
+
'internal',
|
|
78
|
+
'parent',
|
|
79
|
+
'sibling',
|
|
80
|
+
'index',
|
|
81
|
+
'object',
|
|
82
|
+
'type',
|
|
83
|
+
],
|
|
84
|
+
'newlines-between': 'always',
|
|
85
|
+
alphabetize: {
|
|
86
|
+
order: 'asc',
|
|
87
|
+
caseInsensitive: true,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
'import-x/no-duplicates': 'error',
|
|
92
|
+
'import-x/no-unresolved': 'off', // TypeScript handles this
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
// Prettier config (must be last to override formatting rules)
|
|
97
|
+
prettier,
|
|
98
|
+
]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
eslint: path.resolve(__dirname, 'eslint.config.mjs'),
|
|
5
|
+
prettier: path.resolve(__dirname, '../base/prettier.js'),
|
|
6
|
+
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
|
|
7
|
+
jest: path.resolve(__dirname, 'jest.config.js'),
|
|
8
|
+
vitest: path.resolve(__dirname, '../base/vitest.config.ts'),
|
|
9
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const baseJest = require('../base/jest.config.js');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
...baseJest,
|
|
5
|
+
moduleNameMapper: {
|
|
6
|
+
'^src/(.*)$': '<rootDir>/src/$1',
|
|
7
|
+
},
|
|
8
|
+
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
|
|
9
|
+
collectCoverageFrom: [
|
|
10
|
+
'src/**/*.ts',
|
|
11
|
+
'!src/**/*.d.ts',
|
|
12
|
+
'!src/**/*.spec.ts',
|
|
13
|
+
'!src/**/*.interface.ts',
|
|
14
|
+
'!src/main.ts',
|
|
15
|
+
],
|
|
16
|
+
coverageThreshold: {
|
|
17
|
+
global: {
|
|
18
|
+
branches: 80,
|
|
19
|
+
functions: 80,
|
|
20
|
+
lines: 80,
|
|
21
|
+
statements: 80,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "../base/tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"module": "CommonJS",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"target": "ES2024",
|
|
8
|
+
"lib": [
|
|
9
|
+
"ES2024"
|
|
10
|
+
],
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"removeComments": true,
|
|
13
|
+
"emitDecoratorMetadata": true,
|
|
14
|
+
"experimentalDecorators": true,
|
|
15
|
+
"allowSyntheticDefaultImports": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"outDir": "./dist",
|
|
18
|
+
"baseUrl": "./",
|
|
19
|
+
"incremental": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"strictNullChecks": true,
|
|
22
|
+
"noImplicitAny": true,
|
|
23
|
+
"strictBindCallApply": true,
|
|
24
|
+
"forceConsistentCasingInFileNames": true,
|
|
25
|
+
"noFallthroughCasesInSwitch": true
|
|
26
|
+
},
|
|
27
|
+
"include": [
|
|
28
|
+
"src/**/*"
|
|
29
|
+
],
|
|
30
|
+
"exclude": [
|
|
31
|
+
"node_modules",
|
|
32
|
+
"dist",
|
|
33
|
+
"test",
|
|
34
|
+
"**/*spec.ts"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
5
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
6
|
+
import importPlugin from 'eslint-plugin-import-x';
|
|
7
|
+
import globals from 'globals';
|
|
8
|
+
import prettier from 'eslint-config-prettier';
|
|
9
|
+
|
|
10
|
+
export default defineConfig([
|
|
11
|
+
// Base recommended configs
|
|
12
|
+
eslint.configs.recommended,
|
|
13
|
+
...tseslint.configs.recommended,
|
|
14
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
15
|
+
|
|
16
|
+
// Global ignores
|
|
17
|
+
{
|
|
18
|
+
ignores: ['dist/**', 'build/**', 'node_modules/**', '*.config.js', '*.config.ts', '*.config.mjs'],
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
// TypeScript and React files configuration
|
|
22
|
+
{
|
|
23
|
+
files: ['**/*.{ts,tsx,js,jsx}'],
|
|
24
|
+
languageOptions: {
|
|
25
|
+
ecmaVersion: 2024,
|
|
26
|
+
sourceType: 'module',
|
|
27
|
+
globals: {
|
|
28
|
+
...globals.browser,
|
|
29
|
+
...globals.node,
|
|
30
|
+
...globals.es2024,
|
|
31
|
+
},
|
|
32
|
+
parser: tseslint.parser,
|
|
33
|
+
parserOptions: {
|
|
34
|
+
ecmaFeatures: {
|
|
35
|
+
jsx: true,
|
|
36
|
+
},
|
|
37
|
+
projectService: true,
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
plugins: {
|
|
42
|
+
'@typescript-eslint': tseslint.plugin,
|
|
43
|
+
react: reactPlugin,
|
|
44
|
+
'react-hooks': reactHooksPlugin,
|
|
45
|
+
'import-x': importPlugin,
|
|
46
|
+
},
|
|
47
|
+
settings: {
|
|
48
|
+
react: {
|
|
49
|
+
version: 'detect',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
rules: {
|
|
53
|
+
// TypeScript specific rules
|
|
54
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
55
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
56
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
57
|
+
'@typescript-eslint/no-unused-vars': [
|
|
58
|
+
'error',
|
|
59
|
+
{
|
|
60
|
+
argsIgnorePattern: '^_',
|
|
61
|
+
varsIgnorePattern: '^_',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
'@typescript-eslint/prefer-const': 'error',
|
|
65
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
66
|
+
|
|
67
|
+
// General best practices
|
|
68
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
69
|
+
'no-debugger': 'error',
|
|
70
|
+
'no-duplicate-imports': 'error',
|
|
71
|
+
'no-unused-expressions': 'error',
|
|
72
|
+
'prefer-const': 'error',
|
|
73
|
+
'prefer-arrow-callback': 'error',
|
|
74
|
+
'prefer-template': 'error',
|
|
75
|
+
|
|
76
|
+
// React specific rules
|
|
77
|
+
'react/prop-types': 'off', // TypeScript handles this
|
|
78
|
+
'react/react-in-jsx-scope': 'off', // Not needed with new JSX transform
|
|
79
|
+
'react/display-name': 'off',
|
|
80
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
81
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
82
|
+
|
|
83
|
+
// Import order rules
|
|
84
|
+
'import-x/order': [
|
|
85
|
+
'error',
|
|
86
|
+
{
|
|
87
|
+
groups: [
|
|
88
|
+
'builtin',
|
|
89
|
+
'external',
|
|
90
|
+
'internal',
|
|
91
|
+
'parent',
|
|
92
|
+
'sibling',
|
|
93
|
+
'index',
|
|
94
|
+
'object',
|
|
95
|
+
'type',
|
|
96
|
+
],
|
|
97
|
+
'newlines-between': 'always',
|
|
98
|
+
alphabetize: {
|
|
99
|
+
order: 'asc',
|
|
100
|
+
caseInsensitive: true,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
'import-x/no-duplicates': 'error',
|
|
105
|
+
'import-x/no-unresolved': 'off', // TypeScript handles this
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
// Prettier config (must be last to override formatting rules)
|
|
110
|
+
prettier,
|
|
111
|
+
]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
eslint: path.resolve(__dirname, 'eslint.config.mjs'),
|
|
5
|
+
prettier: path.resolve(__dirname, '../base/prettier.js'),
|
|
6
|
+
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
|
|
7
|
+
vite: path.resolve(__dirname, 'vite.config.ts'),
|
|
8
|
+
jest: path.resolve(__dirname, '../base/jest.config.js'),
|
|
9
|
+
vitest: path.resolve(__dirname, '../base/vitest.config.ts'),
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "../base/tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"jsx": "react-jsx",
|
|
6
|
+
"lib": ["ES2024", "DOM", "DOM.Iterable"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"types": ["vite/client"],
|
|
10
|
+
"rootDir": "./"
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*", "**/*.ts", "**/*.tsx"],
|
|
13
|
+
"exclude": ["node_modules", "dist", "build"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @ts-nocheck - Template file for consuming projects, peer dependencies not installed here
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
plugins: [react()],
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
'@': path.resolve(__dirname, 'src'),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
build: {
|
|
17
|
+
outDir: 'dist',
|
|
18
|
+
sourcemap: true,
|
|
19
|
+
target: 'esnext',
|
|
20
|
+
minify: 'esbuild',
|
|
21
|
+
rollupOptions: {
|
|
22
|
+
output: {
|
|
23
|
+
manualChunks: {
|
|
24
|
+
vendor: ['react', 'react-dom'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
server: {
|
|
30
|
+
port: 3000,
|
|
31
|
+
open: true,
|
|
32
|
+
strictPort: false,
|
|
33
|
+
},
|
|
34
|
+
preview: {
|
|
35
|
+
port: 3000,
|
|
36
|
+
strictPort: false,
|
|
37
|
+
},
|
|
38
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sklv-labs/ts-dev-configs
|
|
3
|
+
* Unified development configurations for TypeScript projects
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Note: Paths are relative to package root
|
|
7
|
+
// Users can resolve them using require.resolve() or import.meta.resolve()
|
|
8
|
+
|
|
9
|
+
// Preset paths (for extends in config files)
|
|
10
|
+
export const presets = {
|
|
11
|
+
base: {
|
|
12
|
+
eslint: '@sklv-labs/ts-dev-configs/presets/base/eslint.config.mjs',
|
|
13
|
+
prettier: '@sklv-labs/ts-dev-configs/presets/base/prettier.js',
|
|
14
|
+
tsconfig: '@sklv-labs/ts-dev-configs/presets/base/tsconfig.json',
|
|
15
|
+
jest: '@sklv-labs/ts-dev-configs/presets/base/jest.config.js',
|
|
16
|
+
vitest: '@sklv-labs/ts-dev-configs/presets/base/vitest.config.ts',
|
|
17
|
+
},
|
|
18
|
+
react: {
|
|
19
|
+
eslint: '@sklv-labs/ts-dev-configs/presets/react/eslint.config.mjs',
|
|
20
|
+
prettier: '@sklv-labs/ts-dev-configs/presets/base/prettier.js',
|
|
21
|
+
tsconfig: '@sklv-labs/ts-dev-configs/presets/react/tsconfig.json',
|
|
22
|
+
vite: '@sklv-labs/ts-dev-configs/presets/react/vite.config.ts',
|
|
23
|
+
jest: '@sklv-labs/ts-dev-configs/presets/base/jest.config.js',
|
|
24
|
+
vitest: '@sklv-labs/ts-dev-configs/presets/base/vitest.config.ts',
|
|
25
|
+
},
|
|
26
|
+
nestjs: {
|
|
27
|
+
eslint: '@sklv-labs/ts-dev-configs/presets/nestjs/eslint.config.mjs',
|
|
28
|
+
prettier: '@sklv-labs/ts-dev-configs/presets/base/prettier.js',
|
|
29
|
+
tsconfig: '@sklv-labs/ts-dev-configs/presets/nestjs/tsconfig.json',
|
|
30
|
+
jest: '@sklv-labs/ts-dev-configs/presets/nestjs/jest.config.js',
|
|
31
|
+
vitest: '@sklv-labs/ts-dev-configs/presets/base/vitest.config.ts',
|
|
32
|
+
},
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
// Config paths
|
|
36
|
+
export const configs = {
|
|
37
|
+
git: {
|
|
38
|
+
lintStaged: '@sklv-labs/ts-dev-configs/configs/git/lint-staged.js',
|
|
39
|
+
commitlint: '@sklv-labs/ts-dev-configs/configs/git/commitlint.js',
|
|
40
|
+
husky: {
|
|
41
|
+
preCommit: '@sklv-labs/ts-dev-configs/configs/git/husky/pre-commit',
|
|
42
|
+
commitMsg: '@sklv-labs/ts-dev-configs/configs/git/husky/commit-msg',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
build: {
|
|
46
|
+
vite: '@sklv-labs/ts-dev-configs/configs/build/vite.base.ts',
|
|
47
|
+
webpack: '@sklv-labs/ts-dev-configs/configs/build/webpack.base.js',
|
|
48
|
+
},
|
|
49
|
+
editor: {
|
|
50
|
+
editorconfig: '@sklv-labs/ts-dev-configs/configs/editor/.editorconfig',
|
|
51
|
+
vscode: {
|
|
52
|
+
settings: '@sklv-labs/ts-dev-configs/configs/editor/vscode/settings.json',
|
|
53
|
+
extensions: '@sklv-labs/ts-dev-configs/configs/editor/vscode/extensions.json',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
} as const;
|
|
57
|
+
|
|
58
|
+
// Type definitions
|
|
59
|
+
export type PresetName = 'base' | 'react' | 'nestjs';
|
|
60
|
+
export type ConfigCategory = 'git' | 'build' | 'editor';
|