Long line-length require statements are awkwardly formatted.
See original GitHub issueIt 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:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.#841 fixes it.