brenolf / polyjuice

A utility to convert JSHint and JSCS files into ESLint files and vice-versa
MIT License
275 stars 15 forks source link

TypeError: Cannot read property 'align' of undefined #25

Closed brendanvinson closed 8 years ago

brendanvinson commented 8 years ago

Here's the error I'm getting:

/node_modules/polyjuice/lib/dictionaries/eslint.js:441
if (value[1].align === 'colon') {
            ^

TypeError: Cannot read property 'align' of undefined
    at module.exports.key-spacing.eval (/usr/local/lib/node_modules/polyjuice/lib/dictionaries/eslint.js:441:19)
    at get (/usr/local/lib/node_modules/polyjuice/lib/polyjuice/reader.js:29:33)
    at module.exports (/usr/local/lib/node_modules/polyjuice/lib/polyjuice/interpreter.js:27:24)
    at module.exports (/usr/local/lib/node_modules/polyjuice/lib/polyjuice/eslint.js:18:10)
    at Object.module.exports.to.jscs (/usr/local/lib/node_modules/polyjuice/lib/polyjuice.js:32:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/polyjuice/lib/bin.js:56:32)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)

It looks like if value is 0, the if (value[0] === 0) check and return doesn't catch and tries to parse the rest of the function.

brenolf commented 8 years ago

Thanks for noticing this @brendanvinson, I just enhanced that check allowing 0 as a value. I didn't know it would be possible by looking at the ESLint docs, but there you are.