skyltmax_config 1.0.0 → 2.0.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.
data/AGENTS.md DELETED
@@ -1,677 +0,0 @@
1
- # AI Agent Guide for @skyltmax/config
2
-
3
- This document provides comprehensive guidance for AI coding agents working with the `@skyltmax/config` package.
4
-
5
- ## Table of Contents
6
-
7
- 1. [Conventions](#conventions)
8
- 2. [Package Overview](#package-overview)
9
- 3. [Getting Started](#getting-started)
10
- 4. [Development](#development)
11
- 5. [Testing](#testing)
12
- 6. [Configuration](#configuration)
13
-
14
- ---
15
-
16
- ## Conventions
17
-
18
- - Max line length before wrapping is 120 chars.
19
- - Don't be overly verbose, prefer brevity.
20
- - Always put strong emphasis on idiomatic TypeScript solutions.
21
- - Always uphold the configured linter settings - eslint, prettier.
22
- - Avoid tautologic comments - prefer saying nothing over stating the obvious.
23
- - Linear git history is required. Avoid cherry-picking etc.
24
-
25
- ### Commit message
26
-
27
- Commit messages should follow a specific format:
28
-
29
- ```
30
- <type>(<scope>): <subject>
31
- <BLANK LINE>
32
- <body>
33
- <BLANK LINE>
34
- <footer>
35
- ```
36
-
37
- For example:
38
-
39
- ```
40
- fix(middleware): Fix device key cookie initialization
41
-
42
- The device key middleware was not setting the cookie header correctly.
43
-
44
- Fixes #42
45
- ```
46
-
47
- Or:
48
-
49
- ```
50
- feat(server): Add configurable middleware options
51
-
52
- Allow users to disable default middleware via ServeAppOptions.
53
-
54
- Breaking change: Default middleware is now optional
55
- ```
56
-
57
- ---
58
-
59
- ## Package Overview
60
-
61
- ### Structure
62
-
63
- This is a **dual-language configuration package** providing ESLint, Prettier, and TypeScript configs for
64
- JavaScript/TypeScript projects, and Rubocop configs for Ruby projects:
65
-
66
- ```
67
- @skyltmax/config/
68
- ├── lib/
69
- │ └── skyltmax_config.rb # Ruby gem entry point
70
- ├── eslint.js # ESLint configuration
71
- ├── eslint.config.js # Example ESLint usage
72
- ├── prettier.js # Prettier configuration
73
- ├── typescript.json # TypeScript configuration
74
- ├── reset.d.ts # TypeScript reset types
75
- ├── rubocop.yml # Rubocop base config
76
- ├── rubocop.rails.yml # Rubocop Rails config
77
- ├── index.js # Package entry point
78
- ├── package.json # npm package manifest
79
- ├── skyltmax_config.gemspec # Ruby gem specification
80
- ├── tsconfig.json # TypeScript config
81
- ├── Gemfile # Ruby dependencies
82
- ├── Rakefile # Ruby tasks
83
- └── README.md
84
- ```
85
-
86
- ### Technology Stack
87
-
88
- **JavaScript/TypeScript:**
89
-
90
- - ESLint 9+ (flat config)
91
- - Prettier 3+
92
- - TypeScript 5+
93
- - React support
94
- - Vitest support
95
- - Testing Library support
96
-
97
- **Ruby:**
98
-
99
- - Rubocop (>= 1.81.0)
100
- - Rubocop Performance
101
- - Rubocop Rails
102
-
103
- **Key Dependencies:**
104
-
105
- - `@typescript-eslint/eslint-plugin` & `@typescript-eslint/parser`
106
- - `eslint-plugin-react`, `eslint-plugin-react-hooks`
107
- - `eslint-plugin-jsx-a11y`
108
- - `eslint-plugin-import-x`
109
- - `@vitest/eslint-plugin`
110
- - `eslint-plugin-testing-library`, `eslint-plugin-jest-dom`
111
- - `prettier-plugin-tailwindcss`
112
- - `@total-typescript/ts-reset`
113
-
114
- **System Requirements:**
115
-
116
- - Node.js >= 18.0.0
117
- - Ruby >= 3.4 (for Rubocop configs)
118
-
119
- ---
120
-
121
- ## Getting Started
122
-
123
- ### Installation
124
-
125
- **For JavaScript/TypeScript projects:**
126
-
127
- ```bash
128
- npm install --save-dev @skyltmax/config
129
- # or
130
- pnpm add -D @skyltmax/config
131
- ```
132
-
133
- **That's it!** All required tools (ESLint, Prettier, TypeScript, and all plugins) are bundled as dependencies. No need
134
- to install peer dependencies separately.
135
-
136
- **For Ruby projects:**
137
-
138
- ```ruby
139
- # Gemfile
140
- gem "skyltmax_config"
141
- ```
142
-
143
- ### Basic Usage
144
-
145
- **ESLint:**
146
-
147
- ```javascript
148
- // eslint.config.js
149
- import { config as defaultConfig } from "@skyltmax/config/eslint"
150
-
151
- /** @type {import("eslint").Linter.Config[]} */
152
- export default [...defaultConfig]
153
- ```
154
-
155
- **Prettier:**
156
-
157
- ```json
158
- // package.json
159
- {
160
- "prettier": "@skyltmax/config/prettier"
161
- }
162
- ```
163
-
164
- **TypeScript:**
165
-
166
- ```json
167
- // tsconfig.json
168
- {
169
- "extends": ["@skyltmax/config/typescript"],
170
- "include": ["**/*.ts", "**/*.tsx"],
171
- "compilerOptions": {
172
- "paths": {
173
- "#app/*": ["./app/*"]
174
- }
175
- }
176
- }
177
- ```
178
-
179
- **Rubocop:**
180
-
181
- ```yaml
182
- # .rubocop.yml
183
- inherit_gem:
184
- skyltmax_config:
185
- - rubocop.yml
186
- - rubocop.rails.yml
187
- ```
188
-
189
- ### Development Setup
190
-
191
- ```bash
192
- # Install dependencies
193
- pnpm install
194
-
195
- # Run validation
196
- pnpm validate
197
-
198
- # Run individual checks
199
- pnpm format # Format with Prettier
200
- pnpm lint # Lint with ESLint
201
- pnpm typecheck # Type check with TypeScript
202
- ```
203
-
204
- ---
205
-
206
- ## Development
207
-
208
- ### File Structure
209
-
210
- **JavaScript/TypeScript Files:**
211
-
212
- - `eslint.js` - ESLint configuration export with all rules and plugins
213
- - `prettier.js` - Prettier configuration with formatting options
214
- - `typescript.json` - TypeScript compiler configuration
215
- - `reset.d.ts` - TypeScript type reset declarations
216
- - `index.js` - Package entry point
217
- - `eslint.config.js` - Example ESLint configuration usage
218
-
219
- **Ruby Files:**
220
-
221
- - `lib/skyltmax_config.rb` - Ruby gem entry point
222
- - `rubocop.yml` - Base Rubocop configuration
223
- - `rubocop.rails.yml` - Rails-specific Rubocop rules
224
- - `skyltmax_config.gemspec` - Gem specification
225
- - `Gemfile` - Ruby dependencies
226
- - `Rakefile` - Ruby build tasks
227
-
228
- ### ESLint Configuration (`eslint.js`)
229
-
230
- The ESLint configuration uses the flat config format (ESLint 9+) and exports an array of configuration objects:
231
-
232
- ```javascript
233
- export const config = [
234
- // Ignore patterns
235
- { ignores: ["**/node_modules/**", "**/build/**", ...] },
236
-
237
- // Base configs
238
- ...(await import("@eslint/js")).default.configs.recommended,
239
- ...(await import("eslint-plugin-prettier/recommended")).default,
240
-
241
- // Import rules for all files
242
- { plugins: { import: ... }, rules: { "import/order": ... } },
243
-
244
- // React/JSX specific rules
245
- { files: ["**/*.tsx", "**/*.jsx"], plugins: { react: ... } },
246
-
247
- // TypeScript specific rules
248
- ...(await import("typescript-eslint")).default.config({ files: ["**/*.ts?(x)"] }),
249
-
250
- // Test file rules (Vitest, Testing Library, Jest DOM)
251
- { files: testFiles, plugins: { vitest: ... } },
252
- ]
253
- ```
254
-
255
- **Key Features:**
256
-
257
- - React and React Hooks support
258
- - JSX accessibility rules
259
- - TypeScript type-aware linting
260
- - Import ordering and deduplication
261
- - Vitest test file support
262
- - Testing Library rules
263
- - Jest DOM assertions
264
-
265
- **Common Rules:**
266
-
267
- - `import/order` - Alphabetized, grouped imports
268
- - `import/no-duplicates` - Prevent duplicate imports with inline types
269
- - `@typescript-eslint/consistent-type-imports` - Prefer `type` imports
270
- - `react/jsx-no-leaked-render` - Prevent leaked renders in JSX
271
- - `no-warning-comments` - Disallow FIXME comments
272
-
273
- ### Prettier Configuration (`prettier.js`)
274
-
275
- The Prettier config emphasizes readability and consistency:
276
-
277
- ```javascript
278
- export const config = {
279
- printWidth: 120, // Max line length
280
- semi: false, // No semicolons
281
- singleQuote: false, // Double quotes
282
- trailingComma: "es5", // Trailing commas where valid in ES5
283
- arrowParens: "avoid", // Omit parens when possible
284
- // ... other options
285
- plugins: ["prettier-plugin-tailwindcss"],
286
- }
287
- ```
288
-
289
- **Tailwind Support:**
290
-
291
- - Automatic class sorting via `prettier-plugin-tailwindcss`
292
- - Configurable class attributes and functions
293
- - Default: `className`, `class`, and `clsx`/`cn` functions
294
-
295
- ### TypeScript Configuration (`typescript.json`)
296
-
297
- Base TypeScript configuration for strict type checking:
298
-
299
- ```json
300
- {
301
- "compilerOptions": {
302
- "strict": true,
303
- "esModuleInterop": true,
304
- "skipLibCheck": true,
305
- "moduleResolution": "Bundler",
306
- "resolveJsonModule": true,
307
- "isolatedModules": true,
308
- "jsx": "react-jsx"
309
- // ... other strict options
310
- }
311
- }
312
- ```
313
-
314
- **TypeScript Reset (`reset.d.ts`):**
315
-
316
- - Imports `@total-typescript/ts-reset`
317
- - Provides better type definitions for common JS APIs
318
- - Fixes issues with `Array.includes`, `JSON.parse`, `fetch`, etc.
319
-
320
- ### Rubocop Configuration
321
-
322
- **Base Config (`rubocop.yml`):**
323
-
324
- - Strict Ruby style enforcement
325
- - Performance optimizations
326
- - Disabled cops that conflict with modern Ruby style
327
-
328
- **Rails Config (`rubocop.rails.yml`):**
329
-
330
- - Rails-specific linting rules
331
- - Database conventions
332
- - ActiveRecord best practices
333
-
334
- ### TypeScript Conventions
335
-
336
- **Exports:**
337
-
338
- - Use named exports for configurations
339
- - Provide default export for backward compatibility
340
- - Example: `export const config = {...}; export default config;`
341
-
342
- **Imports:**
343
-
344
- - Use dynamic imports for ESLint plugins (required for flat config)
345
- - Example: `(await import("eslint-plugin-react")).default`
346
-
347
- **Code Style:**
348
-
349
- - Follow configured Prettier settings
350
- - Max line length: 120 characters
351
- - No semicolons
352
- - Double quotes for strings
353
- - Trailing commas in ES5 contexts
354
-
355
- ### Patterns
356
-
357
- **Configuration Pattern:** All configuration files follow a similar pattern:
358
-
359
- 1. Define constants (severity levels, file patterns)
360
- 2. Export configuration object/array
361
- 3. Provide default export for compatibility
362
- 4. Add JSDoc type annotations for IDE support
363
-
364
- Example:
365
-
366
- ```javascript
367
- /** @type {import("prettier").Options} */
368
- export const config = {
369
- /* ... */
370
- }
371
- export default config
372
- ```
373
-
374
- ### Making Changes
375
-
376
- When updating configurations:
377
-
378
- 1. **ESLint:** Update `eslint.js` with new rules/plugins
379
- 2. **Prettier:** Update `prettier.js` formatting options
380
- 3. **TypeScript:** Update `typescript.json` compiler options
381
- 4. **Rubocop:** Update `rubocop.yml` or `rubocop.rails.yml`
382
- 5. **Version:** Bump version in both `package.json` AND `skyltmax_config.gemspec`
383
- 6. **Changelog:** Document changes in `CHANGELOG.md`
384
- 7. **Test:** Run `pnpm validate` to ensure configs work
385
-
386
- ---
387
-
388
- ## Testing
389
-
390
- This package **does not include automated tests** as it primarily provides configuration files. Testing is done by:
391
-
392
- 1. **Using the configs in real projects** - The configurations are dogfooded
393
- 2. **Manual validation** - `pnpm validate` checks formatting, linting, and type-checking
394
- 3. **CI/CD validation** - GitHub Actions verify the package structure
395
-
396
- ### Validation Process
397
-
398
- **Run all checks:**
399
-
400
- ```bash
401
- pnpm validate
402
- ```
403
-
404
- This runs:
405
-
406
- - `pnpm format` - Prettier formatting
407
- - `pnpm lint` - ESLint validation
408
- - `pnpm typecheck` - TypeScript compilation
409
-
410
- **Individual checks:**
411
-
412
- ```bash
413
- pnpm format # Auto-format all files
414
- pnpm lint # Check ESLint rules
415
- pnpm typecheck # Verify TypeScript types
416
- ```
417
-
418
- ### Testing Configuration Changes
419
-
420
- When modifying configurations:
421
-
422
- 1. **Test in a real project:**
423
- - Link the package locally: `pnpm link /path/to/config`
424
- - Verify ESLint runs without errors
425
- - Check Prettier formats correctly
426
- - Ensure TypeScript compiles
427
-
428
- 2. **Check backward compatibility:**
429
- - Existing projects should not break
430
- - New rules should be additive or opt-in
431
- - Document breaking changes in CHANGELOG
432
-
433
- 3. **Validate exports:**
434
- - Ensure all exports work: `import { config } from "@skyltmax/config/eslint"`
435
- - Check both named and default exports
436
- - Verify TypeScript definitions are correct
437
-
438
- ### Rubocop Testing
439
-
440
- For Ruby configurations:
441
-
442
- ```bash
443
- # Test Rubocop configs locally
444
- bundle exec rubocop
445
-
446
- # Test with specific config
447
- bundle exec rubocop --config rubocop.yml
448
- bundle exec rubocop --config rubocop.rails.yml
449
- ```
450
-
451
- ### Continuous Integration
452
-
453
- The package uses GitHub Actions for CI/CD with two workflows:
454
-
455
- **CI Workflow (`.github/workflows/ci.yml`)** - Runs on PRs and pushes to main:
456
-
457
- 1. **Validate JavaScript/TypeScript configs:**
458
- - Runs `pnpm validate` (dogfooding - lints/formats/typechecks itself)
459
- - Ensures ESLint, Prettier, and TypeScript configs work correctly
460
-
461
- 2. **Validate Ruby configs:**
462
- - Runs `bundle exec rubocop` (dogfooding - validates Rubocop configs)
463
-
464
- 3. **Version sync check:**
465
- - Verifies `package.json` and `lib/skyltmax_config/version.rb` versions match
466
- - Prevents version drift between npm and gem
467
-
468
- 4. **Package installation test:**
469
- - Packs the package with `pnpm pack`
470
- - Installs in a test project
471
- - Verifies all exports work (ESLint, Prettier, TypeScript, reset.d.ts)
472
-
473
- **Release Workflow (`.github/workflows/release.yml`)** - Publishes on GitHub Release:
474
-
475
- 1. Verifies tag version matches both package.json and version.rb
476
- 2. Publishes npm package with provenance (trusted publishing)
477
- 3. Publishes RubyGems gem (trusted publishing)
478
-
479
- **Key CI principle:** Dogfooding is the primary validation strategy. The package validates itself using its own
480
- configurations, which ensures the configs are functional and catches issues early.
481
-
482
- ---
483
-
484
- ## Configuration
485
-
486
- ### Package Structure
487
-
488
- This package uses a dual-publishing approach:
489
-
490
- **NPM Package (`@skyltmax/config`):**
491
-
492
- - Main entry: `index.js`
493
- - Exports: `./prettier`, `./typescript`, `./eslint`, `./reset.d.ts`
494
- - Version must match gemspec version
495
-
496
- **Ruby Gem (`skyltmax_config`):**
497
-
498
- - Entry point: `lib/skyltmax_config.rb`
499
- - Provides Rubocop configurations
500
- - Version must match package.json version
501
-
502
- ### Dependency Management
503
-
504
- This package uses **peer dependencies** to provide all required tooling while ensuring proper editor/IDE discovery:
505
-
506
- **Why Peer Dependencies?**
507
-
508
- 1. **Editor Discovery:** Tools like VSCode, WebStorm, and others look for `prettier`, `eslint`, and `typescript` in the
509
- project's root `node_modules`. When bundled as regular dependencies, they end up in
510
- `node_modules/@skyltmax/config/node_modules`, which editors cannot find.
511
-
512
- 2. **Automatic Installation:** Modern package managers with `autoInstallPeers` enabled (pnpm's default, npm 7+
513
- configurable) automatically install peer dependencies, so users get a "single install" experience.
514
-
515
- 3. **Hoisting:** Peer dependencies are hoisted to the root `node_modules`, making them discoverable by all tools and
516
- editors.
517
-
518
- 4. **Version Control:** This package controls the **exact** versions (no semver ranges) to ensure all consuming projects
519
- get identical tool versions for reproducible linting/formatting/type-checking.
520
-
521
- **Structure:**
522
-
523
- - **peerDependencies:** All ESLint, Prettier, TypeScript tools and plugins with **exact versions** (no semver ranges)
524
- - **devDependencies:** Only dev-specific tools (`@types/react`, `npm-run-all`, `react`) - peer dependencies are
525
- auto-installed by pnpm for local development
526
-
527
- **All tooling (declared as peer dependencies with exact versions):**
528
-
529
- - **ESLint & Core:** `eslint`, `@eslint/js`, `typescript-eslint`
530
- - **TypeScript ESLint:** `@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser`, `@typescript-eslint/utils`
531
- - **Prettier:** `prettier`, `eslint-config-prettier`, `eslint-plugin-prettier`, `prettier-plugin-tailwindcss`
532
- - **TypeScript:** `typescript`, `@total-typescript/ts-reset`, `tslib`
533
- - **Plugins:** `eslint-plugin-import-x`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `eslint-plugin-jsx-a11y`
534
- - **Testing:** `@vitest/eslint-plugin`, `eslint-plugin-testing-library`, `eslint-plugin-jest-dom`
535
- - **Utilities:** `globals`
536
-
537
- **Benefits:**
538
-
539
- **Benefits:**
540
-
541
- - ✅ **Version control:** Consuming projects get consistent, tested versions
542
- - ✅ **Simplified setup:** Single `npm install @skyltmax/config` gets everything (with autoInstallPeers enabled)
543
- - ✅ **No version conflicts:** This package manages compatibility between tools
544
- - ✅ **Updates centralized:** Bump versions here, all projects benefit
545
- - ✅ **Editor compatibility:** Tools are hoisted to root `node_modules/` for VSCode, WebStorm, etc.
546
-
547
- **Note:** pnpm enables `autoInstallPeers` by default. For npm 7+, you may need to enable it with
548
- `npm config set auto-install-peers true` or install peers manually if warnings appear.
549
-
550
- **DevDependencies (development only):**
551
-
552
- - `@types/react` - Type definitions for development
553
- - `npm-run-all` - Script runner
554
- - `react` - For testing React-related rules
555
-
556
- **Files Included in Published Package:**
557
-
558
- The `files` field specifies what gets published to npm:
559
-
560
- - `*.js`, `*.json`, `*.d.ts`, `*.yml` - Configuration files
561
- - `lib/**` - Ruby gem files
562
- - `README.md`, `LICENSE` - Documentation
563
-
564
- ### Version Management
565
-
566
- **Critical:** Versions must be kept in sync across `package.json` and `lib/skyltmax_config/version.rb`.
567
-
568
- The gemspec automatically reads the version from `lib/skyltmax_config/version.rb`, so you only need to update two files:
569
-
570
- ```json
571
- // package.json
572
- {
573
- "version": "0.0.5"
574
- }
575
- ```
576
-
577
- ```ruby
578
- # lib/skyltmax_config/version.rb
579
- module SkyltmaxConfig
580
- VERSION = "0.0.5"
581
- end
582
- ```
583
-
584
- **Note:** The `skyltmax_config.gemspec` uses `SkyltmaxConfig::VERSION` and does not need manual version updates.
585
-
586
- ### Publishing Process
587
-
588
- Releases are automated via GitHub Actions when a release is published:
589
-
590
- 1. **Update versions:**
591
- - `package.json`: `"version": "x.y.z"`
592
- - `lib/skyltmax_config/version.rb`: `VERSION = "x.y.z"`
593
-
594
- 2. **Update changelog:**
595
- - Add changes to `CHANGELOG.md`
596
-
597
- 3. **Commit and push:**
598
-
599
- ```bash
600
- git add package.json lib/skyltmax_config/version.rb CHANGELOG.md
601
- git commit -m "chore: bump version to x.y.z"
602
- git push
603
- ```
604
-
605
- 4. **Create release:**
606
- - Create Git tag: `vX.Y.Z`
607
- - Create GitHub Release for that tag
608
- - Or run "Publish release" workflow manually
609
-
610
- **The workflow:**
611
-
612
- - Verifies tag version matches both package.json and version.rb
613
- - Publishes npm package with provenance
614
- - Builds and pushes Ruby gem to RubyGems
615
-
616
- ### Adding New Configurations
617
-
618
- When adding new linting rules or formatting options:
619
-
620
- 1. **Add to appropriate file:**
621
- - ESLint rules → `eslint.js`
622
- - Prettier options → `prettier.js`
623
- - TypeScript options → `typescript.json`
624
- - Rubocop rules → `rubocop.yml` or `rubocop.rails.yml`
625
-
626
- 2. **Document in README.md:**
627
- - Add usage examples
628
- - List new features
629
- - Update configuration sections
630
-
631
- 3. **Update CHANGELOG.md:**
632
- - Document what changed
633
- - Note any breaking changes
634
- - Provide migration guidance if needed
635
-
636
- 4. **Test locally:**
637
- - Run `pnpm validate`
638
- - Test in a real project via `pnpm link`
639
-
640
- 5. **Update version:**
641
- - Bump both `package.json` and `skyltmax_config.gemspec`
642
- - Follow semantic versioning
643
-
644
- ### Backward Compatibility
645
-
646
- When making changes:
647
-
648
- - ✅ Add new optional configuration options
649
- - ✅ Add new rules as warnings first, then errors in next major
650
- - ✅ Provide sensible defaults for all options
651
- - ✅ Support both old and new usage patterns
652
- - ❌ Don't remove exports without major version bump
653
- - ❌ Don't change default behavior without documenting
654
- - ❌ Don't introduce breaking changes in minor/patch versions
655
-
656
- ### Export Structure
657
-
658
- The package exports are defined in `package.json`:
659
-
660
- ```json
661
- {
662
- "exports": {
663
- ".": "./index.js",
664
- "./prettier": "./prettier.js",
665
- "./typescript": "./typescript.json",
666
- "./reset.d.ts": "./reset.d.ts",
667
- "./eslint": "./eslint.js"
668
- }
669
- }
670
- ```
671
-
672
- All exports must:
673
-
674
- - Have valid file paths
675
- - Export both named and default exports (JS files)
676
- - Include proper JSDoc type annotations
677
- - Be documented in README.md