From 3f1ac249272db87f0191727beeaa368fcbe7aab4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 3 Oct 2024 13:15:10 +0700 Subject: [PATCH] [utils] [refactor] `parse`: avoid using a regex here --- utils/CHANGELOG.md | 3 +++ utils/parse.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/CHANGELOG.md b/utils/CHANGELOG.md index 619d05063..bb9372512 100644 --- a/utils/CHANGELOG.md +++ b/utils/CHANGELOG.md @@ -5,6 +5,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ## Unreleased +### Changed +- [refactor] `parse`: avoid using a regex here (thanks [@ljharb]) + ## v2.12.0 - 2024-09-26 ### Added diff --git a/utils/parse.js b/utils/parse.js index 03022ac40..793e37152 100644 --- a/utils/parse.js +++ b/utils/parse.js @@ -33,7 +33,7 @@ function keysFromParser(parserPath, parserInstance, parsedResult) { // up with a `parsedResult` here. It also doesn't expose the visitor keys on the parser itself, // so we have to try and infer the visitor-keys module from the parserPath. // This is NOT supported in flat config! - if (typeof parserPath === 'string' && (/.*babel-eslint.*/).test(parserPath)) { + if (typeof parserPath === 'string' && parserPath.indexOf('babel-eslint') > -1) { return getBabelEslintVisitorKeys(parserPath); } // The espree parser doesn't have the `parseForESLint` function, so we don't end up with a