Skip to content

[import/order] Potential regression in sibling and parent behavior #2671

Closed
@erunion

Description

@erunion

We have a bit of a complex import/order config and are seeing some new weird behavior with ordering on the sibling and parent groups on eslint-plugin-import@2.27.4:

'import/order': [
  'error',
  {
    alphabetize: {
      order: 'asc',
      caseInsensitive: true,
    },
    groups: ['type', 'builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'],
    'newlines-between': 'always',
    pathGroups: [
      { pattern: '@Hub', group: 'external', position: 'after' },
      { pattern: '@Hub/**', group: 'external', position: 'after' },
      { pattern: '@Dash/**', group: 'external', position: 'after' },
      { pattern: '@core/**', group: 'external', position: 'after' },
      { pattern: '@routes/**', group: 'external', position: 'after' },
      { pattern: '@ui', group: 'external', position: 'after' },
      { pattern: '@ui/**', group: 'external', position: 'after' },
    ],
    pathGroupsExcludedImportTypes: ['@Hub', '@Dash', '@core', '@routes', '@ui'],
    warnOnUnassignedImports: true,
  },
],

Here's what our code looks like on eslint-plugin-import@2.26.0:

import React from 'react';

import Flex from '@ui/Flex';
import Menu, { MenuItem, MenuDivider } from '@ui/Menu';

import { isPolymorphic } from '../../utils';

import classes from './style.module.scss';
import './style.scss';

And it wants it to be now:

import React from 'react';

import Flex from '@ui/Flex';
import Menu, { MenuItem, MenuDivider } from '@ui/Menu';

import classes from './style.module.scss';
import './style.scss';

import { isPolymorphic } from '../../utils';

However if I swap the the order of parent and sibling in the config to this then the behavior we were seeing on v2.26.0 remains:

groups: ['type', 'builtin', 'external', 'internal', 'sibling', 'parent', 'index', 'object']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions