eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

Adding new group types and matching pattern for sort order

Open 6graNik opened this issue 6 years ago • 16 comments

I added support for couple of new types.

One that was internally used absolute and one new private

They both for more flexible order customazing, we need it in our project and I thought maybe some one else will need it to.

Both properties have on pattern field that except regex.

6graNik avatar Apr 11 '18 15:04 6graNik

Coverage Status

Coverage increased (+0.02%) to 96.499% when pulling 33cda362518cb636ad71a6118f85e27a22723ff9 on 6graNik:new-group-types into cfd437791ae8c358475a71defa7c47e3f68a3d09 on benmosher:master.

coveralls avatar Apr 11 '18 15:04 coveralls

Absolute has a meaning, this seems fine. I have no idea what “private” means, nor why it needs to be a default group when you can create custom ones.

Either way, please update the documentation to describe all your changes.

ljharb avatar Apr 11 '18 15:04 ljharb

@ljharb How can we create custom types? May be I missed it in docs. But right now I only see The only allowed strings are: "builtin", "external", "internal", "parent", "sibling", "index" (https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md)

I created them because I thought we can't create custom ones. And my idea was to separate private company/project package imports from external

I think you are right that we don't need them as a default.

I will update docs accordingly.

6graNik avatar Apr 11 '18 16:04 6graNik

Ah, you’re right, I’m thinking of a different rule in a different plugin.

What would you expect “private” to mean, given that this isn’t a standard concept in node?

ljharb avatar Apr 11 '18 16:04 ljharb

@ljharb As I said before in my idea private type imports is for company or project level packages/libs, to separate them logically from all external types

6graNik avatar Apr 11 '18 17:04 6graNik

I think something wrong with your CI because locally all test completes successfully.

6graNik avatar Apr 17 '18 13:04 6graNik

@6graNik FWIW, when I run the tests on your branch I get the same errors that are happening in the CI.

chenders avatar Jun 18 '18 21:06 chenders

This PR would solve my use case, which is to group company projects. There are some corner cases, which can only be solved by being able to register a group via regex. Any progress on this?

lucasveigaf avatar Dec 27 '18 12:12 lucasveigaf

@ljharb thanks for the response and pointing me to this issue. Is there something that needs to be done to get this in? Anything I can do to help?

jeffshaver avatar Feb 20 '19 19:02 jeffshaver

See https://github.com/benmosher/eslint-plugin-import/pull/1076#issuecomment-380503393

In other words, I'm fine to add builtin groups that have a reasonable universal meaning; "private" has none.

ljharb avatar Feb 20 '19 19:02 ljharb

@ljharb after reading the docs again and reading the source for the order rule, can you correct me if I'm wrong? Does the "internal" group refer to things that basically look like node modules (no relative paths or whatever) but don't exist in the node_modules folder? If so, I think that group solves the Typescript alias problem and we wouldn't require any changes to switch to this.

jeffshaver avatar Feb 20 '19 20:02 jeffshaver

If your concern only, about naming, we can defenatly change it from private to whatever. I am not a native English speaker, so may be someone could suggest any proper naming.

Basically we want to add opportunity to group "some" imports, to separate them from other predefined ones. I need it to group some out company projects.

6graNik avatar Feb 20 '19 21:02 6graNik

@ljharb After trying to get a minimal project up and running given what we talked about, it seems like I found an issue. Made a new issue so that I don't keep bombing this pr thread. https://github.com/benmosher/eslint-plugin-import/issues/1293

jeffshaver avatar Feb 20 '19 22:02 jeffshaver

@6graNik you can create a custom group already; why is that not sufficient?

ljharb avatar Feb 20 '19 23:02 ljharb

@ljharb is that documented somewhere?

jeffshaver avatar Feb 20 '19 23:02 jeffshaver

ah, perhaps not; in which case, would a feature to create custom groups be a better solution for this?

ljharb avatar Feb 23 '19 00:02 ljharb