Skip to content

Commit

Permalink
feat(no-option): display error if no options are provided (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbbottam committed May 2, 2016
1 parent d3324e8 commit 6502c9f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bin/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ var getRuleFinder = require('../lib/rule-finder')
var specifiedFile = argv._[0]

var ruleFinder = getRuleFinder(specifiedFile)

if (!argv.c && !argv.p && !argv.a && !argv.u) {
console.log('no option provided, please provide a valid option') // eslint-disable-line no-console
console.log('usage:') // eslint-disable-line no-console
console.log('eslint-find-rules [option] <file> [flag]') // eslint-disable-line no-console
process.exit(0)
}

Object.keys(options).forEach(function findRules(option) {
var rules
var ruleFinderMethod = ruleFinder[option]
Expand Down
15 changes: 15 additions & 0 deletions test/bin/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ describe('bin', function() {
delete require.cache[require.resolve('yargs')]
})

it('no option', function() {
var callCount = 0
console.log = function() { // eslint-disable-line no-console
callCount += 1
if (arguments[0].match(
/(no option provided, please provide a valid option|usage:|eslint-find-rules \[option\] <file> \[flag\])/)
) {
return
}
consoleLog.apply(null, arguments)
}
proxyquire('../../src/bin/find', stub)
assert.equal(callCount, 3) // eslint-disable-line no-console
})

it('option -c|--current', function() {
process.argv[2] = '-c'
proxyquire('../../src/bin/find', stub)
Expand Down

0 comments on commit 6502c9f

Please sign in to comment.