From 5dccb61cc8a732947689e523cfd9dd1adf611ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=AF=E7=84=B6?= Date: Mon, 8 Apr 2024 17:09:55 +0800 Subject: [PATCH 1/2] fix: improve eslint rule detecting (#457) fixes https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/455 --- lib/utils.js | 20 ++++++++------------ tests/lib/utils.js | 1 + 2 files changed, 9 insertions(+), 12 deletions(-) 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/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 {}; }', From a424b277399ec9254f82f4d13fa428c7fee902af Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:10:48 +0800 Subject: [PATCH 2/2] chore(main): release 5.5.1 (#458) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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/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",