Skip to content

Commit

Permalink
feat(bin): 0 exit code when no unused rules found (#39)
Browse files Browse the repository at this point in the history
Before, no unused rules always returned a non-zero exit code even when
no unused rules were found. Now, -u only returns a non-zero exit code
when an unused rule is found.

This makes eslint-find-rules an even better tool by being able to
be ran on CI when ESLint updates for configs.
  • Loading branch information
dustinspecker authored and sarbbottam committed Apr 15, 2016
1 parent 1a64db4 commit a001620
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Object.keys(options).forEach(function findRules(option) {
if (rules.length) {
console.log('\n' + options[option][0], 'rules\n') // eslint-disable-line no-console
console.log(rules.join(', ')) // eslint-disable-line no-console
} else if (option === 'getUnusedRules') {
processExitCode = 0
}
}
})
Expand Down
10 changes: 10 additions & 0 deletions test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ describe('bin', function() {
assert.ok(getUnusedRules.called)
})

it('options -u|--unused and no unused rules found', function() {
getUnusedRules.returns([])
process.exit = function(status) {
assert.equal(status, 0)
}
process.argv[2] = '-u'
proxyquire('../src/bin', stub)
assert.ok(getUnusedRules.called)
})

it('option -u|--unused along with -n|no-error', function() {
process.exit = function(status) {
assert.equal(status, 0)
Expand Down

0 comments on commit a001620

Please sign in to comment.