0

In my .eslintrc I have:

    "import/order": [
      "error",
      {
        "alphabetize": {
          "caseInsensitive": true,
          "order": "asc"
        },
        "groups": [
          "builtin",
          "external",
          "internal",
          "parent",
          "sibling",
          "index"
        ],
        "newlines-between": "always-and-inside-groups",
        "pathGroups": [
          {
            "pattern": "react",
            "group": "external",
            "position": "before"
          }
        ],
        "pathGroupsExcludedImportTypes": ["builtin"]
      }
    ],

and

  "settings": {
    "import/resolver": {
      "typescript": {
        "alwaysTryTypes": true,
        "project": "./tsconfig.json"
      },
      "node": {
        "paths": "src"
      }
    }
  }

but in one of my files I have:

import { useReactToPrint } from "react-to-print"

and a few lines below I have import { ReservationStatus } from "generated/graphql"

react-to-print is a third party and generated/ is something local that I generate with apollo but it's not external

but I'm getting a complaint on the import { useReactToPrint } from "react-to-print" saying

react-to-print import should occur after import of generated/graphql eslint[import/order](https://github.com/import-js/eslint-plugin-import/blob/v2.27.5/docs/rules/order.md)

but that's wrong, so what have I configured incorrectly?

Red Baron
  • 7,181
  • 10
  • 39
  • 86
  • You can add a path group and specify what's internal path eg: ``` "pathGroups": [ { "pattern": "generated", "group": "internal" }, ], ``` – Renaldo Mateus Jul 07 '23 at 10:30
  • @RenaldoMateus can I not just ask it to consider anything under "src" as internal? – Red Baron Jul 07 '23 at 10:39
  • You said before that there is a conflict with plugin import identify generated/ as internal it's considered as external so I suggest specifying on import plugin settings that your generated is internal { "pattern": "generated", "group": "internal" } , and I found this might be helpful https://dev.to/diballesteros/how-to-quickly-configure-eslint-for-import-sorting-2h73 – Renaldo Mateus Jul 07 '23 at 10:50

0 Answers0