Skip to content

Commit

Permalink
Merge pull request #24 from job13er/add-rule
Browse files Browse the repository at this point in the history
Add a new rule `no-unused-expressions`
  • Loading branch information
job13er committed Nov 17, 2016
2 parents 974b1d1 + f07085a commit 1dab2c9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ Make sure you don't include empty `it()` calls. More details available [here](ht

#### `mocha/no-skipped-tests`
Emit a warning when you use `it.skip()` or `describe.skip()`. Sometimes it's necessary, but it's nice to easily see them all listed out in one place, and they should be temporary whenever they are checked in. More details available [here](https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-skipped-tests.md).

### `no-unused-expressions`
Stop developers from using property assertions like `expect(foo).to.be.true`. Mainly because of [this issue](https://github.com/chaijs/chai/issues/726).
More details available [here](http://eslint.org/docs/rules/no-unused-expressions).
3 changes: 3 additions & 0 deletions eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"describeModule"
]
}],
"no-unused-expressions": [2, {
"allowTernary": true
}],
"valid-jsdoc": [
2,
{
Expand Down
26 changes: 21 additions & 5 deletions tests/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,31 @@ describe('config', () => {
})

const code = 'var foo = 1\nvar bar = function () {}\nbar(foo)\n'
expect(cli.executeOnText(code).errorCount).to.be.equal(0)
expect(cli.executeOnText(code).errorCount).to.equal(0)
})

it('extends standard', () => {
expect(config.extends[0]).to.be.equal('standard')
it('should extend standard', () => {
expect(config.extends[0]).to.equal('standard')
})

it('includes valid-jsdoc', () => {
expect(config.rules['valid-jsdoc']).not.to.be.null
it('should include camelcase', () => {
expect(config.rules.camelcase).not.to.equal(undefined)
})

it('should include complexity', () => {
expect(config.rules.complexity).not.to.equal(undefined)
})

it('should include max-len', () => {
expect(config.rules['max-len']).not.to.equal(undefined)
})

it('should include no-unused-expressions', () => {
expect(config.rules['no-unused-expressions']).not.to.equal(undefined)
})

it('should include valid-jsdoc', () => {
expect(config.rules['valid-jsdoc']).not.to.equal(undefined)
})
})

0 comments on commit 1dab2c9

Please sign in to comment.