import-js/eslint-plugin-import

import/order relative import sorting order changed in 2.27.0

Open

#2,682 建立於 2023年1月17日

在 GitHub 查看
 (29 留言) (28 反應) (0 負責人)JavaScript (4,946 star) (1,540 fork)batch import
bughelp wantedimport/export ordering

描述

Given the following rule config:

module.exports.rules = {
  'import/order': [
    'error',
    {
      alphabetize: { order: 'asc', caseInsensitive: true },
      groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'object'],
      'newlines-between': 'always',
      warnOnUnassignedImports: true,
    }
  ]
}

In eslint-plugin-import 2.26, sibling imports were sorted after parent imports. In versions 2.27.0 to 2.27.5, siblings are sorted before parents.

Here’s an example of previously valid, but now invalid code:

import { fooz } from '../baz.js'
import { foo } from './bar.js'

貢獻者指南