perfectionist.ts 2.4 KB

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