Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break long import statements into multiple lines in ES6?

I have a pretty long import statement in my JavaScript (ES6) file:

import { A, B, C, D } from '../path/to/my/module/in/very/far/directory/'

Is it OK to add new lines like this?

import { A, B, C, D } from
'../path/to/my/module/in/very/far/directory'

If not, is there any other way to write clean (keeping my code within 80 columns) import statements in ES6 syntax using Babel?

like image 695
June Avatar asked Nov 14 '15 11:11

June


1 Answers

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.

like image 116
activatedgeek Avatar answered Sep 22 '22 04:09

activatedgeek