perfectionist.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import type { Linter } from 'eslint';
  2. export async function perfectionist(): Promise<Linter.FlatConfig[]> {
  3. const [perfectionistNatural] = await Promise.all([
  4. // @ts-expect-error - no types
  5. import('eslint-plugin-perfectionist/configs/recommended-natural'),
  6. ] as const);
  7. return [
  8. perfectionistNatural,
  9. {
  10. rules: {
  11. 'perfectionist/sort-exports': [
  12. 'error',
  13. {
  14. order: 'asc',
  15. type: 'natural',
  16. },
  17. ],
  18. 'perfectionist/sort-imports': [
  19. 'error',
  20. {
  21. 'custom-groups': {
  22. type: {
  23. vben: 'vben',
  24. vue: 'vue',
  25. },
  26. value: {
  27. vben: ['@vben*', '@vben/*', '@vben-core/*'],
  28. vue: ['vue', 'vue-*', '@vue*'],
  29. },
  30. },
  31. groups: [
  32. ['external-type', 'builtin-type', 'type'],
  33. ['parent-type', 'sibling-type', 'index-type'],
  34. ['internal-type'],
  35. 'builtin',
  36. 'vue',
  37. 'vben',
  38. 'external',
  39. 'internal',
  40. ['parent', 'sibling', 'index'],
  41. 'side-effect',
  42. 'side-effect-style',
  43. 'style',
  44. 'object',
  45. 'unknown',
  46. ],
  47. 'internal-pattern': [
  48. '@/layouts/**',
  49. '@/apis/**',
  50. '@/forward/**',
  51. '@/router/**',
  52. '@/views/**',
  53. '#/**',
  54. ],
  55. 'newlines-between': 'always',
  56. order: 'asc',
  57. type: 'natural',
  58. },
  59. ],
  60. 'perfectionist/sort-named-exports': [
  61. 'error',
  62. {
  63. order: 'asc',
  64. type: 'natural',
  65. },
  66. ],
  67. 'perfectionist/sort-objects': [
  68. 'error',
  69. {
  70. 'custom-groups': {
  71. items: 'items',
  72. list: 'list',
  73. children: 'children',
  74. },
  75. groups: ['unknown', 'items', 'list', 'children'],
  76. 'ignore-pattern': ['children'],
  77. order: 'asc',
  78. 'partition-by-comment': 'Part:**',
  79. type: 'natural',
  80. },
  81. ],
  82. 'perfectionist/sort-vue-attributes': 'off',
  83. },
  84. },
  85. ];
  86. }