File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change 33const  {  getStaticValue,  findVariable }  =  require ( 'eslint-utils' ) ; 
44const  estraverse  =  require ( 'estraverse' ) ; 
55
6+ const  functionTypes  =  new  Set ( [ 
7+  'FunctionExpression' , 
8+  'ArrowFunctionExpression' , 
9+  'FunctionDeclaration' , 
10+ ] ) ; 
11+ 
612/** 
713 * Determines whether a node is a 'normal' (i.e. non-async, non-generator) function expression. 
814 * @param  {ASTNode } node The node in question 
915 * @returns  {boolean } `true` if the node is a normal function expression 
1016 */ 
1117function  isNormalFunctionExpression ( node )  { 
12-  const  functionTypes  =  [ 
13-  'FunctionExpression' , 
14-  'ArrowFunctionExpression' , 
15-  'FunctionDeclaration' , 
16-  ] ; 
17-  return  functionTypes . includes ( node . type )  &&  ! node . generator  &&  ! node . async ; 
18+  return  functionTypes . has ( node . type )  &&  ! node . generator  &&  ! node . async ; 
1819} 
1920
2021/** 
@@ -150,12 +151,7 @@ function getRuleExportsESM(ast, scopeManager) {
150151 // skip if it's function-style to avoid false positives 
151152 // refs: https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/450 
152153 possibleNodes . push ( 
153-  ...nodes . filter ( 
154-  ( node )  => 
155-  node  && 
156-  node . type  !==  'FunctionDeclaration'  && 
157-  node . type  !==  'FunctionExpression' 
158-  ) 
154+  ...nodes . filter ( ( node )  =>  node  &&  ! functionTypes . has ( node . type ) ) 
159155 ) ; 
160156 } 
161157 break ; 
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ describe('utils', () => {
9191 'export function foo(options) { return {}; }' , 
9292 'export async function foo(options) { return {}; }' , 
9393 'export const foo = function (options) { return {}; }' , 
94+  'export const foo = (options) => { return {}; }' , 
9495 'export function foo(options) { return; }' , 
9596 'export function foo({opt1, opt2}) { return {}; }' , 
9697
                                 You can’t perform that action at this time. 
               
                  
0 commit comments