willhoney7 / eslint-plugin-import-helpers

ESLint plugin to help enforce a configurable order for import statements
291 stars 17 forks source link

[QUESTION] - Why make this order 👇 ? #32

Closed mateushnsoares closed 4 years ago

mateushnsoares commented 4 years ago

Sorry for the new issue. When have a "^react" import a want that stays in the top but when have styled-components default import I want that stays on the top because In my style files I want the styled-components default import stays before of react-icons. But when I import the theme provider from styled-components ( named export ) I want him to stay after react I try this:

{
 rules: {
    "import-helpers/order-imports": [
      "error",
      {
        "newlinesBetween": "always",
        "groups": [
          [
            "/^react(?!-icons\/*)/", // also I tried"/^react(?!-icons)"
            "/styled-components/",
            "/react-icons/"
          ],
          "module",
          [
            "parent",
            "sibling",
            "index"
          ]
        ],
        "alphabetize": {
          "order": "asc",
          "ignoreCase": true
        }
      }
    ],
 }
}

but not work

mateushnsoares commented 4 years ago

@Tibfib pleaseee helpp me

willhoney7 commented 4 years ago

Hi @mateushnsoares,

The issue is that the order within a group is not enforced. For your react+styled-components+react-icons group, they are ordered alphabetically (see your "alphabetize" settings).

There's more discussion on this issue here https://github.com/Tibfib/eslint-plugin-import-helpers/issues/17. I'm going to close this one in favor of keeping all the conversation over there. Please comment over there if you have suggestions on how to address this. Thanks!

mateushnsoares commented 4 years ago

Thx, sorry for the new issue.