solhint
solhint copied to clipboard
allow immutable state variables to be named in CAPS_SNAKE_CASE
This is more of a question than a bug report -- IMO immutable variables should be allowed to be treated as constants, since they in fact cannot be changed.
Currently the code below returns a warning Variable name must be in mixedCase
when linted with the recommended ruleset.
contract Test {
uint16 public immutable TEST_MODE;
constructor(uint16 _testMode) { TEST_MODE = _testMode; }
}
I think we need to rethink the whole approach to naming, since it's hard to make some calls. For example, the linked docs use mixedCase for immutable variables, but I agree that it makes sense to use SNAKE_CASE.
The quick and backward compatible fix here is to add an option to the var-name-mixedcase
. Something like { ignoreImmutable: true }
. The problem is, if you do that you would also need to add a mirror option to const-name-snakecase
, something like { allowImmutable: true }
. What do you think?
It's hard to think of a good single setting here, since it really concerns two rules. The simplest way would be to have some "general config" option treat-immutable-vars-as-constants
, but that's kinda bad design since it's not really a general option, just a two-rule option...
Maybe it will be enough to add a treat-immutable-var-as-constant: true
option to both these rules? You'd have to turn on both to have immutable variables linted in CAPS_SNAKE_CASE
, and without them it would lint them in mixedCase
.
Yeah, I'd be fine with that. Especially because having such a long and ugly option would motivate me to totally redo the naming rules in the next major :smile:
I don't know what is the state of this issue now but having support for this would be great 👍
Plus one, would love to see this!
+1 on this, would be great, Optimism prefers SCREAMING_SNAKE_CASE
for immutables
+1 here too guys