@dimensional-innovations/tool-config 5.0.0 → 5.0.1

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.
@@ -0,0 +1,401 @@
1
+ /**
2
+ * Shared type definitions for @dimensional-innovations/tool-config
3
+ */
4
+ type ToolName = 'eslint' | 'prettier' | 'stylelint' | 'typescript' | 'semantic-release';
5
+ type Framework = 'react' | 'vue' | 'svelte' | 'solid' | 'astro' | 'angular' | 'vanilla' | 'node' | 'auto';
6
+ type ResolvedFramework = Exclude<Framework, 'auto'>;
7
+ type Environment = 'browser' | 'node' | 'universal' | 'auto';
8
+ type ResolvedEnvironment = Exclude<Environment, 'auto'>;
9
+ type GitProvider = 'gitlab' | 'github' | 'bitbucket' | null;
10
+ type CssPreprocessor = 'scss' | 'sass' | 'less' | null;
11
+ interface CssTypeResult {
12
+ preprocessor: CssPreprocessor;
13
+ tailwind: boolean;
14
+ modules: boolean;
15
+ postcss: boolean;
16
+ }
17
+ interface DetectionResult {
18
+ framework: ResolvedFramework;
19
+ environment: ResolvedEnvironment;
20
+ typescript: boolean;
21
+ gitProvider: GitProvider;
22
+ cssType: CssTypeResult;
23
+ electron: boolean;
24
+ }
25
+ interface PackageJson {
26
+ name?: string;
27
+ version?: string;
28
+ type?: 'module' | 'commonjs';
29
+ main?: string;
30
+ dependencies?: Record<string, string>;
31
+ devDependencies?: Record<string, string>;
32
+ peerDependencies?: Record<string, string>;
33
+ repository?: string | {
34
+ type?: string;
35
+ url?: string;
36
+ };
37
+ scripts?: Record<string, string>;
38
+ }
39
+ interface BaseOptions {
40
+ framework?: Framework;
41
+ environment?: Environment;
42
+ cwd?: string;
43
+ customIgnores?: string[];
44
+ }
45
+ interface EslintOptions extends BaseOptions {
46
+ typescript?: boolean | 'auto';
47
+ ignorePaths?: string[];
48
+ rules?: Record<string, unknown>;
49
+ }
50
+ interface PrettierOptions extends BaseOptions {
51
+ [key: string]: unknown;
52
+ }
53
+ interface StylelintOptions extends BaseOptions {
54
+ cssType?: CssTypeResult | 'auto';
55
+ rules?: Record<string, unknown>;
56
+ extends?: string | string[];
57
+ overrides?: unknown[];
58
+ }
59
+ interface TypescriptOptions extends BaseOptions {
60
+ checker?: 'modern' | 'legacy' | 'auto';
61
+ strict?: boolean;
62
+ electron?: boolean;
63
+ renderer?: ResolvedFramework;
64
+ compilerOptions?: Record<string, unknown>;
65
+ }
66
+ type ReleasePreset = 'default' | 'library' | 'monorepo';
67
+ interface SemanticReleaseOptions extends BaseOptions {
68
+ preset?: ReleasePreset;
69
+ gitProvider?: GitProvider | 'auto';
70
+ branches?: unknown[];
71
+ plugins?: unknown[];
72
+ }
73
+ type ToolOptions = EslintOptions | PrettierOptions | StylelintOptions | TypescriptOptions | SemanticReleaseOptions;
74
+ type TypeChecker = 'tsgo' | 'vue-tsc' | 'tsc';
75
+ type TypeCheckerPreference = 'modern' | 'legacy' | 'auto';
76
+ interface ConfigMeta {
77
+ framework: ResolvedFramework;
78
+ environment?: ResolvedEnvironment;
79
+ checker?: TypeChecker;
80
+ experimental?: boolean;
81
+ renderer?: ResolvedFramework;
82
+ multiConfig?: boolean;
83
+ generatedBy?: string;
84
+ }
85
+ interface EslintFlatConfig {
86
+ name?: string;
87
+ files?: string[];
88
+ ignores?: string[];
89
+ languageOptions?: Record<string, unknown>;
90
+ plugins?: Record<string, unknown>;
91
+ rules?: Record<string, unknown>;
92
+ settings?: Record<string, unknown>;
93
+ processor?: unknown;
94
+ }
95
+ interface PrettierConfig {
96
+ printWidth?: number;
97
+ tabWidth?: number;
98
+ useTabs?: boolean;
99
+ semi?: boolean;
100
+ singleQuote?: boolean;
101
+ quoteProps?: 'as-needed' | 'consistent' | 'preserve';
102
+ jsxSingleQuote?: boolean;
103
+ trailingComma?: 'none' | 'es5' | 'all';
104
+ bracketSpacing?: boolean;
105
+ bracketSameLine?: boolean;
106
+ arrowParens?: 'avoid' | 'always';
107
+ proseWrap?: 'always' | 'never' | 'preserve';
108
+ htmlWhitespaceSensitivity?: 'css' | 'strict' | 'ignore';
109
+ endOfLine?: 'auto' | 'lf' | 'crlf' | 'cr';
110
+ singleAttributePerLine?: boolean;
111
+ plugins?: string[];
112
+ overrides?: Array<{
113
+ files: string | string[];
114
+ options?: Record<string, unknown>;
115
+ }>;
116
+ [key: string]: unknown;
117
+ }
118
+ interface StylelintConfig {
119
+ extends?: string | string[];
120
+ plugins?: string[];
121
+ rules?: Record<string, unknown>;
122
+ overrides?: Array<{
123
+ files: string[];
124
+ rules?: Record<string, unknown>;
125
+ customSyntax?: string;
126
+ }>;
127
+ ignoreFiles?: string[];
128
+ customSyntax?: string;
129
+ [key: string]: unknown;
130
+ }
131
+ interface TypescriptConfig {
132
+ $schema?: string;
133
+ files?: string[];
134
+ compilerOptions?: Record<string, unknown>;
135
+ include?: string[];
136
+ exclude?: string[];
137
+ references?: Array<{
138
+ path: string;
139
+ }>;
140
+ _meta?: ConfigMeta;
141
+ }
142
+ interface ElectronMultiConfig {
143
+ root: TypescriptConfig;
144
+ node: TypescriptConfig;
145
+ web: TypescriptConfig;
146
+ tests: TypescriptConfig;
147
+ _meta?: ConfigMeta;
148
+ }
149
+ interface SemanticReleaseConfig {
150
+ branches?: unknown[];
151
+ plugins?: unknown[];
152
+ tagFormat?: string;
153
+ ci?: boolean;
154
+ _meta?: {
155
+ preset: ReleasePreset;
156
+ gitProvider: GitProvider;
157
+ };
158
+ [key: string]: unknown;
159
+ }
160
+ declare class ConfigError extends Error {
161
+ readonly context?: Record<string, unknown>;
162
+ constructor(message: string, context?: Record<string, unknown>);
163
+ }
164
+
165
+ /**
166
+ * Create an ESLint flat config
167
+ *
168
+ * Supports: React, Vue.js, Svelte, Solid, Astro, Angular, Vanilla JS/TS, and auto-detection
169
+ *
170
+ * @param options - Configuration options
171
+ * @returns ESLint flat config array
172
+ *
173
+ * @example
174
+ * // Zero config - auto-detects everything
175
+ * import { createEslintConfig } from '@dimensional-innovations/tool-config';
176
+ * export default await createEslintConfig();
177
+ *
178
+ * @example
179
+ * // Explicit configuration
180
+ * import { createEslintConfig } from '@dimensional-innovations/tool-config';
181
+ * export default await createEslintConfig({
182
+ * framework: 'react',
183
+ * environment: 'browser',
184
+ * typescript: true
185
+ * });
186
+ *
187
+ * @example
188
+ * // With custom rules
189
+ * import { createEslintConfig } from '@dimensional-innovations/tool-config';
190
+ * export default await createEslintConfig({
191
+ * rules: {
192
+ * 'no-console': 'off'
193
+ * }
194
+ * });
195
+ */
196
+ declare function createEslintConfig(options?: EslintOptions): Promise<EslintFlatConfig[]>;
197
+
198
+ /**
199
+ * Prettier configuration factory
200
+ *
201
+ * Creates Prettier configurations with framework-aware defaults and auto-detection.
202
+ */
203
+
204
+ /**
205
+ * Create a Prettier configuration
206
+ *
207
+ * @param options - Configuration options
208
+ * @returns Prettier configuration object
209
+ *
210
+ * @example
211
+ * // Auto-detect framework
212
+ * export default await createPrettierConfig();
213
+ *
214
+ * @example
215
+ * // Explicit framework
216
+ * export default await createPrettierConfig({ framework: 'vue' });
217
+ *
218
+ * @example
219
+ * // With overrides
220
+ * export default await createPrettierConfig({
221
+ * framework: 'react',
222
+ * printWidth: 120,
223
+ * semi: true
224
+ * });
225
+ */
226
+ declare function createPrettierConfig(options?: PrettierOptions): Promise<PrettierConfig>;
227
+
228
+ /**
229
+ * Stylelint configuration factory
230
+ *
231
+ * Creates Stylelint configurations with framework-aware defaults for CSS linting.
232
+ *
233
+ * Note: Stylelint is for CSS files and component styles (Vue, Svelte).
234
+ * CSS-in-JS (React styled-components, emotion) should use ESLint plugins instead.
235
+ */
236
+
237
+ /**
238
+ * Create a Stylelint configuration
239
+ *
240
+ * @param options - Configuration options
241
+ * @returns Stylelint configuration object
242
+ *
243
+ * @example
244
+ * // Auto-detect framework
245
+ * export default await createStylelintConfig();
246
+ *
247
+ * @example
248
+ * // Explicit framework
249
+ * export default await createStylelintConfig({ framework: 'vue' });
250
+ *
251
+ * @example
252
+ * // Explicit CSS type
253
+ * export default await createStylelintConfig({ cssType: 'scss' });
254
+ *
255
+ * @example
256
+ * // With overrides
257
+ * export default await createStylelintConfig({
258
+ * framework: 'vue',
259
+ * cssType: 'scss',
260
+ * rules: {
261
+ * 'color-hex-length': 'long'
262
+ * }
263
+ * });
264
+ */
265
+ declare function createStylelintConfig(options?: StylelintOptions): Promise<StylelintConfig>;
266
+
267
+ /**
268
+ * semantic-release configuration factory
269
+ *
270
+ * Creates semantic-release configurations with preset-based defaults.
271
+ * Supports standard releases, library publishing, and monorepo structures.
272
+ * Auto-detects Git provider (GitLab, GitHub, Bitbucket) from repository URL.
273
+ */
274
+
275
+ /**
276
+ * Create a semantic-release configuration
277
+ *
278
+ * @example
279
+ * // Use default preset with auto-detected Git provider
280
+ * export default await createReleaseConfig();
281
+ *
282
+ * @example
283
+ * // Use library preset with auto-detected Git provider
284
+ * export default await createReleaseConfig({ preset: 'library' });
285
+ *
286
+ * @example
287
+ * // Explicitly specify Git provider
288
+ * export default await createReleaseConfig({
289
+ * preset: 'default',
290
+ * gitProvider: 'github'
291
+ * });
292
+ *
293
+ * @example
294
+ * // Disable Git provider plugin
295
+ * export default await createReleaseConfig({
296
+ * preset: 'default',
297
+ * gitProvider: null
298
+ * });
299
+ *
300
+ * @example
301
+ * // With custom branches
302
+ * export default await createReleaseConfig({
303
+ * preset: 'default',
304
+ * branches: ['main', 'next']
305
+ * });
306
+ *
307
+ * @example
308
+ * // With plugin overrides
309
+ * export default await createReleaseConfig({
310
+ * preset: 'library',
311
+ * plugins: [
312
+ * '@semantic-release/commit-analyzer',
313
+ * '@semantic-release/release-notes-generator',
314
+ * '@semantic-release/npm'
315
+ * ]
316
+ * });
317
+ */
318
+ declare function createReleaseConfig(options?: SemanticReleaseOptions): Promise<SemanticReleaseConfig>;
319
+
320
+ /**
321
+ * Create TypeScript configuration with auto-detection
322
+ *
323
+ * @param options - Configuration options
324
+ * @returns TypeScript configuration object
325
+ *
326
+ * @example
327
+ * // Auto-detect framework
328
+ * export default await createTypescriptConfig();
329
+ *
330
+ * @example
331
+ * // Explicit framework
332
+ * export default await createTypescriptConfig({ framework: 'react' });
333
+ *
334
+ * @example
335
+ * // With custom compiler options
336
+ * export default await createTypescriptConfig({
337
+ * framework: 'react',
338
+ * compilerOptions: { outDir: './build' }
339
+ * });
340
+ */
341
+ declare function createTypescriptConfig(options?: TypescriptOptions): Promise<TypescriptConfig | ElectronMultiConfig>;
342
+
343
+ /**
344
+ * Detect the framework being used in the project
345
+ * @param cwd - Current working directory
346
+ * @returns Detected framework name
347
+ */
348
+ declare function detectFramework(cwd?: string): ResolvedFramework;
349
+ /**
350
+ * Detect the environment (browser, node, or universal)
351
+ * @param framework - Detected framework
352
+ * @param cwd - Current working directory
353
+ * @returns Environment type
354
+ */
355
+ declare function detectEnvironment(framework: ResolvedFramework, cwd?: string): ResolvedEnvironment;
356
+ /**
357
+ * Detect if TypeScript is being used
358
+ * @param cwd - Current working directory
359
+ * @returns True if TypeScript is detected
360
+ */
361
+ declare function detectTypeScript(cwd?: string): boolean;
362
+ /**
363
+ * Detect Git provider from repository URL
364
+ * @param cwd - Current working directory
365
+ * @returns Git provider ('gitlab', 'github', 'bitbucket', or null)
366
+ */
367
+ declare function detectGitProvider(cwd?: string): GitProvider;
368
+ /**
369
+ * Detect CSS type and variants
370
+ * @param cwd - Current working directory
371
+ * @returns CSS type detection results
372
+ */
373
+ declare function detectCssType(cwd?: string): CssTypeResult;
374
+ /**
375
+ * Detect if project is an Electron application
376
+ * @param cwd - Current working directory
377
+ * @returns True if Electron project detected
378
+ */
379
+ declare function detectElectron(cwd?: string): boolean;
380
+ /**
381
+ * Auto-detect all configuration options
382
+ * @param cwd - Current working directory
383
+ * @returns Detected configuration
384
+ */
385
+ declare function autoDetect(cwd?: string): DetectionResult;
386
+
387
+ /**
388
+ * @dimensional-innovations/tool-config
389
+ * Universal configuration package for development tools
390
+ *
391
+ * Supports: ESLint, Prettier, Stylelint, semantic-release, TypeScript
392
+ * Auto-detects: React, Vue, Svelte, Solid, Astro, Angular, Vanilla JS, Node.js
393
+ */
394
+
395
+ declare function createConfig(tool: 'eslint', options?: EslintOptions): Promise<EslintFlatConfig[]>;
396
+ declare function createConfig(tool: 'prettier', options?: PrettierOptions): Promise<PrettierConfig>;
397
+ declare function createConfig(tool: 'stylelint', options?: StylelintOptions): Promise<StylelintConfig>;
398
+ declare function createConfig(tool: 'typescript', options?: TypescriptOptions): Promise<TypescriptConfig>;
399
+ declare function createConfig(tool: 'semantic-release', options?: SemanticReleaseOptions): Promise<SemanticReleaseConfig>;
400
+
401
+ export { type BaseOptions, ConfigError, type ConfigMeta, type CssPreprocessor, type CssTypeResult, type DetectionResult, type Environment, type EslintFlatConfig, type EslintOptions, type Framework, type GitProvider, type PackageJson, type PrettierConfig, type PrettierOptions, type ReleasePreset, type ResolvedEnvironment, type ResolvedFramework, type SemanticReleaseConfig, type SemanticReleaseOptions, type StylelintConfig, type StylelintOptions, type ToolName, type ToolOptions, type TypeChecker, type TypeCheckerPreference, type TypescriptConfig, type TypescriptOptions, autoDetect, createConfig, createEslintConfig, createPrettierConfig, createReleaseConfig, createStylelintConfig, createTypescriptConfig, detectCssType, detectElectron, detectEnvironment, detectFramework, detectGitProvider, detectTypeScript };