2024-05-19 21:20:42 +08:00
|
|
|
import type { Linter } from 'eslint';
|
|
|
|
|
2025-01-01 11:39:49 +08:00
|
|
|
import { interopDefault } from '../util';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-08-02 22:18:46 +08:00
|
|
|
export async function perfectionist(): Promise<Linter.Config[]> {
|
2025-01-01 11:39:49 +08:00
|
|
|
const perfectionistPlugin = await interopDefault(
|
|
|
|
// @ts-expect-error - no types
|
|
|
|
import('eslint-plugin-perfectionist'),
|
|
|
|
);
|
|
|
|
|
2024-05-19 21:20:42 +08:00
|
|
|
return [
|
2024-07-23 00:03:59 +08:00
|
|
|
perfectionistPlugin.configs['recommended-natural'],
|
2024-05-19 21:20:42 +08:00
|
|
|
{
|
|
|
|
rules: {
|
|
|
|
'perfectionist/sort-exports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
order: 'asc',
|
|
|
|
type: 'natural',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'perfectionist/sort-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
2024-07-23 00:03:59 +08:00
|
|
|
customGroups: {
|
2024-05-19 21:20:42 +08:00
|
|
|
type: {
|
2025-01-01 11:39:49 +08:00
|
|
|
'vben-core-type': ['^@vben-core/.+'],
|
|
|
|
'vben-type': ['^@vben/.+'],
|
|
|
|
'vue-type': ['^vue$', '^vue-.+', '^@vue/.+'],
|
2024-05-19 21:20:42 +08:00
|
|
|
},
|
|
|
|
value: {
|
2025-01-01 11:39:49 +08:00
|
|
|
vben: ['^@vben/.+'],
|
|
|
|
'vben-core': ['^@vben-core/.+'],
|
|
|
|
vue: ['^vue$', '^vue-.+', '^@vue/.+'],
|
2024-05-19 21:20:42 +08:00
|
|
|
},
|
|
|
|
},
|
2025-01-01 11:39:49 +08:00
|
|
|
environment: 'node',
|
2024-05-19 21:20:42 +08:00
|
|
|
groups: [
|
2024-06-08 19:49:06 +08:00
|
|
|
['external-type', 'builtin-type', 'type'],
|
2025-01-01 11:39:49 +08:00
|
|
|
'vue-type',
|
|
|
|
'vben-type',
|
|
|
|
'vben-core-type',
|
2024-06-08 19:49:06 +08:00
|
|
|
['parent-type', 'sibling-type', 'index-type'],
|
|
|
|
['internal-type'],
|
2024-05-19 21:20:42 +08:00
|
|
|
'builtin',
|
2024-06-08 19:49:06 +08:00
|
|
|
'vue',
|
2024-05-19 21:20:42 +08:00
|
|
|
'vben',
|
2025-01-01 11:39:49 +08:00
|
|
|
'vben-core',
|
2024-05-19 21:20:42 +08:00
|
|
|
'external',
|
|
|
|
'internal',
|
|
|
|
['parent', 'sibling', 'index'],
|
2024-06-08 19:49:06 +08:00
|
|
|
'side-effect',
|
|
|
|
'side-effect-style',
|
2024-05-19 21:20:42 +08:00
|
|
|
'style',
|
|
|
|
'object',
|
|
|
|
'unknown',
|
|
|
|
],
|
2025-01-01 11:39:49 +08:00
|
|
|
internalPattern: ['^#/.+'],
|
2024-07-23 00:03:59 +08:00
|
|
|
newlinesBetween: 'always',
|
2024-05-19 21:20:42 +08:00
|
|
|
order: 'asc',
|
|
|
|
type: 'natural',
|
|
|
|
},
|
|
|
|
],
|
2025-01-01 11:39:49 +08:00
|
|
|
'perfectionist/sort-modules': 'off',
|
2024-05-19 21:20:42 +08:00
|
|
|
'perfectionist/sort-named-exports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
order: 'asc',
|
|
|
|
type: 'natural',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'perfectionist/sort-objects': [
|
|
|
|
'error',
|
|
|
|
{
|
2024-07-23 00:03:59 +08:00
|
|
|
customGroups: {
|
2024-05-19 21:20:42 +08:00
|
|
|
items: 'items',
|
|
|
|
list: 'list',
|
|
|
|
children: 'children',
|
|
|
|
},
|
|
|
|
groups: ['unknown', 'items', 'list', 'children'],
|
2024-07-23 00:03:59 +08:00
|
|
|
ignorePattern: ['children'],
|
2024-05-19 21:20:42 +08:00
|
|
|
order: 'asc',
|
2024-06-09 13:31:43 +08:00
|
|
|
type: 'natural',
|
|
|
|
},
|
|
|
|
],
|
2024-05-19 21:20:42 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|