@schafevormfenster/eslint-config 0.0.8 → 0.0.10

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,6 @@
1
+
2
+ 
3
+ > @schafevormfenster/eslint-config@0.0.9 check /Users/jan-henrik.hempel/Projects/commons/packages/eslint-config
4
+ > echo 'eslint-config: no build required'
5
+
6
+ eslint-config: no build required
@@ -0,0 +1,323 @@
1
+ # Contributing to @schafevormfenster/eslint-config
2
+
3
+ Thank you for your interest in contributing to our ESLint configuration hub! This document describes the package structure, maintenance responsibilities, and how to contribute effectively.
4
+
5
+ ## Package Overview
6
+
7
+ This package serves as the **Configuration Hub** for ESLint across the `@schafevormfenster` monorepo. It orchestrates community standards (Next.js, TypeScript, Prettier) and integrates our internal custom rules from `@schafevormfenster/eslint-plugin`.
8
+
9
+ ### Key Responsibilities
10
+
11
+ - **Standardization**: Ensures all projects follow the same coding standards
12
+ - **Simplification**: Bundles multiple ESLint plugins into composable configurations
13
+ - **Modularity**: Provides pre-configured rule sets for different tech stacks
14
+
15
+ ## Package Structure
16
+
17
+ ```
18
+ packages/eslint-config/
19
+ ├── index.js # Default base configuration
20
+ ├── base.js # Minimal plugin registration
21
+ ├── next.js # Next.js + React + Hooks
22
+ ├── library.js # Pure TypeScript libraries
23
+ ├── logging.js # Logging standards
24
+ ├── architecture.js # File naming and structure
25
+ ├── rest.js # REST API patterns
26
+ ├── caching.js # Caching strategies
27
+ ├── stack.js # Technology choices
28
+ ├── playwright.js # E2E testing
29
+ ├── vitest.js # Unit testing
30
+ ├── integration.js # Integration testing
31
+ ├── docs/
32
+ │ └── RULES_REFERENCE.md # Comprehensive rule documentation
33
+ ├── README.md # Package overview and usage
34
+ ├── CONTRIBUTING.md # This file
35
+ └── package.json # Dependencies and exports
36
+ ```
37
+
38
+ ## Modular Configuration Files
39
+
40
+ Each configuration file exports a Flat Config array that can be composed in consuming applications:
41
+
42
+ - **Base configurations** (`index.js`, `base.js`, `next.js`, `library.js`): Provide foundation rules from community plugins
43
+ - **Domain configurations** (`logging.js`, `architecture.js`, `rest.js`, etc.): Add domain-specific custom rules
44
+ - **Testing configurations** (`playwright.js`, `vitest.js`, `integration.js`): Apply testing-specific rules
45
+
46
+ ## Documentation Maintenance
47
+
48
+ ### Critical: Keeping RULES_REFERENCE.md in Sync
49
+
50
+ **⚠️ IMPORTANT**: The `docs/RULES_REFERENCE.md` file contains a comprehensive mapping of all rules to their configurations. This documentation **MUST** be updated whenever rules change in `@schafevormfenster/eslint-plugin`.
51
+
52
+ #### When to Update RULES_REFERENCE.md
53
+
54
+ Update the reference documentation when:
55
+
56
+ 1. **New rules are added** to `@schafevormfenster/eslint-plugin`
57
+ - Add the rule to the appropriate configuration table
58
+ - Update rule counts if displayed
59
+ - Add to the "Key rules" section if significant
60
+
61
+ 2. **Rules are removed** from `@schafevormfenster/eslint-plugin`
62
+ - Remove the rule from configuration tables
63
+ - Update any examples that referenced the rule
64
+
65
+ 3. **Rule severity changes** (error ↔ warn)
66
+ - Update the severity column in the configuration tables
67
+ - Verify the change is reflected in all relevant sections
68
+
69
+ 4. **Rules are moved** between configurations
70
+ - Remove from old configuration table
71
+ - Add to new configuration table
72
+ - Update any explanatory text
73
+
74
+ 5. **New configurations are added** to this package
75
+ - Add a new section explaining the configuration's purpose
76
+ - Create a rule table for the configuration
77
+ - Add usage examples
78
+ - Update the configuration list in README.md
79
+
80
+ #### How to Update RULES_REFERENCE.md
81
+
82
+ 1. **Check the source of truth**: Review `@schafevormfenster/eslint-plugin/index.js` to see the current rule definitions:
83
+ ```javascript
84
+ const loggingRules = {
85
+ [`${pluginName}/enforce-log-before-throw`]: "error",
86
+ // ... other rules
87
+ };
88
+ ```
89
+
90
+ 2. **Update the tables**: Locate the relevant configuration section in RULES_REFERENCE.md and update the rule table:
91
+ ```markdown
92
+ | Rule | Severity | Description |
93
+ |------|----------|-------------|
94
+ | `new-rule-name` | error | Description of what the rule does |
95
+ ```
96
+
97
+ 3. **Update counts and summaries**: If rule counts are mentioned, update them
98
+
99
+ 4. **Test the documentation**: Verify all links work and paths are correct
100
+
101
+ 5. **Cross-reference**: Ensure the README.md configuration list matches RULES_REFERENCE.md
102
+
103
+ #### Automation Opportunity
104
+
105
+ Currently, this synchronization is **manual**. Future improvements could include:
106
+ - Script to extract rules from `@schafevormfenster/eslint-plugin/index.js`
107
+ - Automated table generation
108
+ - CI check to ensure documentation is in sync
109
+
110
+ ## Making Changes
111
+
112
+ ### Adding a New Configuration
113
+
114
+ 1. **Create the configuration file** (e.g., `new-domain.js`):
115
+ ```javascript
116
+ import svfPlugin from "@schafevormfenster/eslint-plugin";
117
+
118
+ export default [
119
+ svfPlugin.configs.base,
120
+ svfPlugin.configs["new-domain"]
121
+ ];
122
+ ```
123
+
124
+ 2. **Add to package.json exports**:
125
+ ```json
126
+ {
127
+ "exports": {
128
+ "./new-domain": "./new-domain.js"
129
+ }
130
+ }
131
+ ```
132
+
133
+ 3. **Update README.md**: Add to the "Available Configurations" list
134
+
135
+ 4. **Update RULES_REFERENCE.md**:
136
+ - Add a new section explaining the configuration
137
+ - Create a rule table
138
+ - Add usage examples
139
+ - Update the Quick Navigation links
140
+
141
+ ### Updating Existing Configurations
142
+
143
+ 1. **Modify the configuration file** as needed
144
+
145
+ 2. **Update documentation** if:
146
+ - The purpose changes
147
+ - Files/globs change
148
+ - Dependencies change
149
+ - Usage patterns change
150
+
151
+ 3. **Test in a consuming app** to ensure it works correctly
152
+
153
+ ### Updating Dependencies
154
+
155
+ When updating community plugin versions:
156
+
157
+ 1. **Test compatibility** with consuming applications
158
+ 2. **Update package.json** version constraints
159
+ 3. **Document breaking changes** if any
160
+ 4. **Update examples** if plugin usage changed
161
+
162
+ ## Development Workflow
163
+
164
+ ### Local Development
165
+
166
+ ```bash
167
+ # This package has no build step
168
+ cd packages/eslint-config
169
+
170
+ # Check that everything is valid (no-op currently)
171
+ pnpm run check
172
+
173
+ # Test in a consuming app
174
+ cd /path/to/consuming-app
175
+ pnpm link ../../packages/eslint-config
176
+ ```
177
+
178
+ ### Testing Changes
179
+
180
+ To test configuration changes:
181
+
182
+ 1. Make changes to configuration files
183
+ 2. Link the package to a consuming application
184
+ 3. Run the consuming app's linter: `pnpm lint`
185
+ 4. Verify rules are applied correctly
186
+ 5. Check that there are no unexpected errors
187
+
188
+ ### Validation Checklist
189
+
190
+ Before submitting changes:
191
+
192
+ - [ ] All configuration files are valid JavaScript/ESM
193
+ - [ ] `package.json` exports are correct
194
+ - [ ] README.md is updated with any new configurations
195
+ - [ ] RULES_REFERENCE.md is updated (if rules changed)
196
+ - [ ] Changes tested in at least one consuming application
197
+ - [ ] No unintended side effects on existing configurations
198
+
199
+ ## Release Process
200
+
201
+ 1. **Make changes** to configuration files or documentation
202
+ 2. **Update RULES_REFERENCE.md** if rules changed in eslint-plugin
203
+ 3. **Test thoroughly** in consuming applications
204
+ 4. **Version bump** following semantic versioning:
205
+ - **Patch** (0.0.x): Documentation updates, bug fixes
206
+ - **Minor** (0.x.0): New configurations, new rules (backward compatible)
207
+ - **Major** (x.0.0): Breaking changes to existing configurations
208
+ 5. **Update changelog** if maintained
209
+ 6. **Publish** using `pnpm run release` or `../../scripts/smart-publish.sh`
210
+
211
+ ## Documentation Standards
212
+
213
+ ### README.md
214
+
215
+ - Keep it concise and focused on usage
216
+ - Link to RULES_REFERENCE.md for detailed information
217
+ - Include basic examples
218
+ - List all available configurations
219
+
220
+ ### RULES_REFERENCE.md
221
+
222
+ - **Comprehensive** but **organized** - use sections and tables
223
+ - **Accurate** - must reflect actual rule implementations
224
+ - **Helpful** - include usage examples and guidance
225
+ - **Up-to-date** - synchronize with eslint-plugin changes
226
+ - **Searchable** - use clear headings and consistent terminology
227
+
228
+ ### Writing Style
229
+
230
+ - **Clear and direct** - developers should understand quickly
231
+ - **Example-driven** - show real usage patterns
232
+ - **Consistent** - use the same terminology across all documentation
233
+ - **Accessible** - explain concepts, don't assume knowledge
234
+
235
+ ## Relationship with @schafevormfenster/eslint-plugin
236
+
237
+ This package **re-exports** configurations from `@schafevormfenster/eslint-plugin`. Understanding this relationship is crucial:
238
+
239
+ ### Dependency Flow
240
+
241
+ ```
242
+ @schafevormfenster/eslint-plugin
243
+ ↓ (defines rules and base configs)
244
+ @schafevormfenster/eslint-config
245
+ ↓ (composes configs with community plugins)
246
+ Consuming Applications
247
+ ```
248
+
249
+ ### When Changes Happen in eslint-plugin
250
+
251
+ If `@schafevormfenster/eslint-plugin` changes:
252
+
253
+ 1. **New rules added**: Update RULES_REFERENCE.md tables
254
+ 2. **Rules removed**: Update RULES_REFERENCE.md tables
255
+ 3. **Severity changed**: Update RULES_REFERENCE.md tables
256
+ 4. **New config added**: Consider adding a new file here that exposes it
257
+ 5. **Breaking changes**: May require a major version bump here too
258
+
259
+ ### Staying in Sync
260
+
261
+ - Monitor changes to `@schafevormfenster/eslint-plugin`
262
+ - Review the plugin's changelog/commits regularly
263
+ - Update documentation proactively
264
+ - Test compatibility when plugin version updates
265
+
266
+ ## Common Tasks
267
+
268
+ ### Task: Add a New Configuration
269
+
270
+ ```bash
271
+ # 1. Create the config file
272
+ echo 'import svfPlugin from "@schafevormfenster/eslint-plugin";\n\nexport default [\n svfPlugin.configs.base,\n svfPlugin.configs["your-domain"]\n];' > your-domain.js
273
+
274
+ # 2. Add to package.json exports (manual edit required)
275
+
276
+ # 3. Update README.md (manual edit required)
277
+
278
+ # 4. Update RULES_REFERENCE.md (manual edit required)
279
+
280
+ # 5. Test in a consuming app
281
+ ```
282
+
283
+ ### Task: Sync with eslint-plugin Rule Changes
284
+
285
+ ```bash
286
+ # 1. Check what changed in eslint-plugin
287
+ cd ../eslint-plugin
288
+ git log --oneline -10
289
+ git diff HEAD~5 index.js # or appropriate commit range
290
+
291
+ # 2. Note the changes to rules (added, removed, severity changed)
292
+
293
+ # 3. Update RULES_REFERENCE.md in eslint-config
294
+ cd ../eslint-config
295
+ vim docs/RULES_REFERENCE.md # Update the relevant tables
296
+
297
+ # 4. Verify accuracy
298
+ grep "your-rule-name" docs/RULES_REFERENCE.md
299
+ ```
300
+
301
+ ### Task: Update Documentation Only
302
+
303
+ ```bash
304
+ # Edit the documentation
305
+ vim docs/RULES_REFERENCE.md
306
+ # or
307
+ vim README.md
308
+
309
+ # No build step needed - documentation is ready to commit
310
+ git add docs/RULES_REFERENCE.md README.md
311
+ git commit -m "docs: update rule reference for X"
312
+ ```
313
+
314
+ ## Questions and Support
315
+
316
+ - **For rule behavior**: See `@schafevormfenster/eslint-plugin` documentation
317
+ - **For configuration usage**: See README.md and RULES_REFERENCE.md
318
+ - **For contributing**: This file and the main repository CONTRIBUTING.md
319
+ - **For architecture questions**: Consult with the platform team
320
+
321
+ ## Code of Conduct
322
+
323
+ Please be respectful and constructive in all interactions. We're building tools to help our team write better code together.
package/README.md CHANGED
@@ -8,6 +8,16 @@ This package serves as the central **Configuration Hub** for ESLint across the `
8
8
  - **Simplicity**: Projects only need to install this one package instead of managing dozens of ESLint plugins and dependencies.
9
9
  - **Modularity**: Provides composable configurations for different tech stacks (Next.js, Library, Playwright, etc.).
10
10
 
11
+ ## Documentation
12
+
13
+ > **For detailed rule documentation, usage examples, and offline access patterns**, see [**RULES_REFERENCE.md**](docs/RULES_REFERENCE.md) or the [@schafevormfenster/eslint-plugin documentation](https://www.npmjs.com/package/@schafevormfenster/eslint-plugin).
14
+
15
+ The RULES_REFERENCE guide includes:
16
+ - Complete mapping of all rules by configuration
17
+ - Path patterns to find documentation in node_modules (for offline/isolated environments)
18
+ - Detailed explanations of when and how to use each modular config
19
+ - Guidance for AI coding agents on referencing documentation
20
+
11
21
  ## General Approach
12
22
 
13
23
  This package exports **Flat Config** arrays that can be easily combined in your project's `eslint.config.mjs`. It wraps:
@@ -45,7 +55,10 @@ export default defineConfig([
45
55
 
46
56
  ### Available Configurations
47
57
 
58
+ > For detailed information about each configuration's purpose, rules, and when to use them, see [RULES_REFERENCE.md](docs/RULES_REFERENCE.md).
59
+
48
60
  - **`@schafevormfenster/eslint-config`** (default): Base TypeScript & Node.js rules.
61
+ - **`@schafevormfenster/eslint-config/base`**: Minimal plugin registration only (advanced usage).
49
62
  - **`@schafevormfenster/eslint-config/next`**: For Next.js applications (includes React & Hooks).
50
63
  - **`@schafevormfenster/eslint-config/library`**: For pure TypeScript libraries.
51
64
  - **`@schafevormfenster/eslint-config/logging`**: Enforces internal logging standards.
@@ -55,3 +68,4 @@ export default defineConfig([
55
68
  - **`@schafevormfenster/eslint-config/stack`**: Enforces tech stack constraints (e.g. forbidden imports).
56
69
  - **`@schafevormfenster/eslint-config/playwright`**: For E2E test suites.
57
70
  - **`@schafevormfenster/eslint-config/vitest`**: For Unit test suites.
71
+ - **`@schafevormfenster/eslint-config/integration`**: For Integration test suites.
@@ -0,0 +1,418 @@
1
+ # ESLint Rules Reference
2
+
3
+ This document provides a comprehensive reference for all ESLint configurations available in `@schafevormfenster/eslint-config`, including how to find detailed rule documentation both online and offline.
4
+
5
+ ## Quick Navigation
6
+
7
+ - [Finding Rule Documentation](#finding-rule-documentation)
8
+ - [Modular Configurations](#modular-configurations)
9
+ - [Rules by Configuration](#rules-by-configuration)
10
+ - [Usage Examples](#usage-examples)
11
+
12
+ ## Finding Rule Documentation
13
+
14
+ ### Online Documentation
15
+
16
+ For the most up-to-date documentation of custom rules, visit:
17
+ - **npm package**: https://www.npmjs.com/package/@schafevormfenster/eslint-plugin
18
+ - **GitHub repository**: https://github.com/schafe-vorm-fenster/commons/tree/main/packages/eslint-plugin
19
+
20
+ ### Offline/Local Documentation
21
+
22
+ When working in isolated or offline environments, you can find rule documentation in your `node_modules`:
23
+
24
+ ```bash
25
+ # Custom rules documentation (from @schafevormfenster/eslint-plugin)
26
+ node_modules/.pnpm/@schafevormfenster+eslint-plugin@*/node_modules/@schafevormfenster/eslint-plugin/docs/rules/
27
+
28
+ # If using npm or yarn instead of pnpm
29
+ node_modules/@schafevormfenster/eslint-plugin/docs/rules/
30
+
31
+ # Example: View documentation for a specific rule
32
+ cat node_modules/@schafevormfenster/eslint-plugin/docs/rules/enforce-log-before-throw.md
33
+ ```
34
+
35
+ ### Documentation Structure in node_modules
36
+
37
+ ```
38
+ @schafevormfenster/eslint-plugin/
39
+ ├── docs/
40
+ │ ├── instructions/ # Coding guidelines and best practices
41
+ │ │ ├── logging-guide.md
42
+ │ │ ├── rest-service-design-guide.md
43
+ │ │ ├── caching-guide.md
44
+ │ │ ├── testing-standards-guide.md
45
+ │ │ └── ...
46
+ │ └── rules/ # Individual rule documentation
47
+ │ ├── enforce-log-before-throw.md
48
+ │ ├── no-sensitive-log-keys.md
49
+ │ ├── enforce-api-route-structure.md
50
+ │ └── ...
51
+ └── README.md # Full overview and rule catalog
52
+ ```
53
+
54
+ ## Modular Configurations
55
+
56
+ `@schafevormfenster/eslint-config` provides several modular configurations that you can mix and match based on your project's needs.
57
+
58
+ ### Base Configurations
59
+
60
+ #### `@schafevormfenster/eslint-config` (default)
61
+ **Purpose**: Base TypeScript and Node.js rules for all projects
62
+ **Includes**: TypeScript ESLint, import ordering, SonarJS code quality, Unicorn best practices, Zod schema validation
63
+ **Use when**: Setting up any TypeScript project in the monorepo
64
+
65
+ #### `@schafevormfenster/eslint-config/base`
66
+ **Purpose**: Minimal base configuration that only registers the custom plugin
67
+ **Includes**: Only the plugin registration from `@schafevormfenster/eslint-plugin`
68
+ **Use when**: You want to manually configure rules without any presets (advanced usage)
69
+
70
+ #### `@schafevormfenster/eslint-config/library`
71
+ **Purpose**: Configuration for pure TypeScript libraries (non-UI packages)
72
+ **Includes**: Base config plus library-specific rules
73
+ **Use when**: Building reusable npm packages without UI components
74
+
75
+ #### `@schafevormfenster/eslint-config/next`
76
+ **Purpose**: Configuration for Next.js applications
77
+ **Includes**: Base config + Next.js rules + React + React Hooks
78
+ **Use when**: Building Next.js web applications
79
+
80
+ ### Domain-Specific Configurations
81
+
82
+ These configurations enforce domain-specific patterns and are designed to be used **alongside** base configurations.
83
+
84
+ #### `@schafevormfenster/eslint-config/logging`
85
+ **Purpose**: Enforces structured logging standards with Pino
86
+ **Key rules**:
87
+ - Must log before throwing errors
88
+ - Enforce structured logging (context object + message)
89
+ - Prevent logging sensitive data (passwords, tokens, etc.)
90
+ - Require proper log levels
91
+ - Use custom logger instead of console
92
+
93
+ **Use when**: Your project uses the `@schafevormfenster/logging` package
94
+
95
+ **Related documentation**: See `docs/instructions/logging-guide.md` in `@schafevormfenster/eslint-plugin`
96
+
97
+ #### `@schafevormfenster/eslint-config/architecture`
98
+ **Purpose**: Enforces architectural patterns and file organization
99
+ **Key rules**:
100
+ - Kebab-case file naming with semantic suffixes
101
+ - Folder structure conventions (src/app, src/clients, src/services, etc.)
102
+ - Layer dependency rules (clients → services → coordinators)
103
+ - One function per file
104
+ - No re-export files
105
+
106
+ **Use when**: You want to enforce consistent project structure
107
+
108
+ **Related documentation**: See `docs/instructions/client-service-coordinator-guide.md` in `@schafevormfenster/eslint-plugin`
109
+
110
+ #### `@schafevormfenster/eslint-config/rest`
111
+ **Purpose**: Enforces REST API design standards
112
+ **Key rules**:
113
+ - API route structure (requires route.test.ts, *.contract.ts, *.schema.ts)
114
+ - Zod schema type exports
115
+ - Token validation in API paths
116
+ - Schema extension best practices
117
+
118
+ **Use when**: Building REST API endpoints
119
+
120
+ **Related documentation**: See `docs/instructions/rest-service-design-guide.md` in `@schafevormfenster/eslint-plugin`
121
+
122
+ #### `@schafevormfenster/eslint-config/caching`
123
+ **Purpose**: Enforces correct caching strategies
124
+ **Key rules**:
125
+ - No "use cache" directive in POST handlers
126
+ - Semantic cache headers in GET handlers
127
+
128
+ **Use when**: Implementing caching in Next.js applications
129
+
130
+ **Related documentation**: See `docs/instructions/caching-guide.md` in `@schafevormfenster/eslint-plugin`
131
+
132
+ #### `@schafevormfenster/eslint-config/stack`
133
+ **Purpose**: Enforces technology stack choices
134
+ **Key rules**:
135
+ - Prevents use of forbidden imports (libraries with preferred alternatives)
136
+
137
+ **Use when**: You want to enforce specific library choices across the project
138
+
139
+ ### Testing Configurations
140
+
141
+ These configurations apply only to test files and should be added **after** your main configuration.
142
+
143
+ #### `@schafevormfenster/eslint-config/playwright`
144
+ **Purpose**: Configuration for Playwright E2E tests
145
+ **Includes**: Playwright plugin + custom E2E testing rules
146
+ **Key rules**:
147
+ - Enforce `*.spec.ts` file naming for E2E tests
148
+ - Environment variable access restrictions (APITEST_* prefix)
149
+ - No environment variable preservation in tests
150
+ - Require describe() wrappers for test organization
151
+ - Enforce meaningful test descriptions
152
+ - Suggest test categorization (Happy Path → Error → Edge Cases)
153
+
154
+ **Use when**: Writing end-to-end tests with Playwright
155
+
156
+ **Applies to**: `**/e2e/**`, `**/*.spec.ts` files
157
+
158
+ **Related documentation**: See `docs/instructions/testing-standards-guide.md` and `docs/instructions/rest-api-e2e-testing-guide.md` in `@schafevormfenster/eslint-plugin`
159
+
160
+ #### `@schafevormfenster/eslint-config/vitest`
161
+ **Purpose**: Configuration for Vitest unit and integration tests
162
+ **Includes**: Vitest plugin + custom testing rules
163
+ **Key rules**:
164
+ - Enforce `*.test.ts` file naming
165
+ - Prefer loose error matching (regex over exact strings)
166
+ - Require environment setup in beforeEach
167
+ - No environment variable preservation
168
+ - Require describe() wrappers for test organization
169
+ - Enforce meaningful test descriptions
170
+ - Suggest test categorization (Happy Path → Error → Edge Cases)
171
+
172
+ **Use when**: Writing unit or integration tests with Vitest
173
+
174
+ **Applies to**: `**/*.test.ts` files
175
+
176
+ **Related documentation**: See `docs/instructions/testing-standards-guide.md` and `docs/instructions/unit-test-env-vars-guide.md` in `@schafevormfenster/eslint-plugin`
177
+
178
+ #### `@schafevormfenster/eslint-config/integration`
179
+ **Purpose**: Configuration for Vitest integration tests
180
+ **Includes**: Custom integration testing rules
181
+ **Key rules**:
182
+ - Enforce `*.test.ts` file naming
183
+ - Prefer loose error matching (regex over exact strings)
184
+ - No environment variable preservation
185
+ - Require environment setup in beforeEach
186
+ - Require describe() wrappers for test organization
187
+ - Enforce meaningful test descriptions
188
+ - Suggest test categorization (Happy Path → Error → Edge Cases)
189
+
190
+ **Use when**: Writing integration tests with Vitest (tests that involve multiple modules or external services)
191
+
192
+ **Applies to**: `**/*.test.ts` files
193
+
194
+ **Related documentation**: See `docs/instructions/testing-standards-guide.md` in `@schafevormfenster/eslint-plugin`
195
+
196
+ ## Rules by Configuration
197
+
198
+ ### Base Configuration Rules
199
+
200
+ The base configuration includes rules from these community plugins:
201
+
202
+ | Plugin | Source | Rules Count |
203
+ |--------|--------|-------------|
204
+ | TypeScript ESLint | `typescript-eslint` | ~50 recommended rules |
205
+ | Import | `eslint-plugin-import` | Import ordering, dependency validation |
206
+ | SonarJS | `eslint-plugin-sonarjs` | Code quality and complexity |
207
+ | Unicorn | `eslint-plugin-unicorn` | Best practices and modern patterns |
208
+ | Zod | `eslint-plugin-zod` | Zod schema validation |
209
+
210
+ ### Custom Rules by Domain
211
+
212
+ Below is a comprehensive mapping of custom rules (from `@schafevormfenster/eslint-plugin`) to their configurations:
213
+
214
+ #### Logging Rules (`@schafevormfenster/eslint-config/logging`)
215
+
216
+ | Rule | Severity | Description |
217
+ |------|----------|-------------|
218
+ | `enforce-log-before-throw` | error | Must log before throwing an error |
219
+ | `enforce-log-level-before-throw` | warn | Enforce appropriate log level before throwing |
220
+ | `prefer-custom-logger` | warn | Use custom logger instead of console |
221
+ | `enforce-get-logger-category` | error | getLogger must be called with a category string |
222
+ | `enforce-structured-logging` | error | Log calls must include context object + message |
223
+ | `no-raw-logging` | warn | Prevent logging raw objects without message |
224
+ | `require-error-in-log-error` | warn | log.error must include an error object |
225
+ | `no-sensitive-log-keys` | error | Prevent logging sensitive keys (password, token, etc.) |
226
+ | `no-unsafe-log-property-access` | warn | Prevent unsafe property access in log context |
227
+ | `no-redundant-normalize-error` | error | Don't call normalizeError() in log.error() |
228
+
229
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/enforce-log-before-throw.md` (and similar files)
230
+
231
+ #### Architecture Rules (`@schafevormfenster/eslint-config/architecture`)
232
+
233
+ | Rule | Severity | Description |
234
+ |------|----------|-------------|
235
+ | `enforce-file-naming` | warn | Enforce kebab-case with semantic suffixes |
236
+ | `enforce-folder-structure` | warn | Enforce src/ folder conventions |
237
+ | `one-function-per-file` | warn | Warn if file exports multiple named functions |
238
+ | `no-reexport-files` | warn | Prevent files that only re-export from other modules |
239
+ | `enforce-layer-dependencies` | error | Enforce architectural layer dependency rules |
240
+
241
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/enforce-file-naming.md` (and similar files)
242
+
243
+ #### REST Rules (`@schafevormfenster/eslint-config/rest`)
244
+
245
+ | Rule | Severity | Description |
246
+ |------|----------|-------------|
247
+ | `enforce-api-route-structure` | error | Require route.test.ts, *.contract.ts, *.schema.ts for API routes |
248
+ | `enforce-schema-type-export` | error | Export TypeScript types for all Zod schemas |
249
+ | `prefer-schema-extension` | warn | Reuse schemas with .extend() or .merge() |
250
+ | `enforce-token-in-path` | error | API routes must include [token] in path or validate params.token |
251
+
252
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/enforce-api-route-structure.md` (and similar files)
253
+
254
+ #### Caching Rules (`@schafevormfenster/eslint-config/caching`)
255
+
256
+ | Rule | Severity | Description |
257
+ |------|----------|-------------|
258
+ | `no-use-cache-in-post` | error | Forbid "use cache" directive in POST handlers |
259
+ | `enforce-semantic-cache-headers` | warn | Ensure Cache-Control header in GET handlers |
260
+
261
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/no-use-cache-in-post.md` (and similar files)
262
+
263
+ #### Stack Rules (`@schafevormfenster/eslint-config/stack`)
264
+
265
+ | Rule | Severity | Description |
266
+ |------|----------|-------------|
267
+ | `no-forbidden-imports` | warn | Forbid libraries with preferred alternatives |
268
+
269
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/no-forbidden-imports.md`
270
+
271
+ #### Testing Rules (E2E - `@schafevormfenster/eslint-config/playwright`)
272
+
273
+ | Rule | Severity | Description |
274
+ |------|----------|-------------|
275
+ | `enforce-apitest-env-vars` | error | Require APITEST_* prefix for env vars in E2E tests |
276
+ | `enforce-test-file-naming` | error | Enforce *.spec.ts for Playwright tests |
277
+ | `no-env-preservation-in-tests` | error | Forbid preserving/restoring process.env in tests |
278
+ | `require-describe-wrapper` | warn | Require test cases to be wrapped in describe() blocks |
279
+ | `require-meaningful-descriptions` | warn | Require meaningful descriptions (min 10 chars for describe, 15 for it/test) |
280
+ | `suggest-test-categorization` | warn | Suggest organizing tests into categories (Happy Path → Error → Edge Cases) |
281
+
282
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/enforce-apitest-env-vars.md` (and similar files)
283
+
284
+ #### Testing Rules (Unit/Integration - `@schafevormfenster/eslint-config/vitest`)
285
+
286
+ | Rule | Severity | Description |
287
+ |------|----------|-------------|
288
+ | `prefer-loose-error-matching` | warn | Prefer regex over exact string matching for errors |
289
+ | `enforce-test-file-naming` | error | Enforce *.test.ts for Vitest tests |
290
+ | `no-env-preservation-in-tests` | error | Forbid preserving/restoring process.env in tests |
291
+ | `require-env-setup-in-tests` | warn | Require beforeEach to initialize env vars |
292
+ | `require-describe-wrapper` | warn | Require test cases to be wrapped in describe() blocks |
293
+ | `require-meaningful-descriptions` | warn | Require meaningful descriptions (min 10 chars for describe, 15 for it/test) |
294
+ | `suggest-test-categorization` | warn | Suggest organizing tests into categories (Happy Path → Error → Edge Cases) |
295
+
296
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/prefer-loose-error-matching.md` (and similar files)
297
+
298
+ #### Testing Rules (Integration - `@schafevormfenster/eslint-config/integration`)
299
+
300
+ | Rule | Severity | Description |
301
+ |------|----------|-------------|
302
+ | `prefer-loose-error-matching` | warn | Prefer regex over exact string matching for errors |
303
+ | `enforce-test-file-naming` | error | Enforce *.test.ts for integration tests |
304
+ | `no-env-preservation-in-tests` | error | Forbid preserving/restoring process.env in tests |
305
+ | `require-env-setup-in-tests` | warn | Require beforeEach to initialize env vars |
306
+ | `require-describe-wrapper` | warn | Require test cases to be wrapped in describe() blocks |
307
+ | `require-meaningful-descriptions` | warn | Require meaningful descriptions (min 10 chars for describe, 15 for it/test) |
308
+ | `suggest-test-categorization` | warn | Suggest organizing tests into categories (Happy Path → Error → Edge Cases) |
309
+
310
+ **Documentation**: See `node_modules/@schafevormfenster/eslint-plugin/docs/rules/prefer-loose-error-matching.md` (and similar files)
311
+
312
+ ## Usage Examples
313
+
314
+ ### Basic Next.js Application
315
+
316
+ ```javascript
317
+ // eslint.config.mjs
318
+ import { defineConfig } from "eslint/config";
319
+ import svfNext from "@schafevormfenster/eslint-config/next";
320
+ import svfLogging from "@schafevormfenster/eslint-config/logging";
321
+ import svfPlaywright from "@schafevormfenster/eslint-config/playwright";
322
+
323
+ export default defineConfig([
324
+ ...svfNext,
325
+ ...svfLogging,
326
+ ...svfPlaywright,
327
+ ]);
328
+ ```
329
+
330
+ ### REST API with Full Stack
331
+
332
+ ```javascript
333
+ // eslint.config.mjs
334
+ import { defineConfig } from "eslint/config";
335
+ import svfNext from "@schafevormfenster/eslint-config/next";
336
+ import svfLogging from "@schafevormfenster/eslint-config/logging";
337
+ import svfArchitecture from "@schafevormfenster/eslint-config/architecture";
338
+ import svfRest from "@schafevormfenster/eslint-config/rest";
339
+ import svfCaching from "@schafevormfenster/eslint-config/caching";
340
+ import svfStack from "@schafevormfenster/eslint-config/stack";
341
+ import svfPlaywright from "@schafevormfenster/eslint-config/playwright";
342
+ import svfVitest from "@schafevormfenster/eslint-config/vitest";
343
+
344
+ export default defineConfig([
345
+ // Base stack
346
+ ...svfNext,
347
+
348
+ // Domain rules
349
+ ...svfLogging,
350
+ ...svfArchitecture,
351
+ ...svfRest,
352
+ ...svfCaching,
353
+ ...svfStack,
354
+
355
+ // Testing rules
356
+ ...svfPlaywright,
357
+ ...svfVitest,
358
+ ]);
359
+ ```
360
+
361
+ ### Pure TypeScript Library
362
+
363
+ ```javascript
364
+ // eslint.config.mjs
365
+ import { defineConfig } from "eslint/config";
366
+ import svfLibrary from "@schafevormfenster/eslint-config/library";
367
+ import svfLogging from "@schafevormfenster/eslint-config/logging";
368
+ import svfVitest from "@schafevormfenster/eslint-config/vitest";
369
+
370
+ export default defineConfig([
371
+ ...svfLibrary,
372
+ ...svfLogging,
373
+ ...svfVitest,
374
+ ]);
375
+ ```
376
+
377
+ ## Guidance for AI Coding Agents
378
+
379
+ ### When to Reference Documentation
380
+
381
+ 1. **Before implementing logging**: Read `docs/instructions/logging-guide.md` in `@schafevormfenster/eslint-plugin`
382
+ 2. **Before creating REST APIs**: Read `docs/instructions/rest-service-design-guide.md` in `@schafevormfenster/eslint-plugin`
383
+ 3. **Before implementing caching**: Read `docs/instructions/caching-guide.md` in `@schafevormfenster/eslint-plugin`
384
+ 4. **When ESLint errors occur**: Check the specific rule documentation in `docs/rules/` to understand the requirement
385
+
386
+ ### Finding Documentation Programmatically
387
+
388
+ ```bash
389
+ # List all available instruction guides
390
+ ls node_modules/@schafevormfenster/eslint-plugin/docs/instructions/
391
+
392
+ # List all rule documentation
393
+ ls node_modules/@schafevormfenster/eslint-plugin/docs/rules/
394
+
395
+ # Search for specific topics
396
+ grep -r "structured logging" node_modules/@schafevormfenster/eslint-plugin/docs/
397
+ ```
398
+
399
+ ### Best Practices
400
+
401
+ 1. **Check AGENTS.md first**: Projects using these configs should have an `AGENTS.md` file in their root that references these documentation files
402
+ 2. **Read instruction guides proactively**: Don't wait for ESLint errors - read the relevant instruction guide before writing code
403
+ 3. **Use offline docs when needed**: In isolated environments, always use the node_modules paths to access documentation
404
+ 4. **Reference rule docs for fixes**: When you encounter an ESLint error, read the specific rule documentation to understand the correct pattern
405
+
406
+ ## Version Compatibility
407
+
408
+ - `@schafevormfenster/eslint-config` requires ESLint 9+ (Flat Config)
409
+ - All rules assume TypeScript 5+
410
+ - Next.js configurations require Next.js 14+
411
+ - Testing configurations work with Vitest 1+ and Playwright 1.40+
412
+
413
+ ## See Also
414
+
415
+ - Main package README: [`packages/eslint-config/README.md`](../README.md)
416
+ - Plugin documentation: https://www.npmjs.com/package/@schafevormfenster/eslint-plugin
417
+ - Coding guidelines: `node_modules/@schafevormfenster/eslint-plugin/docs/instructions/`
418
+ - Rule catalog: `node_modules/@schafevormfenster/eslint-plugin/docs/rules/`
package/integration.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import svfPlugin from "@schafevormfenster/eslint-plugin";
2
2
 
