@@ -38,13 +38,16 @@ export const baseSpecRules = {
38
38
} ;
39
39
40
40
/**
41
+ * @param {Object } [options]
42
+ * @param {boolean } [options.useMocha]
41
43
* @returns {import('eslint').Linter.Config[] }
42
44
*/
43
- export function createTestConfig ( ) {
45
+ export function createTestConfig ( options = { } ) {
46
+ const { useMocha = true } = options ;
44
47
return /** @type {import('eslint').Linter.Config[] } */ (
45
48
tseslint . config (
46
49
// @ts -expect-error The types don't make sense here.
47
- mochaPlugin . configs . recommended ,
50
+ useMocha ? mochaPlugin . configs . recommended : null ,
48
51
testingLibrary . configs [ 'flat/dom' ] ,
49
52
testingLibrary . configs [ 'flat/react' ] ,
50
53
{
@@ -59,23 +62,6 @@ export function createTestConfig() {
59
62
// does not work with wildcard imports. Mistakes will throw at runtime anyway
60
63
'import/named' : 'off' ,
61
64
'material-ui/disallow-active-element-as-key-event-target' : 'error' ,
62
- 'mocha/consistent-spacing-between-blocks' : 'off' ,
63
-
64
- // upgraded level from recommended
65
- 'mocha/no-pending-tests' : 'error' ,
66
-
67
- // no rationale provided in /recommended
68
- 'mocha/no-mocha-arrows' : 'off' ,
69
- // definitely a useful rule but too many false positives
70
- // due to `describeConformance`
71
- // "If you're using dynamically generated tests, you should disable this rule.""
72
- 'mocha/no-setup-in-describe' : 'off' ,
73
- // `beforeEach` for a single case is optimized for change
74
- // when we add a test we don't have to refactor the existing
75
- // test to `beforeEach`.
76
- // `beforeEach`+`afterEach` also means that the `beforeEach`
77
- // is cleaned up in `afterEach` if the test causes a crash
78
- 'mocha/no-hooks-for-single-case' : 'off' ,
79
65
80
66
// disable eslint-plugin-jsx-a11y
81
67
// tests are not driven by assistive technology
@@ -97,6 +83,27 @@ export function createTestConfig() {
97
83
// that they don't need type-checking
98
84
'react/prop-types' : 'off' ,
99
85
'react/no-unused-prop-types' : 'off' ,
86
+ ...( useMocha
87
+ ? {
88
+ 'mocha/consistent-spacing-between-blocks' : 'off' ,
89
+
90
+ // upgraded level from recommended
91
+ 'mocha/no-pending-tests' : 'error' ,
92
+
93
+ // no rationale provided in /recommended
94
+ 'mocha/no-mocha-arrows' : 'off' ,
95
+ // definitely a useful rule but too many false positives
96
+ // due to `describeConformance`
97
+ // "If you're using dynamically generated tests, you should disable this rule.""
98
+ 'mocha/no-setup-in-describe' : 'off' ,
99
+ // `beforeEach` for a single case is optimized for change
100
+ // when we add a test we don't have to refactor the existing
101
+ // test to `beforeEach`.
102
+ // `beforeEach`+`afterEach` also means that the `beforeEach`
103
+ // is cleaned up in `afterEach` if the test causes a crash
104
+ 'mocha/no-hooks-for-single-case' : 'off' ,
105
+ }
106
+ : { } ) ,
100
107
} ,
101
108
} ,
102
109
)
0 commit comments