import-js/eslint-plugin-import

v2.23 breaking group spacing/ordering

Open

#2081 opened on May 16, 2021

View on GitHub
 (14 comments) (2 reactions) (0 assignees)JavaScript (4,946 stars) (1,540 forks)batch import
help wantedimport/export ordering

Description

The following comes up as an error since upgrading to 2.23:

// ESLint error due to the empty line between two import groups
import { UserInputError } from 'apollo-server-express'

import { new as assertNewEmail } from 'Assertions/Email'
// .eslintrc.json (abridged)
{
  "plugins": [
    "import",
  ],
  "rules": {
    "import/order": [
      "error",
      {
        "alphabetize": {
          "caseInsensitive": true,
          "order": "asc"
        },
        "groups": [
          "builtin",
          "external",
          "internal",
          "parent",
          "sibling",
          "index"
        ],
        "newlines-between": "always"
      }
    ],
  },
  "settings": {
    "import/resolver": {
      "babel-module": {},
      "webpack": {}
    }
  }
}

The codebase I’m working on uses the convention that aliases start with a capital letter (i.e. the second import statement belongs to the internal group). There should be a space between import groups. The error goes away when removing the empty line between both import statements.

Contributor guide