Tslint: [Rule Suggestion] ordered-imports: Allow for optional new lines between groups.

Created on 4 Nov 2017  路  6Comments  路  Source: palantir/tslint

This is more of a preference of wanting to only have new line separation between libraries and directory imports while maintaining the sorted order enforced with "grouped-imports".

Here's an example of what I mean:

Enforces this

import * as fs from "fs";

import { Foo } from "../no";

import { Foo } from "./no";

and can optionally enforce this

import * as fs from "fs";

import { Foo } from "../no";
import { Foo } from "./no";

Essentially, an option to have an enforced order of imports, but not the new lines.

Fixed Feature Request

Most helpful comment

@adidahiya Wow, I couldn't be worse with timing here. Sorry!
To answer your question, that's exactly what I'm proposing. Having groups is great, but being able to designate what the groups are would be even better!

All 6 comments

To clarify, you want the "grouped-imports" option but more granular control over what the groups are? I think that makes sense; we'd accept a new rule option that just separates external vs. internal paths.

Separating groups of imports with newlines is something I'd really like to have, too. Currently I use eslint with eslint-plugin-import to manage import groups and this would allow me to drop eslint entirely.

@adidahiya Wow, I couldn't be worse with timing here. Sorry!
To answer your question, that's exactly what I'm proposing. Having groups is great, but being able to designate what the groups are would be even better!

@omiiii Does #4134 give you what you need/want?

@abierbaum Hey! Yes, that's exactly the kind of customization I was looking for. Thanks!

I believe this was fixed by #4134, please file a new issue if needed

Was this page helpful?
0 / 5 - 0 ratings