Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make external package and internal components folder as a separate group #2545

Open
szulcus opened this issue Sep 5, 2022 · 8 comments
Open

Comments

@szulcus
Copy link

szulcus commented Sep 5, 2022

I have this eslint configuration:

    "import/order": [
      "error",
      {
        "pathGroups": [
          {
            "pattern": "@frontend/components",
            "group": "internal",
            "position": "after"
          },
          {
            "pattern": "~/components/**",
            "group": "internal",
            "position": "after"
          }
        ],
        "groups": [
          "builtin",
          "external",
          "internal",
          "unknown",
          "parent",
          "sibling",
          "index",
          "object",
          "type"
        ]
      }
    ]

I would like all my imports of @frontend/components and ~/components/ ** to be treated as a separate group. How can I do this?

@ljharb
Copy link
Member

ljharb commented Sep 5, 2022

Can you be more specific about what code you’d like, that this config considers incorrect?

@szulcus
Copy link
Author

szulcus commented Sep 7, 2022

Can you be more specific about what code you’d like, that this config considers incorrect?

Of course. I want to have all the imports sorted by default, except for components which will always have a line before an empty one, and will be in ~/components/** or @frontend/components. For example:
Zrzut ekranu 2022-09-07 181826
I have temporarily disabled the option, so it does not report bugs, but generally screams that things from @frontend/components should be above ~/store.

@ljharb
Copy link
Member

ljharb commented Sep 7, 2022

How come your pathGroups don't account for ~/**, since those are all internal?

Regardling newlines, you may also be interested in the pathGroups.distinctGroup option added in #2395, that will be in the next release.

@szulcus
Copy link
Author

szulcus commented Sep 7, 2022

How come your pathGroups don't account for ~/**, since those are all internal?

Regardling newlines, you may also be interested in the pathGroups.distinctGroup option added in #2395, that will be in the next release.

I think I do not understand. Is it about something like that?
image
If so, it still doesn't work 😅

@ljharb
Copy link
Member

ljharb commented Sep 7, 2022

If you can provide a PR with a failing test case, I can likely solve it more quickly.

@szulcus
Copy link
Author

szulcus commented Sep 8, 2022

Unfortunately the project and package are reserved, but I don't see any reason to reproduce it. I just want to have all the components separate. In Vue 3, in the <script setup> tag, there is no need to define the components, so I want to have them all in one place.

@ljharb
Copy link
Member

ljharb commented Sep 8, 2022

@szulcus the reason is that without a reproduction case or regression tests, it can never be fixed - especially since I don't use Vue myself, so I'd have no idea how to set up a test case.

@szulcus
Copy link
Author

szulcus commented Sep 13, 2022

@szulcus the reason is that without a reproduction case or regression tests, it can never be fixed - especially since I don't use Vue myself, so I'd have no idea how to set up a test case.

I still think it's a pattern bug and doesn't require reproduction, but if you really need it, I created it for you:
Nuxt Bridge ESLint import order reproduction.zip

yarn
yarn dev

File path: ~/pages/index.vue
Environment: Visual Studio Code + Volar extension

image

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

No branches or pull requests

2 participants