question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Newline inserted after ES6 module import/export

See original GitHub issue

Hey,

I’m running jsbeautifier on a collection of Ember.JS ES6 modules and I’ve noticed a small issue with export statements.

Suppose I have a module that exports as below

export default DS.FixtureAdapter.extend();

jsbeautifier will add a newline after export

export
default DS.FixtureAdapter.extend();

It’s a minor problem that is only an issue for us as we enforce a jsbeautifier run before a commit is accepted. So, if a developer removes the newline, the file in question will be included in the commit even though it may have nothing to do with the changes being commited.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:54 (14 by maintainers)

github_iconTop GitHub Comments

19reactions
eloquencecommented, Aug 25, 2016

@the-simian The correct option is "brace_style": "collapse-preserve-inline", in the “Brace style” section if you go through the Atom preferences. The “preserve_newlines” option is for preservation of newlines across the whole file. You definitely want that one to be true, though. 😃

17reactions
the-simiancommented, Jun 29, 2016

I am still experiencing this issue with import. I am using 1.6.3

import { mod1, mod2 } from 'filePath';

becomes

import { 
  mod1, 
  mod2 
} from 'filePath';

for those of you that it works correctly, can you post your .rc file json with the correct properties pointed out? I have no idea why it isn’t working at all.

{
  "preserve_newlines": true,
  "max_preserve_newlines": 2
}

that did not fix it (as posted above)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to break long import statements into multiple lines in ...
Yes, the ES6 spec does allow whitespace - which includes newlines - between every token (unless otherwise restricted).
Read more >
typescript import newline with single import
I see a similar setting in webstorm: "ES6 import/export". The problem is when I set this to "wrap always" it only wraps import...
Read more >
Appendix B: ES6 - Fullstack React
This appendix is a non-exhaustive list of new syntactic features and methods that were added to JavaScript in ES6. These features are the...
Read more >
eslint-plugin-import
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
Read more >
eslint-plugin-import
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found