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.

Long line-length require statements are awkwardly formatted.

See original GitHub issue

It seems that there’s no concept of keeping require statements and its params as one unit. It’s not very often that you’ll get an extremely long string to pass in to the require() parens. There should be a preference for keeping the require('./something') as one unit.

If I run prettier on this:

const { one, two, thee, four, five, six, seven, eight, nine, ten } = require('./my-utils');

I get this:

const { one, two, thee, four, five, six, seven, eight, nine, ten } = require(
  "./my-utils"
);

When it should be:

const { one, two, thee, four, five, six, seven, eight, nine, ten }
  = require('./my-utils');

or:

const { 
  one, 
  two, 
  thee, 
  four, 
  five, 
  six, 
  seven, 
  eight, 
  nine, 
  ten } = require('./my-utils');

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
jlongstercommented, Jan 18, 2017

I’d say this is the expected behavior for “normal” expressions. Trying to figure out which one is bigger could possibly done, but we need to be really careful how many combinations of styles we try to detect before performance becomes a serious issue.

Also, I’d prefer for the format to be as consistent as possible. The above case, even if it’s slightly awkward in rare cases, is consistent.

What we could do is specialize the require pattern specifically. This is what I talked about in Respecting Patterns. It’s a very common pattern to destructure a large amount of imported properties, so we could specifically break it differently.

2reactions
vjeuxcommented, Mar 1, 2017

#841 fixes it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In python, how to tweak Black formatter, if possible?
This is due to the default line length for black being longer than you'd like – 88 characters per line. To decrease the...
Read more >
long dotted identifiers that are correct length are flattened out ...
I just found out that black is violating line length for long call chains and keeps changing formatted long calls so I had...
Read more >
Google Java Style Guide
1 Introduction. This document serves as the complete definition of Google's coding standards for source code in the Java™ Programming Language.
Read more >
Better Clojure formatting - Hacker News
Especially in Clojure code, I find that if things are that long, ... Tools to format (not just indent) textual Lisp code has...
Read more >
Do people generally use dartfmt? - Google Groups
Yup, we require all internal Google Dart users to format with dartfmt (using the ... I'd probably be really happy with it (I'd...
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