How to break long import statements into multiple lines in ES6?
Here are the results from my test using ESLint
.
ESLINT PASSED
import fs
from 'fs';
ESLINT PASSED
import
fs
from
'fs';
ESLINT PASSED
import {
moduleName
} from './my/module/file';
And the above code executes fine. I think you are good to go!
NOTE: This .eslintrc
was used.
Yes, the ES6 spec does allow whitespace - which includes newlines - between every token (unless otherwise restricted). Automatic semicolon insertion will not mess with you inside of import declarations either, so you're free to do
import
{
A
,
B
,
C
,
D
}
from
'../path/to/my/module/in/very/far/directory/'
;
or anything that is less extreme and better indented :-)