royriojas / esformatter-jsx

esformatter plugin: format jsx files (or js files with Facebook React JSX Syntax)
MIT License
142 stars 25 forks source link

Error formatting Windows line ending CRLF files #80

Open abbr opened 8 years ago

abbr commented 8 years ago

Following error is thrown in console when saving files with CRLF line ending on Windows. On the same machine unix line ending files work fine.

error: The formatting failed please check the console for more details.

JSFMT ==>
Error: C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\jsfmt.js:31

        throw err; CR

        ^CR

SyntaxError: Unexpected token (11:4) CR

    at Parser.pp.raise (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\parser\location.js:24:13)

    at Parser.pp.unexpected (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\parser\util.js:91:8)

    at Parser.pp.jsxParseIdentifier (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:216:10)

    at Parser.pp.jsxParseNamespacedName (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:227:19)

    at Parser.pp.jsxParseAttribute (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:309:20)

    at Parser.pp.jsxParseOpeningElementAt (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:321:31)

    at Parser.pp.jsxParseElementAt (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:343:29)

    at Parser.pp.jsxParseElementAt (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:356:30)

    at Parser.pp.jsxParseElement (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:392:15)

    at Parser.parseExprAtom (C:\Users\x\AppData\Roaming\Sublime Text 3\Packages\jsfmt\node_modules\esformatter-jsx\node_modules\babylon\lib\plugins\jsx\index.js:404:21)
royriojas commented 8 years ago

Hi @abbr,

thanks for reporting. I don't actively use windows so I'm not sure I can test this, but it should not be an issue. Can you try copy pasting the code here: royriojas.com/resources/esformatter-jsx and verify if the issue can be reproduced?

Regards