brackets-beautify
brackets-beautify copied to clipboard
brackets-beautify breaking code by inserting space in import(...)
I tried to edit a file with beautify on save turn on and disaster
https://github.com/davsk/website/blob/master/src/my-app.js
I am using:
- brackets-beautify 1.0.2
- Polymer 3.x polymer-cli v1.7.1
This bit of code is from the Polymer 3.x starter-kit.
import('./my-view1.js');
brackets-beautify inserts a space
import ('./my-view1.js');
which causes the following error
PS C:\Users\skinn\local\src\davsk.net\website> polymer build
info: [cli.command.build] Clearing build\ directory...
error: [cli.main] Promise rejection: Error: 'import' and 'export' may only appear at the top level
error: [cli.main] Error: 'import' and 'export' may only appear at the top level
at error (C:\Users\skinn\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\rollup\dist\rollup.js:199:15)
at Module.error (C:\Users\skinn\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\rollup\dist\rollup.js:1694
7:9)
at tryParse (C:\Users\skinn\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\rollup\dist\rollup.js:16625:16
)
at Module.setSource (C:\Users\skinn\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\rollup\dist\rollup.js:
16689:33)
at C:\Users\skinn\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\rollup\dist\rollup.js:20589:20
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
This seems to happen because Polymer (or this starter) uses a reserved keyword as a function name (import
). Ideally, that should be renamed.
That being said, this should also not break the formatting. This can only be fixed in the formatting library we are using, so I have opened an issue there.
Finally, consider switching to the original beautify extension, as only that one is actively maintained (also by me though).