Skip to content

Commit 7d03891

Browse files
committed
Add forceUpperCaseConst docs
1 parent bb37afd commit 7d03891

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

packages/eslint-plugin-prefer-let/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,38 @@ Then configure the rules you want to use under the rules section.
8282
}
8383
```
8484

85+
### Options
86+
87+
#### `forceUpperCaseConst`
88+
89+
When set to `true`, this option enforces `const` for top-level `UPPER_CASE` names (e.g. `PI`, `API_BASE_URL`)
90+
91+
```json
92+
{
93+
"rules": {
94+
"prefer-let/prefer-let": [2, { "forceUpperCaseConst": true }]
95+
}
96+
}
97+
```
98+
99+
This makes the distinction between true constants and regular bindings explicit and machine-enforced.
100+
101+
Good:
102+
103+
```javascript
104+
const PI = 3.14;
105+
const API_BASE_URL = 'https://example.com';
106+
107+
let config = loadConfig();
108+
```
109+
110+
Bad:
111+
112+
```javascript
113+
const config = loadConfig(); // not UPPER_CASE — use let
114+
let PI = 3.14; // UPPER_CASE — use const
115+
```
116+
85117
### Possible Conflicts
86118

87119
This plugin may conflict with other plugins or configs that set `eslint prefer-const`. You can configure the rules to avoid this:

0 commit comments

Comments
 (0)