@dimensional-innovations/tool-config 1.1.0 → 1.2.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/README.md CHANGED
@@ -541,8 +541,96 @@ export default [
541
541
  ]
542
542
  ```
543
543
 
544
+ ## Ignoring Files
545
+
546
+ All tools automatically ignore common build outputs and generated files to prevent unnecessary linting and formatting. This happens automatically when you create a config - no manual setup required.
547
+
548
+ ### What Gets Ignored
549
+
550
+ **Common directories** (all tools):
551
+
552
+ - `node_modules/` - Dependencies
553
+ - `dist/`, `build/`, `out/` - Build outputs
554
+ - `coverage/` - Test coverage reports
555
+ - `.nyc_output/` - NYC coverage data
556
+
557
+ **Framework build outputs** (all tools):
558
+
559
+ - `.next/` - Next.js
560
+ - `.nuxt/`, `.output/` - Nuxt
561
+ - `.svelte-kit/` - SvelteKit
562
+ - `.vite/` - Vite cache
563
+ - `.cache/`, `.parcel-cache/`, `.turbo/` - Build caches
564
+
565
+ **Generated files** (Prettier only):
566
+
567
+ - Lock files (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`)
568
+ - `CHANGELOG.md` (auto-generated by semantic-release)
569
+
570
+ ### How It Works
571
+
572
+ **ESLint**: Uses runtime `ignores` array in flat config
573
+ **Stylelint**: Uses runtime `ignoreFiles` property in config
574
+ **Prettier**: Auto-generates `.prettierignore` file on first run
575
+
576
+ ### Customizing Ignore Patterns
577
+
578
+ **ESLint** - Add custom ignores:
579
+
580
+ ```javascript
581
+ export default await createConfig('eslint', {
582
+ ignorePaths: ['generated/**', 'legacy/**']
583
+ })
584
+ ```
585
+
586
+ **Stylelint** - Extend ignoreFiles:
587
+
588
+ ```javascript
589
+ export default createConfig('stylelint', {
590
+ ignoreFiles: ['**/*.min.css', 'vendor/**']
591
+ })
592
+ ```
593
+
594
+ **Prettier** - Edit `.prettierignore` file:
595
+
596
+ ```
597
+ # Custom ignores
598
+ generated/
599
+ legacy/
600
+ ```
601
+
602
+ ### Verifying Ignore Patterns
603
+
604
+ Check what files are being processed:
605
+
606
+ ```bash
607
+ # ESLint
608
+ npx eslint --debug . 2>&1 | grep "Ignored"
609
+
610
+ # Stylelint
611
+ npx stylelint "**/*.css" --formatter verbose
612
+
613
+ # Prettier
614
+ npx prettier --check . --debug-check
615
+ ```
616
+
544
617
  ## Troubleshooting
545
618
 
619
+ ### Tools Processing Build Outputs
620
+
621
+ If you see errors about linting/formatting files in `dist/`, `coverage/`, or `out/`:
622
+
623
+ 1. **ESLint**: Ignore patterns are applied automatically ✅
624
+ 2. **Stylelint**: Ignore patterns are applied automatically ✅
625
+ 3. **Prettier**: Check that `.prettierignore` was created. If not, re-run config creation or manually create the file.
626
+
627
+ **Solution**: If `.prettierignore` is missing, it will be auto-created next time you use the config. Or create it manually:
628
+
629
+ ```bash
630
+ # Let Prettier generate it
631
+ node -e "import('@dimensional-innovations/tool-config').then(m => m.createConfig('prettier'))"
632
+ ```
633
+
546
634
  ### ESLint Not Detecting Framework
547
635
 
548
636
  Ensure your `package.json` includes the framework dependency:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimensional-innovations/tool-config",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Universal configuration package for ESLint, Prettier, Stylelint, and semantic-release with auto-detection for React, Vue, Svelte, Solid, Astro, Angular, and more",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -2,6 +2,7 @@ import js from '@eslint/js'
2
2
  import tseslint from 'typescript-eslint'
3
3
 
4
4
  import { autoDetect } from '../../detectors.js'
5
+ import { getEslintIgnores } from '../../utils/ignore-patterns.js'
5
6
 
6
7
  import basePreset from './presets/base.js'
7
8
  import browserEnv from './presets/environments/browser.js'
