File tree 2 files changed +9
-8
lines changed 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 3
3
const { getStaticValue, findVariable } = require ( 'eslint-utils' ) ;
4
4
const estraverse = require ( 'estraverse' ) ;
5
5
6
+ const functionTypes = [
7
+ 'FunctionExpression' ,
8
+ 'ArrowFunctionExpression' ,
9
+ 'FunctionDeclaration' ,
10
+ ] ;
11
+
6
12
/**
7
13
* Determines whether a node is a 'normal' (i.e. non-async, non-generator) function expression.
8
14
* @param {ASTNode } node The node in question
9
15
* @returns {boolean } `true` if the node is a normal function expression
10
16
*/
11
17
function isNormalFunctionExpression ( node ) {
12
- const functionTypes = [
13
- 'FunctionExpression' ,
14
- 'ArrowFunctionExpression' ,
15
- 'FunctionDeclaration' ,
16
- ] ;
17
18
return functionTypes . includes ( node . type ) && ! node . generator && ! node . async ;
18
19
}
19
20
@@ -152,9 +153,7 @@ function getRuleExportsESM(ast, scopeManager) {
152
153
possibleNodes . push (
153
154
...nodes . filter (
154
155
( node ) =>
155
- node &&
156
- node . type !== 'FunctionDeclaration' &&
157
- node . type !== 'FunctionExpression'
156
+ node && ! functionTypes . includes ( node . type )
158
157
)
159
158
) ;
160
159
}
Original file line number Diff line number Diff line change @@ -93,6 +93,8 @@ describe('utils', () => {
93
93
'export const foo = function (options) { return {}; }' ,
94
94
'export function foo(options) { return; }' ,
95
95
'export function foo({opt1, opt2}) { return {}; }' ,
96
+ 'export async function foo({opt1, opt2}) { return {}; }' ,
97
+ 'export const foo = async function (options) { return {}; }' ,
96
98
97
99
// Incorrect TypeScript helper structure:
98
100
'export default foo()({ create() {}, meta: {} });' ,
You can’t perform that action at this time.
0 commit comments