Skip to content

Commit

Permalink
Add miscellaneous examples
Browse files Browse the repository at this point in the history
  • Loading branch information
touhonoob committed Aug 23, 2019
1 parent 74b3d81 commit 79048c7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
16 changes: 15 additions & 1 deletion lib/rules/miscellaneous/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@ const meta = {
description: `Type of quotes. Must be one of ${formatEnum(QUOTE_TYPES)}`,
default: DEFAULT_QUOTES_TYPE
}
]
],
examples: {
good: [
{
description: 'String with double quotes',
code: require('../../../test/fixtures/miscellaneous/string-with-double-quotes')
}
],
bad: [
{
description: 'String with single quotes',
code: require('../../../test/fixtures/miscellaneous/string-with-single-quotes')
}
]
}
},

isDefault: false,
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-rule-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function getDefaultSeverity(rule) {
function main() {
const rules = loadRules()
rules.forEach(rule => {
if (rule.ruleId === 'reason-string')
if (rule.ruleId === 'quotes')
console.log(generateRuleDoc(rule))
})
}
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/miscellaneous/string-with-double-quotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { contractWith } = require('./../../common/contract-builder')

module.exports = contractWith('string private a = "test";')
3 changes: 3 additions & 0 deletions test/fixtures/miscellaneous/string-with-single-quotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { contractWith } = require('./../../common/contract-builder')

module.exports = contractWith("string private a = 'test';")
4 changes: 2 additions & 2 deletions test/rules/miscellaneous/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Linter - quotes', () => {
})

it('should raise quotes error', () => {
const code = contractWith("string private a = 'test';")
const code = require('../../fixtures/miscellaneous/string-with-single-quotes')

const report = linter.processStr(code, {
rules: { quotes: 'error' }
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Linter - quotes', () => {
)

it('should raise no error', () => {
const filePath = storeAsFile(contractWith('string private a = "test";'))
const filePath = storeAsFile(require('../../fixtures/miscellaneous/string-with-double-quotes'))

const report = linter.processFile(filePath, {
rules: { quotes: 'error' }
Expand Down

0 comments on commit 79048c7

Please sign in to comment.