Console removal fails with "Cannot read property 'type' of undefined"
parkan opened this issue · comments
[master//groundskeeper]% ./bin/groundskeeper < foo.js (ark@xx:~/groundskeeper/)
TypeError: Cannot read property 'type' of undefined
at Groundskeeper.removeConsole (/home/ark/groundskeeper/lib/groundskeeper.js:140:20)
at Groundskeeper.<anonymous> (/home/ark/groundskeeper/lib/groundskeeper.js:119:18)
at walk (/home/ark/groundskeeper/node_modules/falafel/index.js:60:9)
at /home/ark/groundskeeper/node_modules/falafel/index.js:57:17
at Array.forEach (native)
at forEach (/home/ark/groundskeeper/node_modules/falafel/index.js:8:31)
at walk (/home/ark/groundskeeper/node_modules/falafel/index.js:44:9)
at /home/ark/groundskeeper/node_modules/falafel/index.js:57:17
at Array.forEach (native)
at forEach (/home/ark/groundskeeper/node_modules/falafel/index.js:8:31)
Looks like an ast node is empty? File passes esvalidate.
Looks like this choked on:
typeof console !== 'undefined'
Seems to fail on any UnaryExpression. To be fair, it's unlikely you need to use those except for custom console wrappers :)
I've tried to reproduce your case with the version in the dev branch and your problem seems to be fixed, at least according to my tests.
If you're on a pinch, you can use that version, I'll merge both branches as soon as the dev branch is stable.
Thanks for reporting your case, please continue reporting if you find more cases where groundskeeper chokes =)