import-js/eslint-plugin-import

`import/order` not working well with direct parent index

開放

#483 建立於 2016年8月11日

 (2 則留言) (3 個反應) (0 位負責人)JavaScript (1,549 個分叉)batch import
bughelp wantedimport/export ordering

倉庫指標

星標
 (5,940 顆星)
PR 合併指標
 (平均合併 138天 22小時) (30 天內合併 3 個 PR)

描述

Hello there,

I'm trying to set up a config for the import/order but I have issues when using .. path to match with direct parent index (e.g. ../index.js).

This is the config I use:

'import/order': [ // Enforce a convention in module import order.
  'warn',
  {
    'groups': [
      'builtin',
      ['external', 'internal'],
      ['parent', 'sibling', 'index'],
    ],
    'newlines-between': 'always',
  },
],

And here is an example of where I get a wrong warning:

import moduleA from '../moduleA'; // import/order warning
import moduleB from '..';

It reports a warning on the first line: import/order: There should be at least one empty line between import groups. Thus, it is no more a problem when adding an ending / after module B's path:

import moduleA from '../moduleA';
import moduleB from '../';
// everything is fine

According to me it's a bug, as I don't have to declare import moduleA from '../moduleA/ to match an index.js file. What's your thoughts on this?

貢獻者指南