This repository has been archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rule): add eslint-plugin-mocha ☕️
- Loading branch information
1 parent
9a3165f
commit 87fd555
Showing
9 changed files
with
156 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Mocha | ||
|
||
These configuration files are suitable to lint Mocha test files. | ||
|
||
## Configurations | ||
|
||
### @strv/javascript/environments/mocha/recommended | ||
|
||
Use this ruleset to configure ESLint to lint your Mocha test files. Mocha test files are by default identified by `*.test.*` or `*.spec.*` filenames or by being in the _test/_ directory in your project root. | ||
|
||
> ⚠️ You can use this environment ruleset in combination with any of the existing environment rulesets. Just make sure this one comes in as the last one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Js-coding-standards | ||
* | ||
* @author Robert Rossmann <[email protected]> | ||
* @copyright 2018 STRV | ||
* @license http://choosealicense.com/licenses/bsd-3-clause BSD-3-Clause License | ||
*/ | ||
|
||
'use strict' | ||
|
||
const globs = require('../../globs') | ||
|
||
module.exports = { | ||
|
||
overrides: [{ | ||
files: globs.test, | ||
|
||
plugins: [ | ||
'mocha', | ||
], | ||
|
||
env: { | ||
mocha: true, | ||
}, | ||
|
||
rules: { | ||
// Enforces handling of callbacks for async tests | ||
// Mocha allows you to write asynchronous tests by adding a done callback to the parameters of | ||
// your test function. It is easy to forget calling this callback after the asynchronous | ||
// operation is done. | ||
// @TODO (semver-major): Raise to `error` | ||
'mocha/handle-done-callback': 'warn', | ||
|
||
// Limit the number of top-level suites in a single file | ||
// This rule enforces having a limited amount of top-level suites in a file. | ||
'mocha/max-top-level-suites': ['warn', { limit: 1 }], | ||
|
||
// Disallow exclusive tests | ||
// This rule reminds you to remove .only from your tests by raising a warning whenever you are | ||
// using the exclusivity feature. | ||
'mocha/no-exclusive-tests': 'warn', | ||
|
||
// Disallow global tests | ||
// This rule checks each mocha test function to not be located directly in the global scope. | ||
'mocha/no-global-tests': 'warn', | ||
|
||
// Disallow identical titles | ||
// This rule looks at the title of every test and test suites. It will report when two test | ||
// suites or two test cases at the same level of a test suite have the same title. | ||
'mocha/no-identical-title': 'warn', | ||
|
||
// Disallow tests to be nested within other tests | ||
// This rule looks for all test cases (it, specify and test) or suites (describe, context and | ||
// suite) which are nested within another test case. | ||
// @TODO (semver-major): Raise to `error` | ||
'mocha/no-nested-tests': 'warn', | ||
|
||
// Disallow returning in a test or hook function that uses a callback | ||
// Mocha's tests or hooks (like before) may be asynchronous by either returning a Promise or | ||
// specifying a callback parameter for the function. It can be confusing to have both methods | ||
// used in a test or hook, and from Mocha v3 on, causes the test to fail in order to force | ||
// developers to remove this source of confusion. | ||
// @TODO (semver-major): Raise to `error` | ||
'mocha/no-return-and-callback': 'warn', | ||
|
||
// Disallow setup in describe blocks | ||
// Any setup directly in a describe is run before all tests execute. This rule reports all | ||
// function calls and use of the dot operator (due to getters and setters) directly in | ||
// describe blocks. | ||
'mocha/no-setup-in-describe': 'warn', | ||
}, | ||
}], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters