Skip to content

Commit 4e8fba7

Browse files
author
dbale-altoros
committed
fix: rename pascalcase to capwords
1 parent 9cb97a4 commit 4e8fba7

File tree

14 files changed

+130
-46
lines changed

14 files changed

+130
-46
lines changed

conf/rulesets/solhint-all.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ module.exports = Object.freeze({
3838
'comprehensive-interface': 'warn',
3939
quotes: ['error', 'double'],
4040
'const-name-snakecase': 'warn',
41-
'contract-name-pascalcase': 'warn',
42-
'event-name-pascalcase': 'warn',
41+
'contract-name-capwords': 'warn',
42+
'event-name-capwords': 'warn',
4343
'foundry-test-functions': ['warn', ['setUp']],
4444
'func-name-mixedcase': 'warn',
4545
'func-named-parameters': ['warn', 4],

conf/rulesets/solhint-recommended.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ module.exports = Object.freeze({
2323
'gas-custom-errors': 'warn',
2424
quotes: ['error', 'double'],
2525
'const-name-snakecase': 'warn',
26-
'contract-name-pascalcase': 'warn',
27-
'event-name-pascalcase': 'warn',
26+
'contract-name-capwords': 'warn',
27+
'event-name-capwords': 'warn',
2828
'func-name-mixedcase': 'warn',
2929
'immutable-vars-naming': [
3030
'warn',

docs/rules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ title: "Rule Index of Solhint"
2929
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------ | ----------- |
3030
| [interface-starts-with-i](./rules/naming/interface-starts-with-i.md) | Solidity Interfaces names should start with an `I` | | |
3131
| [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) | $~~~~~~~~$✔️ | |
32-
| [contract-name-pascalcase](./rules/naming/contract-name-pascalcase.md) | Contract, Structs and Enums should be in PascalCase. | $~~~~~~~~$✔️ | |
33-
| [event-name-pascalcase](./rules/naming/event-name-pascalcase.md) | Event name must be in PascalCase. | $~~~~~~~~$✔️ | |
32+
| [contract-name-capwords](./rules/naming/contract-name-capwords.md) | Contract, Structs and Enums should be in CapWords. | $~~~~~~~~$✔️ | |
33+
| [event-name-capwords](./rules/naming/event-name-capwords.md) | Event name must be in CapWords. | $~~~~~~~~$✔️ | |
3434
| [foundry-test-functions](./rules/naming/foundry-test-functions.md) | Enforce naming convention on functions for Foundry test cases | | |
3535
| [func-name-mixedcase](./rules/naming/func-name-mixedcase.md) | Function name must be in mixedCase. | $~~~~~~~~$✔️ | |
3636
| [func-named-parameters](./rules/naming/func-named-parameters.md) | Enforce named parameters for function calls with 4 or more arguments. This rule may have some false positives | | |
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
warning: "This is a dynamically generated file. Do not edit manually."
3+
layout: "default"
4+
title: "contract-name-capwords | Solhint"
5+
---
6+
7+
# contract-name-capwords
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+
Contract, Structs and Enums should be in CapWords.
16+
17+
## Options
18+
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn.
19+
20+
### Example Config
21+
```json
22+
{
23+
"rules": {
24+
"contract-name-capwords": "warn"
25+
}
26+
}
27+
```
28+
29+
### Notes
30+
- Solhint allows this rule to automatically fix the code with `--fix` option
31+
- The FIX will only change first letter and remove underscores
32+
33+
## Examples
34+
This rule does not have examples.
35+
36+
## Version
37+
This rule is introduced in the latest version.
38+
39+
## Resources
40+
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/contract-name-capwords.js)
41+
- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/contract-name-capwords.md)
42+
- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/contract-name-capwords.js)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
warning: "This is a dynamically generated file. Do not edit manually."
3+
layout: "default"
4+
title: "event-name-capwords | Solhint"
5+
---
6+
7+
# event-name-capwords
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+
Event name must be in CapWords.
16+
17+
## Options
18+
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn.
19+
20+
### Example Config
21+
```json
22+
{
23+
"rules": {
24+
"event-name-capwords": "warn"
25+
}
26+
}
27+
```
28+
29+
### Notes
30+
- Solhint allows this rule to automatically fix the code with `--fix` option
31+
- The FIX will only change first letter and remove underscores
32+
33+
## Examples
34+
This rule does not have examples.
35+
36+
## Version
37+
This rule is introduced in the latest version.
38+
39+
## Resources
40+
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/event-name-capwords.js)
41+
- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/event-name-capwords.md)
42+
- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/event-name-capwords.js)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"rules": {
3-
"contract-name-pascalcase": "error"
3+
"contract-name-capwords": "error"
44
}
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"rules": {
3-
"event-name-pascalcase": "error"
3+
"event-name-capwords": "error"
44
}
55
}

