Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow immutable state variables to be named in CAPS_SNAKE_CASE #243

Closed
quezak opened this issue Jul 31, 2020 · 11 comments
Closed

allow immutable state variables to be named in CAPS_SNAKE_CASE #243

quezak opened this issue Jul 31, 2020 · 11 comments

Comments

@quezak
Copy link

quezak commented Jul 31, 2020

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; }
}
@fvictorio
Copy link
Contributor

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?

@quezak
Copy link
Author

quezak commented Aug 5, 2020

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.

@fvictorio
Copy link
Contributor

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 😄

@benesjan
Copy link

I don't know what is the state of this issue now but having support for this would be great 👍

@maxholloway
Copy link

Plus one, would love to see this!

@smartcontracts
Copy link

+1 on this, would be great, Optimism prefers SCREAMING_SNAKE_CASE for immutables

@hktitof
Copy link

hktitof commented Nov 5, 2022

+1 here too guys

@yuradmt
Copy link

yuradmt commented Dec 11, 2022

agree, let's add the snake case

@clicman
Copy link

clicman commented Mar 1, 2023

Are any updates?

@SvenMeyer
Copy link

yes,please !

@dbale-altoros
Copy link
Collaborator

see this PR
#458
will add new rule to treat immutable as constants or mixed case as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants