-
Notifications
You must be signed in to change notification settings - Fork 195
Allow $ in casing-related rules
#453
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,4 +13,33 @@ describe('Linter - event-name-camelcase', () => { | |||||
| assert.equal(report.errorCount, 1) | ||||||
| assert.ok(report.messages[0].message.includes('CamelCase')) | ||||||
| }) | ||||||
|
|
||||||
| it('should not raise event name error for event in camelCase', () => { | ||||||
| const code = contractWith('event Event1(uint a);') | ||||||
|
|
||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'event-name-camelcase': 'error' }, | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 0) | ||||||
| }) | ||||||
|
|
||||||
| describe('with $ character', () => { | ||||||
| const WITH_$ = { | ||||||
| $: contractWith('event $(uint a);'), | ||||||
| 'starting with $': contractWith('event $Event1(uint a);'), | ||||||
| 'containing a $': contractWith('event Eve$nt1(uint a);'), | ||||||
| 'ending with $': contractWith('event Event1$(uint a);'), | ||||||
| } | ||||||
|
|
||||||
| for (const [key, code] of Object.entries(WITH_$)) { | ||||||
| it(`should not raise event name error for events ${key}`, () => { | ||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'contract-name-camelcase': 'error' }, | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one should be event-name-camelcase, right ? (I fix)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, it should be:
Suggested change
|
||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 0) | ||||||
| }) | ||||||
| } | ||||||
| }) | ||||||
| }) | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,25 +3,87 @@ const linter = require('../../../lib/index') | |||||
| const contractWith = require('../../common/contract-builder').contractWith | ||||||
|
|
||||||
| describe('Linter - func-param-name-mixedcase', () => { | ||||||
| it('should raise incorrect func param name error', () => { | ||||||
| const code = contractWith('function funcName (uint A) public {}') | ||||||
| describe('in functions', () => { | ||||||
| it('should raise incorrect func param name error', () => { | ||||||
| const code = contractWith('function funcName (uint A) public {}') | ||||||
|
|
||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-param-name-mixedcase': 'error' }, | ||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-param-name-mixedcase': 'error' }, | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 1) | ||||||
| assert.ok(report.messages[0].message.includes('param')) | ||||||
| }) | ||||||
|
|
||||||
| it('should not raise incorrect func param name error', () => { | ||||||
| const code = contractWith('function funcName (uint someParam) public {}') | ||||||
|
|
||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-param-name-mixedcase': 'error' }, | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 0) | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 1) | ||||||
| assert.ok(report.messages[0].message.includes('param')) | ||||||
| describe('with $ character', () => { | ||||||
| const WITH_$ = { | ||||||
| $: contractWith('function funcName (uint $) public {}'), | ||||||
| 'starting with $': contractWith('function funcName (uint $param) public {}'), | ||||||
| 'containing a $': contractWith('function funcName (uint pa$ram) public {}'), | ||||||
| 'ending with $': contractWith('function funcName (uint param$) public {}'), | ||||||
| } | ||||||
|
|
||||||
| for (const [key, code] of Object.entries(WITH_$)) { | ||||||
| it(`should not raise func param name error for parameters ${key}`, () => { | ||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-param-name-mixedcase': 'error' }, | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 0) | ||||||
| }) | ||||||
| } | ||||||
| }) | ||||||
| }) | ||||||
|
|
||||||
| it('should raise var name error for event arguments illegal styling', () => { | ||||||
| const code = contractWith('event Event1(uint B);') | ||||||
| describe('in events', () => { | ||||||
| it('should raise var name error for event arguments illegal styling', () => { | ||||||
| const code = contractWith('event Event1(uint B);') | ||||||
|
|
||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-param-name-mixedcase': 'error' }, | ||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-param-name-mixedcase': 'error' }, | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 1) | ||||||
| assert.ok(report.messages[0].message.includes('mixedCase')) | ||||||
| }) | ||||||
|
|
||||||
| it('should not raise incorrect func param name error', () => { | ||||||
| const code = contractWith('event Event1(uint someParam);') | ||||||
|
|
||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-param-name-mixedcase': 'error' }, | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 0) | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 1) | ||||||
| assert.ok(report.messages[0].message.includes('mixedCase')) | ||||||
| describe('with $ character', () => { | ||||||
| const WITH_$ = { | ||||||
| $: contractWith('event Event1(uint $);'), | ||||||
| 'starting with $': contractWith('event Event1(uint $param);'), | ||||||
| 'containing a $': contractWith('event Event1(uint pa$ram);'), | ||||||
| 'ending with $': contractWith('event Event1(uint param$);'), | ||||||
| } | ||||||
|
|
||||||
| for (const [key, code] of Object.entries(WITH_$)) { | ||||||
| it(`should not raise func name error for functions ${key}`, () => { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for Event Parameters
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| const report = linter.processStr(code, { | ||||||
| rules: { 'func-name-mixedcase': 'error' }, | ||||||
| }) | ||||||
|
|
||||||
| assert.equal(report.errorCount, 0) | ||||||
| }) | ||||||
| } | ||||||
| }) | ||||||
| }) | ||||||
| }) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this description is not ok, right ?
Don't worry I'll fix... just wanted to make sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct, it had to be: