Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import-x/order scss file ordering #129

Open
reintroducing opened this issue Aug 15, 2024 · 0 comments
Open

import-x/order scss file ordering #129

reintroducing opened this issue Aug 15, 2024 · 0 comments

Comments

@reintroducing
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant