N
N
Nikita Pavlyuk2020-12-24 12:20:29
Linter
Nikita Pavlyuk, 2020-12-24 12:20:29

How to properly format imports?

How to properly (and why) format imports like
1) "table"

import ComponentOne   from '@/components';
import ComponentTwo   from '@/components/Two';
import ComponentThree from '@/components/Three';

2) "herringbone"
import ComponentOne from '@/components';
import ComponentTwo from '@/components/Two';
import ComponentThree from '@/components/Three';


Reading / refactoring is more convenient than a table, IMHO. But the question arises, if the variable name takes more characters, then you need to shift all the rest?
tell me from your experience and / or sources where this can be clearly stated

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Romanov, 2020-12-24
@Neakit

It's not organization, it's formatting. I agree with Anton, if you use VS Code, there are already extensions there, they do everything themselves. Although it can be configured.
I personally prefer the first option for both imports and assignments and arrays etc.
I think there is no “how to” answer, unless you are writing code for a common project where there is an explicit code formatting guide.

A
Anton Anton, 2020-12-24
@Fragster

Clearly spelled out in the autoformatter settings, such as eslint or prettier.
They customize their own style.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question