azat-io / eslint-plugin-perfectionist

🦄 ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
https://eslint-plugin-perfectionist.azat.io
MIT License
1.66k stars 30 forks source link

Bug: (sort-imports) side-effect imports with an internal pattern are defined as internal modules #72

Closed Wondermarin closed 9 months ago

Wondermarin commented 9 months ago

Describe the bug

If a side-effect import starts with an internal pattern, then it will be defined as an internal module and not a side-effect.

Code example

IN CONFIG:

"perfectionist/sort-imports": [
  "error",
  {
    "type": "line-length",
    "order": "desc",
    "internal-pattern": ["@/**"],
    "groups": [
      "builtin",
      "external",
      "internal",
      "parent",
      "sibling",
      "index",
      "side-effect"
    ]
  }
],

IN CODE:

import { App } from "@/components/app"; // ⤸ There is no space between groups.
import "@/styles/globals.css";

ESLint version

v8.49.0

ESLint Plugin Perfectionist version

v2.1.0

Additional comments

Starting from the idea of the plugin, I think that the current behavior is not quite correct, because there is a group for side-effect imports and therefore something like this is not very aesthetically?

import { EvenLongerNameComponent } from "@/components";
import { LongNameComponent } from "@/components";
import { AnotherComponent } from "@/components";
import { Component } from "@/components";
import "@/styles/globals.css";
import { s } from "@/css";

import "./styles.css";
import "./base.css";

Validations

Wondermarin commented 9 months ago

Made PR.

azat-io commented 9 months ago

Thank you! How critical is this problem? Should I create a release right now or can it wait a bit?

Wondermarin commented 9 months ago

The problem is not critical, you can create a release as it will be more convenient for you.

azat-io commented 8 months ago

Released in v2.2.0.