diff --git a/CHANGELOG.md b/CHANGELOG.md index a2a782c3..ae17dbeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,13 @@ * update dependency markdownlint-cli to ^0.38.0 ([#410](https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/410)) ([6b53c5b](https://github.com/eslint-community/eslint-plugin-eslint-plugin/commit/6b53c5b7b8bc9e19dcb86796ab29019f89c449fc)) * update dependency markdownlint-cli to ^0.39.0 ([#431](https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/431)) ([f005a2c](https://github.com/eslint-community/eslint-plugin-eslint-plugin/commit/f005a2c0231b8b77f6862dca81b4a6e3099e0493)) +## [5.5.1](https://github.com/eslint-community/eslint-plugin-eslint-plugin/compare/v5.5.0...v5.5.1) (2024-04-08) + + +### Bug Fixes + +* improve eslint rule detecting ([#457](https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/457)) ([5dccb61](https://github.com/eslint-community/eslint-plugin-eslint-plugin/commit/5dccb61cc8a732947689e523cfd9dd1adf611ca3)) + ## [5.5.0](https://github.com/eslint-community/eslint-plugin-eslint-plugin/compare/v5.4.1...v5.5.0) (2024-04-01) diff --git a/lib/utils.js b/lib/utils.js index ae708f80..c1be12c2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,18 +3,19 @@ const { getStaticValue, findVariable } = require('eslint-utils'); const estraverse = require('estraverse'); +const functionTypes = new Set([ + '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; + return functionTypes.has(node.type) && !node.generator && !node.async; } /** @@ -150,12 +151,7 @@ function getRuleExportsESM(ast, scopeManager) { // skip if it's function-style to avoid false positives // refs: https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/450 possibleNodes.push( - ...nodes.filter( - (node) => - node && - node.type !== 'FunctionDeclaration' && - node.type !== 'FunctionExpression' - ) + ...nodes.filter((node) => node && !functionTypes.has(node.type)) ); } break; diff --git a/package.json b/package.json index a3e181d1..839a723b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-eslint-plugin", - "version": "5.5.0", + "version": "5.5.1", "description": "An ESLint plugin for linting ESLint plugins", "author": "Teddy Katz", "main": "./lib/index.js", 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 {}; }',