willhoney7 / eslint-plugin-import-helpers

ESLint plugin to help enforce a configurable order for import statements
291 stars 17 forks source link

Type sorting does not work correctly #54

Open serGlazkov opened 1 year ago

serGlazkov commented 1 year ago

The section with type imports looks wrong My config is:

'import-helpers/order-imports': [
  'error',
  {
    newlinesBetween: 'always', // new line between groups
    groups: [
      ['/^react$/', '/^next/', 'module'],
      ['/^@framework/', '/^@lib/'],
      '/^@contexts/',
      '/^@components/',
      ['parent', 'sibling', 'index'],
      'type',
    ],
    alphabetize: { order: 'asc', ignoreCase: true },
  },
],

The sorting result looks like this:

import { AnimatePresence, motion } from 'framer-motion'
import { useTranslation } from 'next-i18next'
import Link from 'next/link'
import { useToggle } from 'react-use'

import {
  useTrackIdentifyCustomer,
  useTrackLogin,
  useTrackRegistration,
} from '@lib/tracking/helper'

import { useAuthContext } from '@contexts/AuthContext/AuthContext'

import { Button, Logo } from '@components/ui'

import { AuthFormInput } from './AuthFormInput'
import { getFormData } from './get-form-data'
import { hasErrors } from './has-errors'

import type { AuthFormData, AuthFormErrors } from './useFormValidation'
import { useFormValidation } from './useFormValidation'
import { useCallback, useEffect, useState } from 'react'
import type { FC, FormEvent, HTMLAttributes } from 'react'