@@ -234,16 +235,7 @@ export async function createEslintConfig(options = {}) {
234
235
  )
235
236
  }
236
237
 
237
- const defaultIgnorePaths = [
238
- '**/node_modules/**',
239
- '**/dist/**',
240
- '**/build/**',
241
- '**/out/**',
242
- '**/coverage/**',
243
- '**/*.min.js',
244
- '**/.next/**',
245
- '**/.nuxt/**'
246
- ]
238
+ const defaultIgnorePaths = getEslintIgnores()
247
239
  const allIgnorePaths = [...defaultIgnorePaths, ...(options.ignorePaths || [])]
248
240
 
249
241
  const config = []
@@ -4,7 +4,11 @@
4
4
  * Creates Prettier configurations with framework-aware defaults and auto-detection.
5
5
  */
6
6
 
7
+ import { existsSync, writeFileSync } from 'fs'
8
+ import { join } from 'path'
9
+
7
10
  import { autoDetect } from '../../detectors.js'
11
+ import { getPrettierIgnoreContent } from '../../utils/ignore-patterns.js'
8
12
 
9
13
  import basePreset from './presets/base.js'
10
14
  import astroPreset from './presets/frameworks/astro.js'
@@ -45,6 +49,20 @@ export function createPrettierConfig(options = {}) {
45
49
  // Auto-detect framework if needed
46
50
  const framework = explicitFramework === 'auto' ? autoDetect(cwd).framework : explicitFramework
47
51
 
52
+ // Auto-generate .prettierignore if it doesn't exist
53
+ const ignoreFile = join(cwd, '.prettierignore')
54
+ if (!existsSync(ignoreFile)) {
55
+ try {
56
+ writeFileSync(ignoreFile, getPrettierIgnoreContent(), 'utf8')
57
+ console.warn('📝 Prettier: Created .prettierignore file')
58
+ } catch {
59
+ console.warn(
60
+ '⚠️ Prettier: Could not create .prettierignore file automatically.\n' +
61
+ ' Please create it manually or ensure write permissions.'
62
+ )
63
+ }
64
+ }
65
+
48
66
  // Start with base configuration
49
67
  const config = { ...basePreset }
50
68
 
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import { autoDetect, detectCssType } from '../../detectors.js'
11
+ import { getStylelintIgnores } from '../../utils/ignore-patterns.js'
11
12
 
12
13
  import basePreset from './presets/base.js'
13
14
  import cssModulesPreset from './presets/css-modules.js'
@@ -127,6 +128,9 @@ export function createStylelintConfig(options = {}) {
127
128
  ? { ...scssPreset, customSyntax: 'postcss-scss' }
128
129
  : { ...basePreset }
129
130
 
131
+ // Add default ignore patterns
132
+ config.ignoreFiles = getStylelintIgnores()
133
+
130
134
  // Apply Tailwind preset if detected
131
135
  if (cssType?.tailwind) {
132
136
  mergePreset(config, tailwindPreset)
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Shared ignore patterns for all tools
3
+ *
4
+ * Provides consistent ignore patterns across ESLint, Prettier, and Stylelint
5
+ * to prevent processing build outputs, dependencies, and generated files.
6
+ */
7
+
8
+ /**
9
+ * Common directories that should be ignored by all tools
10
+ */
11
+ export const COMMON_IGNORE_DIRS = [
12
+ 'node_modules',
13
+ 'dist',
14
+ 'build',
15
+ 'out',
16
+ 'coverage',
17
+ '.nyc_output'
18
+ ]
19
+
20
+ /**
21
+ * Framework-specific build outputs
22
+ */
23
+ export const FRAMEWORK_BUILD_DIRS = [
24
+ '.next', // Next.js
25
+ '.nuxt', // Nuxt
26
+ '.output', // Nitro/Nuxt3
27
+ '.vercel', // Vercel
28
+ '.netlify', // Netlify
29
+ '.cache', // Gatsby/Parcel
30
+ '.parcel-cache', // Parcel
31
+ '.turbo', // Turborepo
32
+ '.vite', // Vite
33
+ '.svelte-kit' // SvelteKit
34
+ ]
35
+
36
+ /**
37
+ * Lock files and generated files
38
+ */
39
+ export const GENERATED_FILES = [
40
+ 'package-lock.json',
41
+ 'pnpm-lock.yaml',
42
+ 'yarn.lock',
43
+ 'bun.lockb',
44
+ 'CHANGELOG.md'
45
+ ]
46
+
47
+ /**
48
+ * Minified files
49
+ */
50
+ export const MINIFIED_FILES = ['*.min.js', '*.min.css', '*.min.mjs']
51
+
52
+ /**
53
+ * Get ESLint ignore patterns (flat config format)
54
+ * @returns {string[]} Array of glob patterns for ESLint ignores array
55
+ */
56
+ export function getEslintIgnores() {
57
+ return [
58
+ ...COMMON_IGNORE_DIRS.map(dir => `**/${dir}/**`),
59
+ ...FRAMEWORK_BUILD_DIRS.map(dir => `**/${dir}/**`),
60
+ ...MINIFIED_FILES.map(pattern => `**/${pattern}`)
61
+ ]
62
+ }
63
+
64
+ /**
65
+ * Get Stylelint ignore patterns (ignoreFiles format)
66
+ * @returns {string[]} Array of glob patterns for Stylelint ignoreFiles
67
+ */
68
+ export function getStylelintIgnores() {
69
+ return [
70
+ ...COMMON_IGNORE_DIRS.map(dir => `**/${dir}/**`),
71
+ ...FRAMEWORK_BUILD_DIRS.map(dir => `**/${dir}/**`),
72
+ ...MINIFIED_FILES.map(pattern => `**/${pattern}`)
73
+ ]
74
+ }
75
+
76
+ /**
77
+ * Get Prettier ignore content (.prettierignore file format)
78
+ * @returns {string} .prettierignore file content
79
+ */
80
+ export function getPrettierIgnoreContent() {
81
+ return `# Dependencies
82
+ node_modules/
83
+ .pnp/
84
+ .pnp.js
85
+
86
+ # Build outputs
87
+ ${COMMON_IGNORE_DIRS.filter(dir => dir !== 'node_modules' && dir !== 'coverage')
88
+ .map(dir => `${dir}/`)
89
+ .join('\n')}
90
+ ${FRAMEWORK_BUILD_DIRS.map(dir => `${dir}/`).join('\n')}
91
+
92
+ # Coverage
93
+ coverage/
94
+ .nyc_output/
95
+ *.lcov
96
+
97
+ # Lock files
98
+ ${GENERATED_FILES.filter(f => f.includes('lock') || f.includes('.lock')).join('\n')}
99
+
100
+ # Generated files
101
+ CHANGELOG.md
102
+
103
+ # Cache directories
104
+ .cache/
105
+ .parcel-cache/
106
+ .turbo/
107
+ .vite/
108
+
109
+ # Environment files (may contain secrets)
110
+ .env
111
+ .env.local
112
+ .env.*.local
113
+
114
+ # IDE
115
+ .vscode/
116
+ .idea/
117
+
118
+ # OS files
119
+ .DS_Store
120
+ Thumbs.db
121
+ `
122
+ }
123
+
124
+ /**
125
+ * Get Stylelint ignore content (.stylelintignore file format)
126
+ * @returns {string} .stylelintignore file content
127
+ */
128
+ export function getStylelintIgnoreContent() {
129
+ return `# Dependencies
130
+ node_modules/
131
+
132
+ # Build outputs
133
+ ${COMMON_IGNORE_DIRS.filter(dir => dir !== 'node_modules' && dir !== 'coverage')
134
+ .map(dir => `${dir}/`)
135
+ .join('\n')}
136
+ ${FRAMEWORK_BUILD_DIRS.map(dir => `${dir}/`).join('\n')}
137
+
138
+ # Coverage
139
+ coverage/
140
+ .nyc_output/
141
+
142
+ # Minified files
143
+ ${MINIFIED_FILES.join('\n')}
144
+ `
145
+ }
146
+
147
+ export default {
148
+ COMMON_IGNORE_DIRS,
149
+ FRAMEWORK_BUILD_DIRS,
150
+ GENERATED_FILES,
151
+ MINIFIED_FILES,
152
+ getEslintIgnores,
153
+ getStylelintIgnores,
154
+ getPrettierIgnoreContent,
155
+ getStylelintIgnoreContent
156
+ }