Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## Unreleased

### Fixed
- [patch] Fix `@babel/eslint-parser` 8 compatibility ([#2343], thanks [@nicolo-ribaudo])

## v2.7.1 - 2021-10-13

### Fixed
- fixed SyntaxError in node <= 6: Unexpected token ) in parse.js ([#2261], thanks [@VitusFW])
- fixed SyntaxError in node <= 6: Unexpected token ) in parse.js ([#2261], thanks [@VitusFW])

## v2.7.0 - 2021-10-11

Expand Down Expand Up @@ -102,6 +105,7 @@ Yanked due to critical issue with cache key resulting from #839.
### Fixed
- `unambiguous.test()` regex is now properly in multiline mode

[#2343]: https://github.com/import-js/eslint-plugin-import/pull/2343
[#2261]: https://github.com/import-js/eslint-plugin-import/pull/2261
[#2212]: https://github.com/import-js/eslint-plugin-import/pull/2212
[#2160]: https://github.com/import-js/eslint-plugin-import/pull/2160
Expand Down Expand Up @@ -138,6 +142,7 @@ Yanked due to critical issue with cache key resulting from #839.
[@manuth]: https://github.com/manuth
[@maxkomarychev]: https://github.com/maxkomarychev
[@mgwalker]: https://github.com/mgwalker
[@nicolo-ribaudo]: https://github.com/nicolo-ribaudo
[@pmcelhaney]: https://github.com/pmcelhaney
[@sergei-startsev]: https://github.com/sergei-startsev
[@sompylasar]: https://github.com/sompylasar
Expand Down
21 changes: 7 additions & 14 deletions utils/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,27 @@ const fs = require('fs');

const log = require('debug')('eslint-plugin-import:parse');

function getBabelVisitorKeys(parserPath) {
function getBabelEslintVisitorKeys(parserPath) {
if (parserPath.endsWith('index.js')) {
const hypotheticalLocation = parserPath.replace('index.js', 'visitor-keys.js');
if (fs.existsSync(hypotheticalLocation)) {
const keys = moduleRequire(hypotheticalLocation);
return keys.default || keys;
}
} else if (parserPath.endsWith('index.cjs')) {
const hypotheticalLocation = parserPath.replace('index.cjs', 'worker/ast-info.cjs');
if (fs.existsSync(hypotheticalLocation)) {
const astInfo = moduleRequire(hypotheticalLocation);
return astInfo.getVisitorKeys();
}
}
return null;
}

function keysFromParser(parserPath, parserInstance, parsedResult) {
// Exposed by @typescript-eslint/parser and @babel/eslint-parser
if (parsedResult && parsedResult.visitorKeys) {
return parsedResult.visitorKeys;
}
if (/.*espree.*/.test(parserPath)) {
return parserInstance.VisitorKeys;
}
if (/.*(babel-eslint|@babel\/eslint-parser).*/.test(parserPath)) {
return getBabelVisitorKeys(parserPath);
}
if (/.*@typescript-eslint\/parser/.test(parserPath)) {
if (parsedResult) {
return parsedResult.visitorKeys;
}
if (/.*babel-eslint.*/.test(parserPath)) {
return getBabelEslintVisitorKeys(parserPath);
}
return null;
}
Expand Down