Skip to content

order rule: add pathGroups option to add support to order by paths#1386

Merged
ljharb merged 1 commit into
import-js:masterfrom
Mairu:pathGroups
Dec 6, 2019
Merged

order rule: add pathGroups option to add support to order by paths#1386
ljharb merged 1 commit into
import-js:masterfrom
Mairu:pathGroups

Conversation

@Mairu
Copy link
Copy Markdown
Contributor

@Mairu Mairu commented Jun 20, 2019

Well there are multiple issues and pull requests open regarding the ordering of groups by paths.
Because I saw that the proposed approach in #795 was "accepted" I implemented it this way.

But if @ljharb has changed his mind in the mean time and would prefer something like custom groups as proposed in #1015 (comment) I can also rework this.

Co-Authored-By: Matt Seccafien <matt@studiocartogram.com>
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+2.6%) to 97.814% when pulling 5c46fae on Mairu:pathGroups into 58b41c2 on benmosher:master.

@coveralls
Copy link
Copy Markdown

coveralls commented Jun 20, 2019

Coverage Status

Coverage increased (+0.1%) to 96.405% when pulling 0426f16 on Mairu:pathGroups into 99b3fbf on benmosher:master.

Comment thread docs/rules/order.md Outdated
Comment thread src/rules/order.js Outdated
Comment thread src/rules/order.js Outdated
Comment thread docs/rules/order.md
@Mairu
Copy link
Copy Markdown
Contributor Author

Mairu commented Jul 3, 2019

Anything else needed for this to be merged? @ljharb

Comment thread docs/rules/order.md Outdated
@fundlg
Copy link
Copy Markdown

fundlg commented Aug 13, 2019

+1, need this feature

@osdiab
Copy link
Copy Markdown

osdiab commented Sep 16, 2019

Any reason this has stalled? Would love to use this @ljharb

@zaqqaz
Copy link
Copy Markdown

zaqqaz commented Oct 14, 2019

Any reason this has stalled? Would love to use this @ljharb

@benmosher, @ljharb ⬆️

Copy link
Copy Markdown
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall

Comment thread CHANGELOG.md Outdated
@osdiab
Copy link
Copy Markdown

osdiab commented Nov 6, 2019

ping on if this is gonna get merged...

@osdiab
Copy link
Copy Markdown

osdiab commented Nov 18, 2019

@benmosher, @ljharb ⬆️

@oliverdolgener
Copy link
Copy Markdown

I'd really like to see this getting merged :D

@ljharb ljharb merged commit 0426f16 into import-js:master Dec 6, 2019
@Mairu Mairu deleted the pathGroups branch December 7, 2019 08:05
@osdiab
Copy link
Copy Markdown

osdiab commented Dec 10, 2019

I was wondering if I was misusing this new rule.

With this this code, I want it to behave as so:

// BEFORE FIX
import { testHelper } from "__tests__/helpers";
import { RecurringStatus } from "@my.company/common/es6/entity/types";
import { ChartistGraph } from "@app/components/common/ChartistGraph";
import { ILineChartOptions } from "chartist";

// AFTER FIX
// this is external, so before all this package's imports
import { ILineChartOptions } from "chartist";

// this is external, but monorepo package, so put it after normal external
import { RecurringStatus } from "@my.company/common/es6/entity/types";

// this is internal, so mixed with anything else internal
import { ChartistGraph } from "@app/components/common/ChartistGraph";

// this is internal but secondary, so after other internal code
import { testHelper } from "__tests__/helpers";

I configured my import/order like so:

        "pathGroups": [
          {
            "pattern": "@app/**",
            "group": "internal"
          },
          {
            "pattern": "__tests__/**",
            "group": "internal",
            "position": "after"
          },
          {
            "pattern": "@my.company/**",
            "group": "external",
            "position": "after"
          }
        ],

But this doesn't mark my BEFORE FIX code as an error at all :P not sure why.

@osdiab
Copy link
Copy Markdown

osdiab commented Dec 10, 2019

I edited the above for my second try

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Dec 10, 2019

Please file a new issue so we can track it properly :-)

@jgabriele
Copy link
Copy Markdown

Thank you ❤️!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

9 participants