jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.96k stars 513 forks source link

Require spaces for object destructuring in imports, alignment cases for imports #2151

Closed fxmaxvl closed 8 years ago

fxmaxvl commented 8 years ago

What about rule for require spaces for import cases?

invalid:
import {foo,bar} from 'foobar';

valid:
import { foo,bar } from 'foobar';

and(maybe for another rule):

invalid:
import { foo,bar } from 'foobar';
import { foo as f,bar } from 'foobar';

valid:
import { foo, bar } from 'foobar';
import { foo as f, bar } from 'foobar';

and what about alignment cases?

invalid:
import { foo, bar } from 'foobar';
import { a, b, c, d, e } from 'alphabet';

valid:
import { foo, bar }      from 'foobar';
import { a, b, c, d, e } from 'alphabet';

but I'm not sure how we can detect alignment for very long import strings:

import { foo, bar} from 'foobar';
import { a as SomethingWithVeryLongNameA, b as SomethingWithVeryLongNameB, c as SomethingWithVeryLongNameC } from 'alphabet'
markelog commented 8 years ago

Sounds good!

fxmaxvl commented 8 years ago

I'll start implement these rules soon. what about naming for this rules ? 1.requireSpacesInsideImportedObjectBrackets 2.requireSpacesBeforeImportDestructuredValues

hzoo commented 8 years ago

I think ObjectBrackets could be ObjectBraces or CurlyBraces or just Braces, since brackets are usually [], braces {}? like array brackets and curly braces? Not sure

For requireSpacesBeforeImportDestructuredValues, I think http://jscs.info/rule/requireSpaceAfterComma works?

fxmaxvl commented 8 years ago

For requireSpacesBeforeImportDestructuredValues, I think http://jscs.info/rule/requireSpaceAfterComma works?

mm, yes its really works.

Braces

Ok, requireSpacesInsideImportedBraces