Skip to content

Commit d410d14

Browse files
committed
feat: introduce experimental pnpmCatalogs support
1 parent c5eabc9 commit d410d14

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"eslint-plugin-n": "^17.16.2",
115115
"eslint-plugin-no-only-tests": "^3.3.0",
116116
"eslint-plugin-perfectionist": "^4.9.0",
117+
"eslint-plugin-pnpm-catalogs": "^0.0.3",
117118
"eslint-plugin-regexp": "^2.7.0",
118119
"eslint-plugin-toml": "^0.12.0",
119120
"eslint-plugin-unicorn": "^57.0.0",

pnpm-lock.yaml

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/configs/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from './jsx'
1212
export * from './markdown'
1313
export * from './node'
1414
export * from './perfectionist'
15+
export * from './pnpm-catalogs'
1516
export * from './react'
1617
export * from './regexp'
1718
export * from './solid'

src/configs/pnpm-catalogs.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { TypedFlatConfigItem } from '../types'
2+
3+
import { interopDefault } from '../utils'
4+
5+
export async function pnpmCatalogs(): Promise<TypedFlatConfigItem[]> {
6+
return [
7+
{
8+
files: [
9+
'package.json',
10+
'**/package.json',
11+
],
12+
languageOptions: {
13+
parser: await interopDefault(import('jsonc-eslint-parser')),
14+
},
15+
name: 'antfu/pnpm-catalogs/rules',
16+
plugins: {
17+
'pnpm-catalogs': await interopDefault(import('eslint-plugin-pnpm-catalogs')),
18+
},
19+
rules: {
20+
'pnpm-catalogs/enforce-catalog': 'error',
21+
'pnpm-catalogs/valid-catalog': 'error',
22+
},
23+
},
24+
]
25+
}

src/factory.ts

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
markdown,
1919
node,
2020
perfectionist,
21+
pnpmCatalogs,
2122
react,
2223
solid,
2324
sortPackageJson,
@@ -87,6 +88,7 @@ export function antfu(
8788
componentExts = [],
8889
gitignore: enableGitignore = true,
8990
jsx: enableJsx = true,
91+
pnpmCatalogs: enablePnpmCatalogs = false, // TOD: smart detect
9092
react: enableReact = false,
9193
regexp: enableRegexp = true,
9294
solid: enableSolid = false,
@@ -253,6 +255,12 @@ export function antfu(
253255
)
254256
}
255257

258+
if (enablePnpmCatalogs) {
259+
configs.push(
260+
pnpmCatalogs(),
261+
)
262+
}
263+
256264
if (options.yaml ?? true) {
257265
configs.push(yaml({
258266
overrides: getOverrides(options, 'yaml'),

src/types.ts

+12
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,18 @@ export interface OptionsConfig extends OptionsComponentExts, OptionsProjectType
390390
*/
391391
unocss?: boolean | OptionsUnoCSS
392392

393+
/**
394+
* Enable pnpm catalogs support.
395+
*
396+
* Currently it's disabled by default, as it's still experimental.
397+
* In the future it will be smartly enabled based on the project catalog usage.
398+
*
399+
* @see https://github.com/antfu/pnpm-catalogs-utils
400+
* @experimental
401+
* @default false
402+
*/
403+
pnpmCatalogs?: boolean
404+
393405
/**
394406
* Use external formatters to format files.
395407
*

0 commit comments

Comments
 (0)