[utils] [refactor] `parse`: avoid using a regex here · import-js/eslint-plugin-import@3f1ac24

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -5,6 +5,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

55
66

## Unreleased

77
8+

### Changed

9+

- [refactor] `parse`: avoid using a regex here (thanks [@ljharb])

10+
811

## v2.12.0 - 2024-09-26

912
1013

### Added

Original file line numberDiff line numberDiff line change

@@ -33,7 +33,7 @@ function keysFromParser(parserPath, parserInstance, parsedResult) {

3333

// up with a `parsedResult` here. It also doesn't expose the visitor keys on the parser itself,

3434

// so we have to try and infer the visitor-keys module from the parserPath.

3535

// This is NOT supported in flat config!

36-

if (typeof parserPath === 'string' && (/.*babel-eslint.*/).test(parserPath)) {

36+

if (typeof parserPath === 'string' && parserPath.indexOf('babel-eslint') > -1) {

3737

return getBabelEslintVisitorKeys(parserPath);

3838

}

3939

// The espree parser doesn't have the `parseForESLint` function, so we don't end up with a