File tree Expand file tree Collapse file tree
packages/eslint-plugin-prefer-let Expand file tree Collapse file tree Original file line number Diff line number Diff 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
87119This plugin may conflict with other plugins or configs that set ` eslint prefer-const ` . You can configure the rules to avoid this:
You can’t perform that action at this time.
0 commit comments