Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6/7 imports getting formatted #9

Closed
MateuszTrN opened this issue May 22, 2016 · 7 comments
Closed

ES6/7 imports getting formatted #9

MateuszTrN opened this issue May 22, 2016 · 7 comments

Comments

@MateuszTrN
Copy link

this ext is marvelous but I have one problem. I'm using ES6/7 syntax and when I format code all my imports are getting a bit messed up (actually they're getting cleaned up but I'd like them kept as they were).
Example:

import { Some1, Some2 } from Something //this is what I want

is turning into:

import { 
Some1, 
Some2,
} from Something  

which is really painful when I implement some form and use react bootstrap components because there's 5-10 elements just for this one.

@Lonefy
Copy link
Owner

Lonefy commented May 31, 2016

I think this is a js-beautify issue. I'll try to find how to config js-beautify to make the extension format ES6/7 well.

@MateuszTrN
Copy link
Author

as an ugly workaround when you pass the document to js-buityfy you could just skip lines if they start with "import". But if js-beautify would allow you to make it clean that would be perfect :)

@Lonefy
Copy link
Owner

Lonefy commented Jun 29, 2016

@MateuszTrN Try to add "brace_style": "collapse-preserve-inline" in your config file.

image

@MateuszTrN
Copy link
Author

Hi @Lonefy,

Sorry for late answer. Indeed this helped. Thanks!

@gdurastanti
Copy link

This seems to still be an issue. The 'collapse-preserve-inline' param no longer disables this behavior. Uninstalled for the time being but would love a resolution.

@mdibenedetto
Copy link

mdibenedetto commented Feb 18, 2017

If Interested I am trying to fix the problem with a custom extension,
which relies on HookyQR.beautify-0.7.3 but it can be used also with Lonefy.
I still need to finish to test but if you want to try you can have look here

Basically my extension calls HookyQR.beautify-0.7.3 or Lonefy (changeable by configuration)
When the beautifier chosen finishes the job I run mine which convert something like

import { 
Some1, 
Some2,
} from Something ;

into
import { Some1, Some2 } from Something;

for now is important to finish the instruction with semicolon ;

@wf-soft
Copy link

wf-soft commented Mar 12, 2023

@Lonefy This function forces the importmap to be formatted into one line, which makes it difficult to read

<script type="importmap">
        { "imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js", "element-plus": "https://unpkg.com/[email protected]/dist/index.full.mjs" } }
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants