Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow use of variables starting with $ in var-name-mixedcase
  • Loading branch information
ernestognw committed Jul 14, 2023
commit 3a10a5ec427549947b43324ed75e40ce1dfe096c
2 changes: 1 addition & 1 deletion lib/common/identifier-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function match(text, regex) {

module.exports = {
isMixedCase(text) {
return match(text, /[_]*[a-z]+[a-zA-Z0-9$]*[_]?/)
return match(text, /[_]*[a-z$]+[a-zA-Z0-9$]*[_]?/)
},

isNotMixedCase(text) {
Expand Down
17 changes: 17 additions & 0 deletions test/rules/naming/var-name-mixedcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,21 @@ describe('Linter - var-name-mixedcase', () => {

assert.equal(report.errorCount, 0)
})

const WITH_$ = {
$: contractWith('uint32 private $ = 10;'),
'starting with $': contractWith('uint32 private $D = 10;'),
'containing a $': contractWith('uint32 private testWith$Contained = 10;'),
'ending with $': contractWith('uint32 private testWithEnding$ = 10;'),
}

for (const [key, code] of Object.entries(WITH_$)) {
it(`should not raise var name error for variables ${key}`, () => {
const report = linter.processStr(code, {
rules: { 'no-unused-vars': 'error', 'var-name-mixedcase': 'error' },
})

assert.equal(report.errorCount, 0)
})
}
})