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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/configs/index.ts

Lines changed: 1 addition & 0 deletions
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

Lines changed: 25 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy