10.4.3 • Published 8 days ago

eslint-plugin-mocha v10.4.3

Weekly downloads
519,958
License
MIT
Repository
github
Last release
8 days ago

NPM Version GitHub Actions status Coverage Status NPM Downloads

eslint-plugin-mocha

ESLint rules for mocha.

Install and configure

This plugin requires ESLint 4.0.0 or later.

npm install --save-dev eslint-plugin-mocha

.eslintrc.json

Then add a reference to this plugin and selected rules in your eslint config:

{
    "plugins": [
        "mocha"
    ]
}

eslint.config.js (requires eslint >= 8.23.0)

To use this plugin with the new eslint configuration format (flat config):

import mochaPlugin from 'eslint-plugin-mocha';

export default [
    mochaPlugin.configs.flat.recommended // or `mochaPlugin.configs.flat.all` to enable all
    // ... Your configurations here
];

Plugin Settings

This plugin supports the following settings, which are used by multiple rules:

  • 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 or mocha-each.

    Example:

    {
        "rules": {
            "mocha/no-skipped-tests": "error",
            "mocha/no-exclusive-tests": "error"
        },
        "settings": {
            "mocha/additionalCustomNames": [
                { "name": "describeModule", "type": "suite", "interfaces": [ "BDD" ] },
                { "name": "testModule", "type": "testCase", "interfaces": [ "TDD" ] }
            ]
        }
    }

    The name property can be in any of the following forms:

    • A plain name e.g. describeModule, which allows:

      describeModule("example", function() { ... });
    • A dotted name, e.g. describe.modifier, which allows:

      describe.modifier("example", function() { ... });
    • A name with parentheses, e.g. forEach().describe, which allows:

      forEach([ 1, 2, 3 ])
          .describe("example", function(n) { ... });
    • Any combination of the above, e.g. forEach().describeModule.modifier, which allows:

      forEach([ 1, 2, 3 ])
          .describeModule.modifier("example", function(n) { ... });

Configs

recommended

This plugin exports a recommended config that enforces good practices.

Enable it with the extends option:

{
    "extends": [
        "plugin:mocha/recommended"
    ]
}

all

There's also a configuration that enables all of our rules.

See Configuring Eslint on eslint.org for more info.

Rules

💼 Configurations enabled in.\ ⚠️ Configurations set to warn in.\ 🚫 Configurations disabled in.\ ✅ Set in the recommended configuration.\ 🔧 Automatically fixable by the --fix CLI option.

Name                             Description💼⚠️🚫🔧
consistent-spacing-between-blocksRequire consistent spacing between blocks🔧
handle-done-callbackEnforces handling of callbacks for async tests
max-top-level-suitesEnforce the number of top-level suites in a single file
no-async-describeDisallow async functions passed to describe🔧
no-empty-descriptionDisallow empty test descriptions
no-exclusive-testsDisallow exclusive tests
no-exportsDisallow exports from test files
no-global-testsDisallow global tests
no-hooksDisallow hooks
no-hooks-for-single-caseDisallow hooks for a single test or test suite
no-identical-titleDisallow identical titles
no-mocha-arrowsDisallow arrow functions as arguments to mocha functions🔧
no-nested-testsDisallow tests to be nested within other tests
no-pending-testsDisallow pending tests
no-return-and-callbackDisallow returning in a test or hook function that uses a callback
no-return-from-asyncDisallow returning from an async test or hook
no-setup-in-describeDisallow setup in describe blocks
no-sibling-hooksDisallow duplicate uses of a hook at the same level inside a describe
no-skipped-testsDisallow skipped tests
no-synchronous-testsDisallow synchronous tests
no-top-level-hooksDisallow top-level hooks
prefer-arrow-callbackRequire using arrow functions for callbacks🔧
valid-suite-descriptionRequire suite descriptions to match a pre-configured regular expression
valid-test-descriptionRequire test descriptions to match a pre-configured regular expression
@hokify/eslint-config@oliveiraswell/eslint-config-oliveiraswell-js@rock-kit/ui-eslint-config@ffbutton/eslint-config-baseeslint-config-superstricteslint-config-quartzslm_cdk@oliveiraswell/eslint-config-dasa-health-jspm-test-pkgpm-ds-target-pkgeslint-config-happyeslint-config-neaf@temporg/config-eslint@temporg/ui-eslint-configeslint-config-loanmarket-react@remotezygote/eslintrcrel-engageeslint-config-tierioneslint-config-quark@infinitebrahmanuniverse/nolb-eslint-plugin-m@mediatool/eslint-config-mediatooleslint-config-wunderflats@everything-registry/sub-chunk-1612@withbluedot/eslint-plugin-ghosteslint-plugin-dwc@katieboland/eslint-config-katieboland@kabalpt/eslint-react@kdominic909/polyfill@leblanccodes/eslint-config@kudobuzz/kbscripts@logojoy/eslint-config-mocha@loopback/eslint-config@ibomorrissey/dashboard@ibomorrissey/shoppy@icplatform/eslint-config-mocha@mishguru/eslint-config@offirmo/unit-test-toolbox@numso/eslint-config-numso@open-xchange/eslint-config-frontend-standard@octoguild/eslint-config-servergrunt-appc-js@mesaic/eslint-config-mesaic@metarouter/analytics.js-integrations@mongodb-js/devtools-docker-test-envs@mongodb-js/eslint-config-compass@mongodb-js/eslint-config-devtools@naturacosmeticos/eslint-config-natura@neodon/eslint-config@neovici/cfg@neovici/eslint-config@neovici/paper-autocomplete@labforward/eslint-config-cypress@lambdaschool/eslint-config@kiwicom/eslint-config-kiwicom-cypress@kamikai/eslint-config-natura-typescript@kamataryo/eslint-config-standard@rinaudokasia/checker@rinaudokasia/manage@redisrupt/eslint-red@rarescrisan/eslint-config-mochainception-standard@roleup/eslint-config@rpapeters/paper-autocompleteinteractive-stateful-process@poddify/eslint-config-poddify@js-soft/eslint-config-ts@jneander/dev-lint@rahil-p/eslint-config-test@pulumi/compliance-policies-unit-test-helpers@pythoncoderas/eslint-config-oclif@pythoncoderas/eslint-config-oclif-typescript@osedea/eslint-config@puresec/eslint-config-base@sifrr/eslint-config@sealsystems/eslint@sealsystems/eslint-config-es@sektek/eslint-plugin@shoutem/clijsh-lint@shiftsmartinc/dotfiles@sisense/eslint-config@sinonjs/eslint-config@sky-uk/eslint-config-sky-mocha@saritasa/react-scripts@passiontrade/pt-react-scripts@plyo/dev-tools@porch/eslint-config-porch@porchdotcom/eslint-config-porch@tetu_io/tetu-converter@springworks/spw-cli@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@swensonpn/proposal-es-build-scripts@toruslabs/eslint-config-react@toruslabs/eslint-config-typescript@toruslabs/eslint-config-vue@stepanjakl/apostrophe-read-only-field@stepanjakl/apostrophe-stripe-checkout@stheine/helperskarma-webpack-bundle@thermopylae/dev.environment
10.4.3

8 days ago

10.4.2

17 days ago

10.4.1

2 months ago

10.4.0

2 months ago

10.3.0

2 months ago

10.2.0

7 months ago

10.0.5

2 years ago

10.1.0

2 years ago

10.0.4

2 years ago

10.0.0

2 years ago

10.0.1

2 years ago

10.0.2

2 years ago

10.0.3

2 years ago

8.2.0

3 years ago

9.0.0

3 years ago

8.1.0

3 years ago

8.0.0

4 years ago

7.0.1

4 years ago

7.0.0

4 years ago

6.3.0

4 years ago

6.2.2

4 years ago

6.2.1

5 years ago

6.2.0

5 years ago

6.1.1

5 years ago

6.1.0

5 years ago

6.0.0

5 years ago

5.3.0

5 years ago

5.2.1

5 years ago

5.2.0

6 years ago

5.1.0

6 years ago

5.0.0

6 years ago

4.12.1

6 years ago

4.12.0

6 years ago

4.11.0

7 years ago

4.10.1

7 years ago

4.10.0

7 years ago

4.9.0

7 years ago

4.8.0

7 years ago

4.7.0

8 years ago

4.6.0

8 years ago

4.5.1

8 years ago

4.5.0

8 years ago

4.4.0

8 years ago

4.3.0

8 years ago

4.2.0

8 years ago

4.1.0

8 years ago

4.0.0

8 years ago

3.0.0

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.1.0

8 years ago

1.0.0

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago