Skip to content

Commit 7da97c6

Browse files
committedMar 7, 2025
feat: sort pnpm workspace
1 parent 8b5c43a commit 7da97c6

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed
 

‎src/configs/sort.ts

+21
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@ export const sortTsconfig = (): Config[] => [
205205
},
206206
]
207207

208+
export const sortPnpmWorkspace = (): Config[] => [
209+
{
210+
files: ['**/pnpm-workspace.yaml'],
211+
name: 'sxzz/sort/pnpm-workspace',
212+
rules: {
213+
'yml/sort-keys': [
214+
'error',
215+
{
216+
order: ['packages', 'catalog', 'catalogs'],
217+
pathPattern: '^$',
218+
},
219+
{
220+
allowLineSeparatedGroups: true,
221+
order: { type: 'asc' },
222+
pathPattern: '^catalogs?',
223+
},
224+
],
225+
},
226+
},
227+
]
228+
208229
export const sortImports = (): Config[] => [
209230
{
210231
name: 'sxzz/sort/imports',

‎src/configs/yml.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ import type { Rules } from '../typegen'
44
import type { Config } from '../types'
55

66
export const yml = (): Config[] => [
7+
{
8+
name: 'sxzz/yaml/setup',
9+
plugins: {
10+
yml: pluginYml as any,
11+
},
12+
},
713
{
814
files: [GLOB_YAML],
915
languageOptions: {
1016
parser: parserYml,
1117
},
12-
name: 'sxzz/yaml',
13-
plugins: {
14-
yml: pluginYml as any,
15-
},
18+
name: 'sxzz/yaml/rules',
1619
rules: {
1720
...(pluginYml.configs.standard.rules as Rules),
1821
...(pluginYml.configs.prettier.rules as Rules),

‎src/presets.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
regexp,
1414
sortImports,
1515
sortPackageJson,
16+
sortPnpmWorkspace,
1617
sortTsconfig,
1718
specialCases,
1819
typescript,
@@ -41,6 +42,7 @@ export const presetJsonc = (): Config[] => [
4142
...jsonc(),
4243
...sortPackageJson(),
4344
...sortTsconfig(),
45+
...sortPnpmWorkspace(),
4446
]
4547
/** Includes markdown, yaml + `presetJsonc` support */
4648
export const presetLangsExtensions = (): Config[] => [

0 commit comments

Comments
 (0)