Skip to content

Commit

Permalink
utils: [New] Print more helpful info if parsing fails
Browse files Browse the repository at this point in the history
If parsing fails, the only message printed to the console is vague and
mostly unhelpful. Print some information about the source of the error
to make debugging easy.
  • Loading branch information
kaiyoma authored and ljharb committed Mar 1, 2020
1 parent b6242b0 commit adbced7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions utils/CHANGELOG.md
Expand Up @@ -5,6 +5,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

## Unreleased

### Added
[New] Print more helpful info if parsing fails ([#1671], thanks [@kaiyoma])

## v2.5.2 - 2020-01-12

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

[#1671]: https://github.com/benmosher/eslint-plugin-import/pull/1671
[#1606]: https://github.com/benmosher/eslint-plugin-import/pull/1606
[#1602]: https://github.com/benmosher/eslint-plugin-import/pull/1602
[#1591]: https://github.com/benmosher/eslint-plugin-import/pull/1591
Expand All @@ -94,3 +98,4 @@ Yanked due to critical issue with cache key resulting from #839.
[@arcanis]: https://github.com/arcanis
[@sompylasar]: https://github.com/sompylasar
[@iamnapo]: https://github.com/iamnapo
[@kaiyoma]: https://github.com/kaiyoma
4 changes: 3 additions & 1 deletion utils/parse.js
Expand Up @@ -47,7 +47,9 @@ exports.default = function parse(path, content, context) {
try {
ast = parser.parseForESLint(content, parserOptions).ast
} catch (e) {
//
console.warn()
console.warn('Error while parsing ' + parserOptions.filePath)
console.warn('Line ' + e.lineNumber + ', column ' + e.column + ': ' + e.message)
}
if (!ast || typeof ast !== 'object') {
console.warn(
Expand Down

0 comments on commit adbced7

Please sign in to comment.