ruoyi-plus-vben5/internal/lint-configs/eslint-config/src/configs/perfectionist.ts

90 lines
2.4 KiB
TypeScript
Raw Normal View History

2024-05-19 21:20:42 +08:00
import type { Linter } from 'eslint';
import { interopDefault } from '../util';
2024-05-19 21:20:42 +08:00
export async function perfectionist(): Promise<Linter.Config[]> {
const perfectionistPlugin = await interopDefault(
// @ts-expect-error - no types
import('eslint-plugin-perfectionist'),
);
2024-05-19 21:20:42 +08:00
return [
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',
{
customGroups: {
2024-05-19 21:20:42 +08:00
type: {
'vben-core-type': ['^@vben-core/.+'],
'vben-type': ['^@vben/.+'],
'vue-type': ['^vue$', '^vue-.+', '^@vue/.+'],
2024-05-19 21:20:42 +08:00
},
value: {
vben: ['^@vben/.+'],
'vben-core': ['^@vben-core/.+'],
vue: ['^vue$', '^vue-.+', '^@vue/.+'],
2024-05-19 21:20:42 +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'],
'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',
'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',
],
internalPattern: ['^#/.+'],
newlinesBetween: 'always',
2024-05-19 21:20:42 +08:00
order: 'asc',
type: 'natural',
},
],
'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',
{
customGroups: {
2024-05-19 21:20:42 +08:00
items: 'items',
list: 'list',
children: 'children',
},
groups: ['unknown', 'items', 'list', 'children'],
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
},
},
];
}