-
Notifications
You must be signed in to change notification settings - Fork 885
New rule: import-ordering #771
Comments
👍. |
Some more suggestions here:
|
good ideas @aeisenberg. unused imports should be covered by |
👍 |
Here's a custom rule I put together that does something like this:
|
FYI @adidahiya I've sent out #1325 which implements something along these lines. |
Where would ordering of the |
We might differ in opinion on this -- I personally don't think default imports / namespace imports / etc. should be treated any differently from each other, so therefore you shouldn't worry about grouping them. There's not much that's semantically related about the import style, so I'd rather go by alphabetization based on module name. Maybe an additional option called |
That sounds fair. I think we can do with the general alph within groups. |
Hi guys. Is there a way to disable "Import sources within a group must be alphabetized" option in this rule? It will be helpful for:
Thanks for your work and any help :) |
@EugeneSnihovsky If I want to separate imports in that way, I usually put them into multiple groups separated by blank lines, just like you would with PEP8. import * as fs from 'fs';
import * as os from 'os';
import * as bar from './bar';
import * as foo from './foo'; |
I've created a custom rule to check for such a default groups layout, i.e.
Edit: see pull request. |
For the error that is triggered by not following |
@tonystaark if you think that's bewildering, imagine learning that TSLint is deprecated: #4534. We highly recommend you stop using this code. 😄 |
Update July 1, 2016
This rule was released as "ordered-imports" in TSLint v3.13.0.
Update Jun 14, 2016
Import ordering
Option:
check-groups
enforces formatting imports into groups (separated by single newlines) in a certain order:Option:
alphabetize
enforces alphabetic ordering offrom
clausecheck-groups
is enabled, then order is enforced within each groupcheck-groups
is not enabled, then enforce overall orderingThe text was updated successfully, but these errors were encountered: