Skip to content

Commit adbced7

Browse files
kgetz-aristaljharb
authored andcommitted
utils: [New] Print more helpful info if parsing fails
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.
1 parent b6242b0 commit adbced7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

utils/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
55

66
## Unreleased
77

8+
### Added
9+
[New] Print more helpful info if parsing fails ([#1671], thanks [@kaiyoma])
10+
811
## v2.5.2 - 2020-01-12
912

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

76+
[#1671]: https://github.com/benmosher/eslint-plugin-import/pull/1671
7377
[#1606]: https://github.com/benmosher/eslint-plugin-import/pull/1606
7478
[#1602]: https://github.com/benmosher/eslint-plugin-import/pull/1602
7579
[#1591]: https://github.com/benmosher/eslint-plugin-import/pull/1591
@@ -94,3 +98,4 @@ Yanked due to critical issue with cache key resulting from #839.
9498
[@arcanis]: https://github.com/arcanis
9599
[@sompylasar]: https://github.com/sompylasar
96100
[@iamnapo]: https://github.com/iamnapo
101+
[@kaiyoma]: https://github.com/kaiyoma

utils/parse.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ exports.default = function parse(path, content, context) {
4747
try {
4848
ast = parser.parseForESLint(content, parserOptions).ast
4949
} catch (e) {
50-
//
50+
console.warn()
51+
console.warn('Error while parsing ' + parserOptions.filePath)
52+
console.warn('Line ' + e.lineNumber + ', column ' + e.column + ': ' + e.message)
5153
}
5254
if (!ast || typeof ast !== 'object') {
5355
console.warn(

0 commit comments

Comments
 (0)