Skip to content

Commit

Permalink
feat: add mocha lint checks
Browse files Browse the repository at this point in the history
BREAKING CHANGE: adds eslint-plugin-mocha as a peerDep
  • Loading branch information
dbushong committed Apr 12, 2018
1 parent f6da322 commit 897dbb0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = Object.assign({
ecmaVersion: 5,
sourceType: 'script',
},
plugins: ['import', 'node', 'prettier'],
plugins: ['import', 'mocha', 'node', 'prettier'],
rules: Object.assign({}, opinions, conventions, mistakes, {
// Additional opinions

Expand Down
13 changes: 13 additions & 0 deletions examples/eslint/node6/mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

/* eslint-env mocha */

describe('various mocha mistakes', () => {
// no-exclusive-tests
it.only('does thing', done => {
it('tries to nest a test'); // no-nested-tests
return done; // no-return-and-callback, handle-done-callback
});

it('does thing'); // no-identical-title
});
1 change: 1 addition & 0 deletions examples/eslint/node6/mocha.js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "errorCount": 4 }
2 changes: 1 addition & 1 deletion lib/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ module.exports = {
experimentalObjectRestSpread: true,
},
},
plugins: ['import', 'node', 'prettier'],
plugins: ['import', 'mocha', 'node', 'prettier'],
};
3 changes: 3 additions & 0 deletions lib/rules/conventions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ module.exports = {

// See: https://eslint.org/docs/rules/prefer-arrow-callback
'prefer-arrow-callback': 'error',

// See: https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-identical-title.md
'mocha/no-identical-title': 'warn',
};
11 changes: 11 additions & 0 deletions lib/rules/mistakes.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,15 @@ module.exports = {
],
// See: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 'error',

// # Mocha

// See: https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/handle-done-callback.md
'mocha/handle-done-callback': 'error',
// See: https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-exclusive-tests.md
'mocha/no-exclusive-tests': 'error',
// See: https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-tested-tests.md
'mocha/no-nested-tests': 'error',
// See: https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-return-and-callback.md
'mocha/no-return-and-callback': 'error',
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"peerDependencies": {
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-mocha": "^4.12.1",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-prettier": "^2.2.0",
"eslint": "^4.5.0"
Expand All @@ -35,6 +36,7 @@
"assertive": "^2.1.0",
"eslint": "^4.7.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-mocha": "^4.12.1",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-prettier": "^2.2.0",
"globby": "^6.1.0",
Expand Down

0 comments on commit 897dbb0

Please sign in to comment.