0
# Custom Config Package Names
1
2
Custom Config Package Names patch removes ESLint's strict requirement that shareable config package names must include 'eslint-config' as a prefix, enabling more flexible naming patterns for rig packages and integrated tooling solutions.
3
4
## Capabilities
5
6
### Config Package Name Patch
7
8
Applies runtime patches to ESLint's ConfigArrayFactory to bypass the 'eslint-config' naming requirement for shareable configurations.
9
10
```javascript { .api }
11
/**
12
* Applies the custom config package names patch to ESLint
13
* Must be required before ESLint processes any configuration
14
*/
15
require("@rushstack/eslint-patch/custom-config-package-names");
16
```
17
18
**Usage Example:**
19
20
```javascript
21
// .eslintrc.js
22
require("@rushstack/eslint-patch/modern-module-resolution");
23
require("@rushstack/eslint-patch/custom-config-package-names");
24
25
module.exports = {
26
extends: [
27
'@your-company/build-rig/profile/default/includes/eslint/node' // No 'eslint-config' prefix required
28
],
29
parserOptions: { tsconfigRootDir: __dirname }
30
};
31
```
32
33
### Package Name Resolution
34
35
The patch modifies ESLint's config resolution to handle non-standard package names:
36
37
1. **Primary Resolution**: Attempts to resolve using ESLint's normalized package name (with 'eslint-config-' prefix)
38
2. **Fallback Resolution**: If MODULE_NOT_FOUND, attempts resolution using the original, non-normalized package name
39
3. **Error Propagation**: Other errors are re-thrown unchanged
40
41
```javascript { .api }
42
// Internal patch implementation (not directly callable)
43
interface ConfigArrayFactory {
44
_loadExtendedShareableConfig(extendName: string): unknown;
45
}
46
47
interface Naming {
48
normalizePackageName(name: string, prefix: string): string;
49
}
50
```
51
52
### Rig Package Support
53
54
This patch specifically enables [Rush Stack rig packages](https://heft.rushstack.io/pages/intro/rig_packages/) to provide ESLint configurations:
55
56
**Rig Package Structure:**
57
```
58
@your-company/build-rig/
59
├── package.json
60
├── profiles/
61
│ └── default/
62
│ └── includes/
63
│ └── eslint/
64
│ ├── node.js # ESLint config for Node.js projects
65
│ └── browser.js # ESLint config for browser projects
66
```
67
68
**Consumer Usage:**
69
```javascript
70
module.exports = {
71
extends: [
72
'@your-company/build-rig/profile/default/includes/eslint/node'
73
]
74
};
75
```
76
77
### Naming Pattern Examples
78
79
The patch enables these naming patterns:
80
81
- `@company/build-rig/profile/web` (rig package with profile)
82
- `@company/tooling-config` (generic tooling package)
83
- `company-tools/eslint` (scoped tooling)
84
- `my-company-standards` (company standards package)
85
86
### ESLint Version Compatibility
87
88
Works across all supported ESLint versions:
89
90
- **ESLint 6.x**: Patches ConfigArrayFactory._loadExtendedShareableConfig
91
- **ESLint 7.x**: Compatible with @eslint/eslintrc changes
92
- **ESLint 8.x**: Works with bundled eslintrc.cjs
93
- **ESLint 9.x**: Supports both legacy and flat config modes
94
95
### Integration with Modern Module Resolution
96
97
Often used together with the modern module resolution patch:
98
99
```javascript
100
// Recommended combination for rig packages
101
require("@rushstack/eslint-patch/modern-module-resolution");
102
require("@rushstack/eslint-patch/custom-config-package-names");
103
104
module.exports = {
105
extends: ['@company/build-rig/profile/web/eslint']
106
};
107
```
108
109
### Error Handling
110
111
The patch gracefully handles resolution failures:
112
113
- **MODULE_NOT_FOUND with normalized name**: Attempts resolution with original name
114
- **MODULE_NOT_FOUND with original name**: Re-throws the error (config truly not found)
115
- **Other resolution errors**: Re-thrown unchanged to preserve ESLint's error handling