Skip to content

ES6/7 imports getting formatted  #9

Closed

Description

@MateuszTrN

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.

Activity

  1. Lonefy commented on May 31, 2016

    @Lonefy
    Owner

    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.

  2. MateuszTrN commented on Jun 1, 2016

    @MateuszTrN
    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 :)

  3. Lonefy commented on Jun 29, 2016

    @Lonefy
    Owner

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

    image

  4. MateuszTrN commented on Jul 16, 2016

    @MateuszTrN
    Author

    Hi @Lonefy,

    Sorry for late answer. Indeed this helped. Thanks!

  5. gdurastanti commented on Sep 26, 2016

    @gdurastanti

    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.

  6. mdibenedetto commented on Feb 18, 2017

    @mdibenedetto

    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 ;

  7. wf-soft commented on Mar 12, 2023

    @wf-soft

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions