From 85ff2dce5ca03717d6fea2ed25c797da5449a890 Mon Sep 17 00:00:00 2001 From: Sander van Beek Date: Wed, 10 Jul 2019 11:21:59 +0200 Subject: [PATCH 1/4] Added recommended ruleset --- index.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 76cb7c1..109c0d0 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,26 @@ module.exports = { configs: { recommended: { rules: { - 'mocha/no-exclusive-tests': 2 + 'mocha/handle-done-callback': 'error', + 'mocha/max-top-level-suites': ['error', {limit: 1}], + 'mocha/no-exclusive-tests': 'warn', + 'mocha/no-global-tests': 'error', + 'mocha/no-hooks': 'off', + 'mocha/no-hooks-for-single-case': 'warn', + 'mocha/no-identical-title': 'error', + 'mocha/no-mocha-arrows': 'error', + 'mocha/no-nested-tests': 'error', + 'mocha/no-pending-tests': 'warn', + 'mocha/no-return-and-callback': 'error', + 'mocha/no-setup-in-describe': 'error', + 'mocha/no-sibling-hooks': 'error', + 'mocha/no-skipped-tests': 'warn', + 'mocha/no-synchronous-tests': 'off', + 'mocha/no-top-level-hooks': 'warn', + 'mocha/prefer-arrow-callback': 'off', + 'mocha/valid-suite-description': 'off', + 'mocha/valid-test-description': 'off', + 'mocha/no-async-describe': 'error', } } } From b3aa4a5e2640ae277d40987808fd9a6bf8b22184 Mon Sep 17 00:00:00 2001 From: Sander van Beek Date: Wed, 10 Jul 2019 11:30:33 +0200 Subject: [PATCH 2/4] Linter changes --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 109c0d0..7320489 100644 --- a/index.js +++ b/index.js @@ -27,7 +27,7 @@ module.exports = { recommended: { rules: { 'mocha/handle-done-callback': 'error', - 'mocha/max-top-level-suites': ['error', {limit: 1}], + 'mocha/max-top-level-suites': [ 'error', { limit: 1 } ], 'mocha/no-exclusive-tests': 'warn', 'mocha/no-global-tests': 'error', 'mocha/no-hooks': 'off', From b528be797ffde08f646d380000531db080e61e9d Mon Sep 17 00:00:00 2001 From: Sander van Beek Date: Wed, 10 Jul 2019 11:32:20 +0200 Subject: [PATCH 3/4] Linter changes --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7320489..011f730 100644 --- a/index.js +++ b/index.js @@ -45,7 +45,7 @@ module.exports = { 'mocha/prefer-arrow-callback': 'off', 'mocha/valid-suite-description': 'off', 'mocha/valid-test-description': 'off', - 'mocha/no-async-describe': 'error', + 'mocha/no-async-describe': 'error' } } } From 0f4ab832a2dee41d87b94df3a620ee24d1e74874 Mon Sep 17 00:00:00 2001 From: Sander van Beek Date: Tue, 16 Jul 2019 15:42:50 +0200 Subject: [PATCH 4/4] Updated README --- README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aba133a..3b7f406 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ ESLint rules for [mocha](http://mochajs.org/). This plugin requires ESLint `4.0.0` or later. -`npm install --save-dev eslint-plugin-mocha` +```bash +npm install --save-dev eslint-plugin-mocha +``` Then add a reference to this plugin and selected rules in your eslint config: @@ -21,16 +23,28 @@ Then add a reference to this plugin and selected rules in your eslint config: "plugins": [ "mocha" ], - "rules": { - "mocha/no-exclusive-tests": "error" - } } ``` + +### Recommended config + +This plugin exports a recommended config that enforces good practices. + +Enable it with the extends option: + +```json +{ + "extends": [ + "plugin:mocha/recommended" + ], +} +``` + See [Configuring Eslint](http://eslint.org/docs/user-guide/configuring) on [eslint.org](http://eslint.org) for more info. ## Rules documentation -The documentation of the rules can be found [here](docs/rules). +The documentation of the rules [can be found here](docs/rules). ## When Not To Use It