1 | [![NPM Version](https://img.shields.io/npm/v/eslint-plugin-mocha.svg?style=flat)](https://www.npmjs.org/package/eslint-plugin-mocha)
|
2 | [![GitHub Actions status](https://github.com/lo1tuma/eslint-plugin-mocha/workflows/CI/badge.svg)](https://github.com/lo1tuma/eslint-plugin-mocha/actions)
|
3 | [![Coverage Status](https://img.shields.io/coveralls/lo1tuma/eslint-plugin-mocha/master.svg?style=flat)](https://coveralls.io/r/lo1tuma/eslint-plugin-mocha)
|
4 | [![Peer Dependencies](http://img.shields.io/david/peer/lo1tuma/eslint-plugin-mocha.svg?style=flat)](https://david-dm.org/lo1tuma/eslint-plugin-mocha#info=peerDependencies&view=table)
|
5 | [![NPM Downloads](https://img.shields.io/npm/dm/eslint-plugin-mocha.svg?style=flat)](https://www.npmjs.org/package/eslint-plugin-mocha)
|
6 |
|
7 | # eslint-plugin-mocha
|
8 |
|
9 | ESLint rules for [mocha](http://mochajs.org/).
|
10 |
|
11 | ## Install and configure
|
12 |
|
13 | This plugin requires ESLint `4.0.0` or later.
|
14 |
|
15 | ```bash
|
16 | npm install --save-dev eslint-plugin-mocha
|
17 | ```
|
18 |
|
19 | Then add a reference to this plugin and selected rules in your eslint config:
|
20 |
|
21 | ```json
|
22 | {
|
23 | "plugins": [
|
24 | "mocha"
|
25 | ]
|
26 | }
|
27 | ```
|
28 |
|
29 | ### Plugin Settings
|
30 |
|
31 | This plugin supports the following settings, which are used by multiple rules:
|
32 |
|
33 | * `additionalCustomNames`: This allows rules to check additional function names when looking for suites or test cases. This might be used with a custom Mocha extension, such as [`ember-mocha`](https://github.com/switchfly/ember-mocha)
|
34 | **Example:**
|
35 |
|
36 | ```json
|
37 | {
|
38 | "rules": {
|
39 | "mocha/no-skipped-tests": "error",
|
40 | "mocha/no-exclusive-tests": "error"
|
41 | },
|
42 | "settings": {
|
43 | "mocha/additionalCustomNames": [
|
44 | { "name": "describeModule", "type": "suite", "interfaces": [ "BDD" ] },
|
45 | { "name": "testModule", "type": "testCase", "interfaces": [ "TDD" ] }
|
46 | ]
|
47 | }
|
48 | }
|
49 | ```
|
50 |
|
51 | ### Recommended config
|
52 |
|
53 | This plugin exports a recommended config that enforces good practices.
|
54 |
|
55 | Enable it with the extends option:
|
56 |
|
57 | ```json
|
58 | {
|
59 | "extends": [
|
60 | "plugin:mocha/recommended"
|
61 | ]
|
62 | }
|
63 | ```
|
64 |
|
65 | See [Configuring Eslint](http://eslint.org/docs/user-guide/configuring) on [eslint.org](http://eslint.org) for more info.
|
66 |
|
67 | ## Rules documentation
|
68 |
|
69 | The documentation of the rules [can be found here](docs/rules).
|