s-a / sublime-text-refactor

A Sublime Text Refactor Plugin for Javascript Code
213 stars 12 forks source link

Error when using ES6/7 features #34

Closed ilearnio closed 8 years ago

ilearnio commented 8 years ago

I have just installed it, seems t be a great plugin, but it gave me an error right away when I tried to rename a variable:

undefined:1534
    throw new JS_Parse_Error(message, filename, line, col, pos);
    ^
    Error
    at new JS_Parse_Error (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1526:18)
    at js_error (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1534:11)
    at parse_error (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1647:9)
    at Object.next_token [as input] (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1912:9)
    at next (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2012:25)
    at vardefs (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2433:48)
    at const_ (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2454:27)
    at eval (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2197:30)
    at eval (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2073:24)
    at eval (eval at <anonymous> (/Users/Admin/Library/Application Support/Sublime Text 3/Packages/JavaScript Refactor/js/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2827:23)

I reduced my code and found out the reason for this error. It seems that the package doesn't support ES6 strings, imports/exports, async/await etc. For example, this piece of code will fail:

import fs from 'fs'

const foo = `bar`
s-a commented 8 years ago

24