Skip to content

Bug: fallbackSort causes sort-imports failed to fix #483

@ntnyq

Description

@ntnyq

Describe the bug

Repro steps

  • Run pnpm run lint will report errors.

  • Run pnpm run lint:fix error still exists.

  • Comment fallbackSort option in eslint.config.mjs, no error reported.

Besides, if there is no // eslint-disable-next-line perfectionist/sort-imports, it still works fine.

Reproduction repo

https://github.com/ntnyq-dev/repro-perfectionist-sort-imports

Code example

Config

// @ts-check

import pluginPerfectionist from 'eslint-plugin-perfectionist'
import { config, configs } from 'typescript-eslint'

export default config(
  {
    extends: configs.recommended,
  },
  {
    plugins: {
      perfectionist: pluginPerfectionist,
    },
    rules: {
      '@typescript-eslint/ban-ts-comment': 'off',
      'perfectionist/sort-imports': [
        'error',
        {
          fallbackSort: { order: 'asc', type: 'alphabetical' },
          order: 'asc',
          type: 'alphabetical',
          groups: [
            // Side effect style imports (e.g. 'normalize.css')
            'side-effect-style',

            // Styles (e.g. *.{css,scss,less})
            'style',
            /**
             * Imports that don’t fit into any other group
             */
            'unknown',
          ],
          internalPattern: ['^~/.+', '^@/.+', '^#.+'],
        },
      ],
    },
  },
)

Code

import '@unocss/reset/tailwind.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import 'element-plus/theme-chalk/index.css'
import 'uno.css'
// COMMENT BELLOW is IMPORTANT
// eslint-disable-next-line perfectionist/sort-imports
import '@/styles/app.scss'

ESLint version

v9.22.0

ESLint Plugin Perfectionist version

v4.10.0

Additional comments

Since option order and type is the same as option fallbackSort.

I think there is no need to attempt to apply fallback sort.

Maybe some deep equal check.

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions