Skip to content

Commit 531f6b3

Browse files
author
dbale-altoros
committed
new rule - immutable vars naming
1 parent 7bb8a28 commit 531f6b3

25 files changed

+330
-42
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
'global-require': 'off',
1919
'no-bitwise': 'off',
2020
'no-console': 'off',
21+
'func-names': 'off',
2122
'no-continue': 'off',
2223
'no-else-return': 'off',
2324
'no-param-reassign': 'off',

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ convertLib.sol
99
antlr4.jar
1010
/docs/.sass-cache/
1111
_temp/
12+
.solhint.json

docs/rules.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ title: "Rule Index of Solhint"
1212
| [function-max-lines](./rules/best-practises/function-max-lines.md) | Function body contains "count" lines but allowed no more than maxlines. | |
1313
| [max-line-length](./rules/best-practises/max-line-length.md) | Line length must be no more than maxlen. | |
1414
| [max-states-count](./rules/best-practises/max-states-count.md) | Contract has "some count" states declarations but allowed no more than maxstates. | ✔️ |
15-
| [no-console](./rules/best-practises/no-console.md) | No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements | ✔️ |
15+
| [no-console](./rules/best-practises/no-console.md) | No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements. | ✔️ |
1616
| [no-empty-blocks](./rules/best-practises/no-empty-blocks.md) | Code contains empty block. | ✔️ |
17-
| [no-global-import](./rules/best-practises/no-global-import.md) | Import statement includes an entire file instead of selected symbols | ✔️ |
18-
| [no-unused-import](./rules/best-practises/no-unused-import.md) | Imported name is not used | ✔️ |
17+
| [no-global-import](./rules/best-practises/no-global-import.md) | Import statement includes an entire file instead of selected symbols. | ✔️ |
18+
| [no-unused-import](./rules/best-practises/no-unused-import.md) | Imported name is not used. | ✔️ |
1919
| [no-unused-vars](./rules/best-practises/no-unused-vars.md) | Variable "name" is unused. | ✔️ |
2020
| [payable-fallback](./rules/best-practises/payable-fallback.md) | When fallback is not payable you will not be able to receive ethers. | ✔️ |
2121
| [reason-string](./rules/best-practises/reason-string.md) | Require or revert statement must have a reason string and check that each reason string is at most N characters long. | ✔️ |
@@ -32,22 +32,23 @@ title: "Rule Index of Solhint"
3232

3333
## Style Guide Rules
3434

35-
| Rule Id | Error | Recommended |
36-
| ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ----------- |
37-
| [const-name-snakecase](./rules/naming/const-name-snakecase.md) | Constant name must be in capitalized SNAKE_CASE. | ✔️ |
38-
| [contract-name-camelcase](./rules/naming/contract-name-camelcase.md) | Contract name must be in CamelCase. | ✔️ |
39-
| [event-name-camelcase](./rules/naming/event-name-camelcase.md) | Event name must be in CamelCase. | ✔️ |
40-
| [func-name-mixedcase](./rules/naming/func-name-mixedcase.md) | Function name must be in mixedCase. | ✔️ |
41-
| [func-param-name-mixedcase](./rules/naming/func-param-name-mixedcase.md) | Function param name must be in mixedCase | |
42-
| [modifier-name-mixedcase](./rules/naming/modifier-name-mixedcase.md) | Modifier name must be in mixedCase. | |
43-
| [named-parameters-mapping](./rules/naming/named-parameters-mapping.md) | Solidity v0.8.18 introduced named parameters on the mappings definition | |
44-
| [private-vars-leading-underscore](./rules/naming/private-vars-leading-underscore.md) | Private and internal names must start with a single underscore. | |
45-
| [use-forbidden-name](./rules/naming/use-forbidden-name.md) | Avoid to use letters 'I', 'l', 'O' as identifiers. | ✔️ |
46-
| [var-name-mixedcase](./rules/naming/var-name-mixedcase.md) | Variable name must be in mixedCase. | ✔️ |
47-
| [func-order](./rules/order/func-order.md) | Function order is incorrect. | |
48-
| [imports-on-top](./rules/order/imports-on-top.md) | Import statements must be on top. | ✔️ |
49-
| [ordering](./rules/order/ordering.md) | Check order of elements in file and inside each contract, according to the style guide | |
50-
| [visibility-modifier-order](./rules/order/visibility-modifier-order.md) | Visibility modifier must be first in list of modifiers. | ✔️ |
35+
| Rule Id | Error | Recommended |
36+
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | ----------- |
37+
| [const-name-snakecase](./rules/naming/const-name-snakecase.md) | Constant name must be in capitalized SNAKE_CASE. (Does not check IMMUTABLES, use immutable-vars-naming) | ✔️ |
38+
| [contract-name-camelcase](./rules/naming/contract-name-camelcase.md) | Contract name must be in CamelCase. | ✔️ |
39+
| [event-name-camelcase](./rules/naming/event-name-camelcase.md) | Event name must be in CamelCase. | ✔️ |
40+
| [func-name-mixedcase](./rules/naming/func-name-mixedcase.md) | Function name must be in mixedCase. | ✔️ |
41+
| [func-param-name-mixedcase](./rules/naming/func-param-name-mixedcase.md) | Function param name must be in mixedCase. | |
42+
| [immutable-vars-naming](./rules/naming/immutable-vars-naming.md) | Check Immutable variables. Capitalized SNAKE_CASE or mixedCase depending on configuration. | ✔️ |
43+
| [modifier-name-mixedcase](./rules/naming/modifier-name-mixedcase.md) | Modifier name must be in mixedCase. | |
44+
| [named-parameters-mapping](./rules/naming/named-parameters-mapping.md) | Solidity v0.8.18 introduced named parameters on the mappings definition. | |
45+
| [private-vars-leading-underscore](./rules/naming/private-vars-leading-underscore.md) | Private and internal names must start with a single underscore. | |
46+
| [use-forbidden-name](./rules/naming/use-forbidden-name.md) | Avoid to use letters 'I', 'l', 'O' as identifiers. | ✔️ |
47+
| [var-name-mixedcase](./rules/naming/var-name-mixedcase.md) | Variable name must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming) | ✔️ |
48+
| [func-order](./rules/order/func-order.md) | Function order is incorrect. | |
49+
| [imports-on-top](./rules/order/imports-on-top.md) | Import statements must be on top. | ✔️ |
50+
| [ordering](./rules/order/ordering.md) | Check order of elements in file and inside each contract, according to the style guide. | |
51+
| [visibility-modifier-order](./rules/order/visibility-modifier-order.md) | Visibility modifier must be first in list of modifiers. | ✔️ |
5152
5253

5354
## Security Rules

docs/rules/best-practises/no-console.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ title: "no-console | Solhint"
1414
1515

1616
## Description
17-
No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements
17+
No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements.
1818

1919
## Options
2020
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to error.

docs/rules/best-practises/no-global-import.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title: "no-global-import | Solhint"
1212
1313

1414
## Description
15-
Import statement includes an entire file instead of selected symbols
15+
Import statement includes an entire file instead of selected symbols.
1616

1717
## Options
1818
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.

docs/rules/best-practises/no-unused-import.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title: "no-unused-import | Solhint"
1212
1313

1414
## Description
15-
Imported name is not used
15+
Imported name is not used.
1616

1717
## Options
1818
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.

docs/rules/naming/const-name-snakecase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title: "const-name-snakecase | Solhint"
1212
1313

1414
## Description
15-
Constant name must be in capitalized SNAKE_CASE.
15+
Constant name must be in capitalized SNAKE_CASE. (Does not check IMMUTABLES, use immutable-vars-naming)
1616

1717
## Options
1818
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.

docs/rules/naming/func-param-name-mixedcase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: "func-param-name-mixedcase | Solhint"
99
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
1010

1111
## Description
12-
Function param name must be in mixedCase
12+
Function param name must be in mixedCase.
1313

1414
## Options
1515
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
warning: "This is a dynamically generated file. Do not edit manually."
3+
layout: "default"
4+
title: "immutable-vars-naming | Solhint"
5+
---
6+
7+
# immutable-vars-naming
8+
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
9+
![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational)
10+
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11+
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12+
13+
14+
## Description
15+
Check Immutable variables. Capitalized SNAKE_CASE or mixedCase depending on configuration.
16+
17+
## Options
18+
This rule accepts an array of options:
19+
20+
| Index | Description | Default Value |
21+
| ----- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
22+
| 0 | Rule severity. Must be one of "error", "warn", "off". | warn |
23+
| 1 | A JSON object with a single property "immutablesAsConstants" as boolean specifying if immutable variables should be treated as constants | {"immutablesAsConstants":true} |
24+
25+
26+
### Example Config
27+
```json
28+
{
29+
"rules": {
30+
"immutable-vars-naming": ["warn",{"immutablesAsConstants":true}]
31+
}
32+
}
33+
```
34+
35+
36+
## Examples
37+
This rule does not have examples.
38+
39+
## Version
40+
This rule is introduced in the latest version.
41+
42+
## Resources
43+
- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/immutable-vars-naming.js)
44+
- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/immutable-vars-naming.md)
45+
- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/immutable-vars-naming.js)

docs/rules/naming/named-parameters-mapping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: "named-parameters-mapping | Solhint"
99
![Default Severity Badge off](https://img.shields.io/badge/Default%20Severity-off-undefined)
1010

1111
## Description
12-
Solidity v0.8.18 introduced named parameters on the mappings definition
12+
Solidity v0.8.18 introduced named parameters on the mappings definition.
1313

1414
## Options
1515
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to off.

0 commit comments

Comments
 (0)