Skip to content

Commit 408f59a

Browse files
committed
fix: improve eslint rule detecting
fixes #455
1 parent 3d12851 commit 408f59a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/utils.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
const { getStaticValue, findVariable } = require('eslint-utils');
44
const estraverse = require('estraverse');
55

6+
const functionTypes = [
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
*/
1117
function isNormalFunctionExpression(node) {
12-
const functionTypes = [
13-
'FunctionExpression',
14-
'ArrowFunctionExpression',
15-
'FunctionDeclaration',
16-
];
1718
return functionTypes.includes(node.type) && !node.generator && !node.async;
1819
}
1920

@@ -152,9 +153,7 @@ function getRuleExportsESM(ast, scopeManager) {
152153
possibleNodes.push(
153154
...nodes.filter(
154155
(node) =>
155-
node &&
156-
node.type !== 'FunctionDeclaration' &&
157-
node.type !== 'FunctionExpression'
156+
node && !functionTypes.includes(node.type)
158157
)
159158
);
160159
}

tests/lib/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)