3
3
  export default [
4
+ svfPlugin.configs.base,
4
5
  {
5
6
  files: ["**/*.test.ts", "**/*.spec.ts"],
6
7
  ...svfPlugin.configs["testing-integration"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schafevormfenster/eslint-config",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,10 +37,13 @@
37
37
  "eslint-plugin-zod": "^1.4.0",
38
38
  "globals": "^16.5.0",
39
39
  "typescript-eslint": "^8.51.0",
40
- "@schafevormfenster/eslint-plugin": "0.0.8"
40
+ "@schafevormfenster/eslint-plugin": "0.0.11"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=22"
44
44
  },
45
- "scripts": {}
45
+ "scripts": {
46
+ "check": "echo 'eslint-config: no build required'",
47
+ "release": "../../scripts/smart-publish.sh"
48
+ }
46
49
  }
package/vitest.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import vitest from "eslint-plugin-vitest";
2
+ import svfPlugin from "@schafevormfenster/eslint-plugin";
2
3
 
3
4
  export default [
5
+ svfPlugin.configs.base,
4
6
  {
5
7
  files: ["**/*.test.ts", "**/*.spec.ts"],
6
8
  plugins: {
@@ -13,5 +15,9 @@ export default [
13
15
  // Disable deep nesting rule for test files - describe/it nesting is organizational, not functional
14
16
  "sonarjs/no-nested-functions": "off"
15
17
  }
18
+ },
19
+ {
20
+ files: ["**/*.test.ts", "**/*.spec.ts"],
21
+ ...svfPlugin.configs["testing-unit"]
16
22
  }
17
23
  ];