diff --git a/lib/utils.js b/lib/utils.js index ae708f80..d51b525c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,17 +3,18 @@ const { getStaticValue, findVariable } = require('eslint-utils'); const estraverse = require('estraverse'); +const functionTypes = [ + 'FunctionExpression', + 'ArrowFunctionExpression', + 'FunctionDeclaration', +]; + /** * Determines whether a node is a 'normal' (i.e. non-async, non-generator) function expression. * @param {ASTNode} node The node in question * @returns {boolean} `true` if the node is a normal function expression */ function isNormalFunctionExpression(node) { - const functionTypes = [ - 'FunctionExpression', - 'ArrowFunctionExpression', - 'FunctionDeclaration', - ]; return functionTypes.includes(node.type) && !node.generator && !node.async; } @@ -152,9 +153,7 @@ function getRuleExportsESM(ast, scopeManager) { possibleNodes.push( ...nodes.filter( (node) => - node && - node.type !== 'FunctionDeclaration' && - node.type !== 'FunctionExpression' + node && !functionTypes.includes(node.type) ) ); } diff --git a/tests/lib/utils.js b/tests/lib/utils.js index 0e8c83ea..eaf7a285 100644 --- a/tests/lib/utils.js +++ b/tests/lib/utils.js @@ -91,6 +91,7 @@ describe('utils', () => { 'export function foo(options) { return {}; }', 'export async function foo(options) { return {}; }', 'export const foo = function (options) { return {}; }', + 'export const foo = (options) => { return {}; }', 'export function foo(options) { return; }', 'export function foo({opt1, opt2}) { return {}; }',