File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ import { TSESTree } from '@typescript-eslint/experimental-utils' ;
7
+ import * as eslint from 'eslint' ;
8
+
9
+ function isCallExpression ( node : TSESTree . Node ) : node is TSESTree . CallExpression {
10
+ return node . type === 'CallExpression' ;
11
+ }
12
+
13
+ function isFunctionExpression ( node : TSESTree . Node ) : node is TSESTree . FunctionExpression {
14
+ return node . type . includes ( 'FunctionExpression' ) ;
15
+ }
16
+
17
+ export = new class NoAsyncSuite implements eslint . Rule . RuleModule {
18
+
19
+ create ( context : eslint . Rule . RuleContext ) : eslint . Rule . RuleListener {
20
+ function hasAsyncSuite ( node : any ) {
21
+ if ( isCallExpression ( node ) && node . arguments . length >= 2 && isFunctionExpression ( node . arguments [ 1 ] ) && node . arguments [ 1 ] . async ) {
22
+ return context . report ( {
23
+ node : node as any ,
24
+ message : 'suite factory function should never be async'
25
+ } ) ;
26
+ }
27
+ }
28
+
29
+ return {
30
+ [ 'CallExpression[callee.name=/suite$/][arguments]' ] : hasAsyncSuite ,
31
+ } ;
32
+ }
33
+ } ;
Original file line number Diff line number Diff line change 120
120
],
121
121
"rules" : {
122
122
"local/code-no-test-only" : " error" ,
123
+ "local/code-no-test-async-suite" : " warn" ,
123
124
"local/code-no-unexternalized-strings" : " off"
124
125
}
125
126
},
You can’t perform that action at this time.
0 commit comments