<ESLINT> Как разместить все строки «типа импорта» внизу и обеспечить одинаковый порядок выравнивания для строк не «типа импорта»

Прежде всего, вот мой файл .eslintrc.js. У меня есть проект с псевдонимами модулей (@foo/**).

      module.exports = {
  extends: ['plugin:prettier/recommended', 'plugin:@typescript-eslint/recommended'],
  parser: '@typescript-eslint/parser',
  parserOptions: { ecmaVersion: '2021', sourceType: 'module' },
  plugins: ['import', '@typescript-eslint'],
  root: true,
  rules: {
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-namespace': 'off',
    '@typescript-eslint/no-empty-interface': 0,
    'import/order': [
      'error',
      {
        alphabetize: { order: 'asc' },
        pathGroups: [
          {
            pattern: '@foo/**',
            group: 'external',
            position: 'after',
          },
        ],
        distinctGroup: false,
        groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'object', 'index', 'unknown', 'type'],
        pathGroupsExcludedImportTypes: ['@foo', 'type'],
      },
    ],
  },
};

От этого eslint я хочу, чтобы мои строки импорта были такими, как показано ниже:

      import { A } from 'express';
import { B } from '@foo/bar';
import { C } from '../baz';

import type { D } from 'express';
import type { E } from '@foo/bar';
import type { F } from '../baz';

Но мой файл .eslintrc.js заставляет строки импорта быть такими.

      import { A } from 'express';
import { B } from '@foo/bar';
import { C } from '../baz';

import type { F } from '../baz';
import type { E } from '@foo/bar';
import type { D } from 'express';

Когда я удаляю «тип» изpathGroupsExcludedImportTypes, Вот как это работает.

      import { A } from 'express';
import { B } from '@foo/bar';
import type { E } from '@foo/bar';
import { C } from '../baz';

import type { D } from 'express';
import type { F } from '../baz';

Как я могу исправить настройки eslint?

0 ответов

Другие вопросы по тегам