0
# Profile Configurations
1
2
Profile configurations provide the foundational ESLint rule sets optimized for different runtime environments and security requirements. Each profile is designed to be used as the primary configuration with optional mixins layered on top.
3
4
## Capabilities
5
6
### Node.js Profile
7
8
ESLint configuration for general Node.js projects, typically web services. Enables security rules assuming the service could receive malicious inputs from untrusted users.
9
10
```javascript { .api }
11
// Legacy format
12
module.exports = {
13
extends: ["@rushstack/eslint-config/profile/node"],
14
parserOptions: { tsconfigRootDir: __dirname }
15
};
16
17
// Flat format
18
import nodeProfile from "@rushstack/eslint-config/flat/profile/node";
19
export default [...nodeProfile];
20
```
21
22
**Path**: `@rushstack/eslint-config/profile/node`
23
**Flat Path**: `@rushstack/eslint-config/flat/profile/node`
24
**Security Level**: High - assumes untrusted inputs
25
**Use Cases**: Web services, APIs, general Node.js applications
26
27
### Node.js Trusted Tool Profile
28
29
ESLint configuration for Node.js projects whose inputs always come from developers or trusted sources. Relaxes certain security rules that would otherwise prohibit resource-intensive operations or unsafe filesystem interactions.
30
31
```javascript { .api }
32
// Legacy format
33
module.exports = {
34
extends: ["@rushstack/eslint-config/profile/node-trusted-tool"],
35
parserOptions: { tsconfigRootDir: __dirname }
36
};
37
38
// Flat format
39
import trustedToolProfile from "@rushstack/eslint-config/flat/profile/node-trusted-tool";
40
export default [...trustedToolProfile];
41
```
42
43
**Path**: `@rushstack/eslint-config/profile/node-trusted-tool`
44
**Flat Path**: `@rushstack/eslint-config/flat/profile/node-trusted-tool`
45
**Security Level**: Relaxed - assumes trusted inputs
46
**Use Cases**: Build tools, CLI applications, development utilities
47
**Warning**: Do not use for libraries that might be loaded by Node.js services
48
49
### Web Application Profile
50
51
ESLint configuration for web applications running in browser environments. Enables security rules relevant to web browser APIs such as DOM manipulation and includes considerations for client-side security.
52
53
```javascript { .api }
54
// Legacy format
55
module.exports = {
56
extends: ["@rushstack/eslint-config/profile/web-app"],
57
parserOptions: { tsconfigRootDir: __dirname }
58
};
59
60
// Flat format
61
import webAppProfile from "@rushstack/eslint-config/flat/profile/web-app";
62
export default [...webAppProfile];
63
```
64
65
**Path**: `@rushstack/eslint-config/profile/web-app`
66
**Flat Path**: `@rushstack/eslint-config/flat/profile/web-app`
67
**Security Level**: High - includes browser-specific security rules
68
**Use Cases**: Web applications, browser-based libraries, universal libraries for both Node.js and browsers
69
70
## Profile Selection Guide
71
72
**Choose `node` when:**
73
- Building web services or APIs
74
- Handling untrusted user inputs
75
- Need maximum security rules
76
- General Node.js applications
77
78
**Choose `node-trusted-tool` when:**
79
- Building CLI tools or build scripts
80
- All inputs come from developers
81
- Need to perform resource-intensive operations
82
- Working exclusively with trusted files
83
84
**Choose `web-app` when:**
85
- Building browser applications
86
- Creating libraries that run in browsers
87
- Need browser-specific security rules
88
- Building universal libraries for Node.js and browsers
89
90
## Usage Examples
91
92
**Basic Node.js web service:**
93
94
```javascript
95
// .eslintrc.js
96
require('@rushstack/eslint-config/patch/modern-module-resolution');
97
98
module.exports = {
99
extends: ["@rushstack/eslint-config/profile/node"],
100
parserOptions: { tsconfigRootDir: __dirname }
101
};
102
```
103
104
**Build tool with relaxed security:**
105
106
```javascript
107
// .eslintrc.js
108
require('@rushstack/eslint-config/patch/modern-module-resolution');
109
110
module.exports = {
111
extends: ["@rushstack/eslint-config/profile/node-trusted-tool"],
112
parserOptions: { tsconfigRootDir: __dirname }
113
};
114
```
115
116
**React web application:**
117
118
```javascript
119
// .eslintrc.js
120
require('@rushstack/eslint-config/patch/modern-module-resolution');
121
122
module.exports = {
123
extends: [
124
"@rushstack/eslint-config/profile/web-app",
125
"@rushstack/eslint-config/mixins/react"
126
],
127
parserOptions: { tsconfigRootDir: __dirname },
128
settings: {
129
react: {
130
version: "18.0"
131
}
132
}
133
};
134
```
135
136
**Flat configuration for modern ESLint:**
137
138
```javascript
139
// eslint.config.js
140
import nodeProfile from "@rushstack/eslint-config/flat/profile/node";
141
import reactMixin from "@rushstack/eslint-config/flat/mixins/react";
142
143
export default [
144
...nodeProfile,
145
...reactMixin
146
];
147
```
148
149
## Internal Implementation
150
151
All profiles are built using a common rule builder function that accepts a profile type parameter and generates the appropriate configuration object. The flat configuration versions export arrays of configuration objects compatible with ESLint's flat config format.
152
153
```typescript { .api }
154
// Internal structure (not directly exported)
155
interface ProfileConfig {
156
extends?: string[];
157
plugins: string[];
158
parser: string;
159
parserOptions: {
160
ecmaVersion: number;
161
sourceType: 'module';
162
project: string;
163
};
164
env: Record<string, boolean>;
165
rules: Record<string, RuleConfig>;
166
overrides: Array<{
167
files: string[];
168
rules: Record<string, RuleConfig>;
169
}>;
170
}
171
```
172
173
## Requirements
174
175
- **ESLint**: ^8.57.0 || ^9.25.1 (for flat config)
176
- **TypeScript**: >=4.7.0
177
- **Required patch**: `@rushstack/eslint-config/patch/modern-module-resolution`
178
- **Parser options**: `tsconfigRootDir: __dirname` must be specified for proper TypeScript integration