import-js/eslint-plugin-import

v2.23 breaking group spacing/ordering

Open

#2081 aperta il 16 mag 2021

Vedi su GitHub
 (14 commenti) (2 reazioni) (0 assegnatari)JavaScript (1540 fork)batch import
help wantedimport/export ordering

Metriche repository

Star
 (4946 star)
Metriche merge PR
 (Merge medio 138g 22h) (3 PR mergiate in 30 g)

Descrizione

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.

Guida contributor