Skip to content

[feat]: apply alphabetize for same group or a new option alphabetizeInGroup: true #129

Closed as not planned
@reintroducing

Description

@reintroducing

Hello,
I'm trying to figure out something that I can't seem to get a handle on. I have the plugin working mostly as i want except for one annoyance. In the following imports:

import clsx from 'clsx';
import Text from '@ui/Text';
import {triggerHaptics} from '@utils/hardware';
import {type Medal} from '../../types';
import css from './Medals.module.scss';
import commonCss from '../Collections.module.scss';

The last two should be reversed. I'd like the output to be:

import clsx from 'clsx';
import Text from '@ui/Text';
import {triggerHaptics} from '@utils/hardware';
import {type Medal} from '../../types';
import commonCss from '../Collections.module.scss';
import css from './Medals.module.scss';

so that the most local scss import is last (it has caused some issues in overriding classes). My config is as follows:

'import-x/order': [
  1,
  {
    alphabetize: {order: 'asc', caseInsensitive: true},
    groups: [
      'builtin',
      'external',
      'internal',
      'parent',
      'sibling',
      'index',
    ],
    pathGroups: [
      {
        pattern: '@hooks/**',
        group: 'internal',
      },
      {
        pattern: '@icons/**',
        group: 'internal',
      },
      {
        pattern: '@gds/**',
        group: 'internal',
      },
      {
        pattern: '@ui/**',
        group: 'internal',
      },
      {
        pattern: '@utils/**',
        group: 'internal',
      },
      {
        pattern: '@/**',
        group: 'internal',
        position: 'after',
      },
      {
        pattern: '*.scss',
        group: 'index',
        patternOptions: {matchBase: true},
        position: 'after',
      },
    ],
    pathGroupsExcludedImportTypes: ['internal'],
    alphabetize: {
      order: 'asc',
      caseInsensitive: true,
    },
  },
]

I can't seem to nail down the proper config to get this working as I'd like. what am i missing to get this sorting properly?

Thank you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions