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.

Is it possible to add spaces to export and import declarations?

See original GitHub issue

Currently, when I use SourceFile.addImport(), I get such an output:

import {NetUser, User, SmthElse} from './models/User';

However, I’d like to add a space after the opening bracket and before the closing one, so that the file conforms to the style rules we use in our project:

import { NetUser, User, SmthElse } from './models/User';

The same with addExport().

Is this achievable somehow?

PS. I’m sorry I’ve created lots of issues in the last 2 days 😃 The project is really so awesome and I just want to use it at its full potential. Please, however, feel free to tell me if I’m misusing it and if the details of file formatting are out of scope of the project.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Mar 25, 2018

This will be implemented in v10 when it’s released.

Be default it will write surrounding spaces, but you can set the insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces manipulation setting to false to make it not add surrounding spaces.

1reaction
fbarthocommented, Mar 13, 2018

An alternate move might be to suggest emitting through something like prettier? That way the stylistic formatting is a distinct task than the AST manipulation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding spaces between imports and braces in WebStorm
Yes. Go to WebStorm -> Preferences -> Editor -> Code Style -> JavaScript -> Spaces (second tab), scroll to section "Within" and check...
Read more >
Export and import spaces and space customization
You can export and import spaces along with their settings and data. All of the information is saved to a self-contained file with...
Read more >
How to export and import multiple spaces from one
One trick that might help - consolidate your source spaces together, then de-consolidate after merge.
Read more >
Basic Importing and Exporting - Customs and Border Protection
Both CBP and the importing/exporting community have a shared ... ensuring the goods that enter the U.S. marketplace are genuine, safe, and lawfully...
Read more >
Understanding Modules and Import and Export Statements in ...
Note: import must always be at the top of the file before any other code, and it is also necessary to include the...
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