e2e/autofix-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ describe('e2e', function () {
476476
})
477477
})
478478

479-
describe('autofix rule: contract-name-pascalcase', () => {
479+
describe('autofix rule: contract-name-capwords', () => {
480480
before(function () {
481-
params = retrieveParams('contract-name-pascalcase/')
481+
params = retrieveParams('contract-name-capwords/')
482482
currentConfig = `${params.path}${params.subpath}.solhint.json`
483483
currentFile = `${params.path}${params.subpath}Foo1.sol`
484484
beforeFixFile = `${params.path}${params.subpath}Foo1BeforeFix.sol`
@@ -522,9 +522,9 @@ describe('e2e', function () {
522522
})
523523
})
524524

525-
describe('autofix rule: event-name-pascalcase', () => {
525+
describe('autofix rule: event-name-capwords', () => {
526526
before(function () {
527-
params = retrieveParams('event-name-pascalcase/')
527+
params = retrieveParams('event-name-capwords/')
528528
currentConfig = `${params.path}${params.subpath}.solhint.json`
529529
currentFile = `${params.path}${params.subpath}Foo1.sol`
530530
beforeFixFile = `${params.path}${params.subpath}Foo1BeforeFix.sol`

lib/common/identifier-naming.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ module.exports = {
1111
return !this.isMixedCase(text)
1212
},
1313

14-
isPascalCase(text) {
14+
isCapWords(text) {
1515
return match(text, /[A-Z$]+[a-zA-Z0-9$]*/)
1616
},
1717

18-
isNotPascalCase(text) {
19-
return !this.isPascalCase(text)
18+
isNotCapWords(text) {
19+
return !this.isCapWords(text)
2020
},
2121

2222
isUpperSnakeCase(text) {

lib/rules/naming/contract-name-pascalcase.js renamed to lib/rules/naming/contract-name-capwords.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const BaseChecker = require('../base-checker')
22
const naming = require('../../common/identifier-naming')
33

4-
const ruleId = 'contract-name-pascalcase'
4+
const ruleId = 'contract-name-capwords'
55
const meta = {
66
type: 'naming',
77

88
docs: {
9-
description: 'Contract, Structs and Enums should be in PascalCase.',
9+
description: 'Contract, Structs and Enums should be in CapWords.',
1010
category: 'Style Guide Rules',
1111
notes: [
1212
{
@@ -25,7 +25,7 @@ const meta = {
2525
schema: null,
2626
}
2727

28-
class ContractNamePascalcaseChecker extends BaseChecker {
28+
class ContractNameCapWordsChecker extends BaseChecker {
2929
constructor(reporter) {
3030
super(reporter, ruleId, meta)
3131
}
@@ -43,7 +43,7 @@ class ContractNamePascalcaseChecker extends BaseChecker {
4343
}
4444

4545
validateName(node, type) {
46-
if (naming.isNotPascalCase(node.name)) {
46+
if (naming.isNotCapWords(node.name)) {
4747
this._error(node, type)
4848
}
4949
}
@@ -73,10 +73,10 @@ class ContractNamePascalcaseChecker extends BaseChecker {
7373
_error(node, type) {
7474
this.error(
7575
node,
76-
'Contract, Structs and Enums should be in PascalCase',
76+
'Contract, Structs and Enums should be in CapWords',
7777
this.fixStatement(node, type)
7878
)
7979
}
8080
}
8181

82-
module.exports = ContractNamePascalcaseChecker
82+
module.exports = ContractNameCapWordsChecker

0 commit comments

Comments
 (0)