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
/
recommended.js
76 lines (61 loc) · 2.89 KB
/
recommended.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* 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: {
// Set Maximum Depth of Nested Callbacks
// This rule is aimed at increasing code clarity by discouraging deeply nesting callbacks.
// Allow some extra nesting for Mocha tests, due to Mocha's test coding patterns encouraging
// some extra callback nesting.
'max-nested-callbacks': ['warn', 6],
// 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.
'mocha/handle-done-callback': 'error',
// 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.
'mocha/no-nested-tests': 'error',
// 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.
'mocha/no-return-and-callback': 'error',
// 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',
},
}],
}