Skip to content

Commit 324b5c0

Browse files
committedMar 9, 2025··
feat: add eslint-plugin-pnpm
1 parent 2b5c1ee commit 324b5c0

8 files changed

+55
-1
lines changed
 

‎eslint-inspector.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { sxzz } from './src/index.ts'
33
export default sxzz([], {
44
vue: true,
55
unocss: true,
6+
pnpm: true,
67
})

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"eslint-plugin-jsonc": "^2.19.1",
6363
"eslint-plugin-n": "^17.16.2",
6464
"eslint-plugin-perfectionist": "^4.9.0",
65+
"eslint-plugin-pnpm": "^0.1.2",
6566
"eslint-plugin-prettier": "^5.2.3",
6667
"eslint-plugin-regexp": "^2.7.0",
6768
"eslint-plugin-sxzz": "^0.2.1",

‎pnpm-lock.yaml

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

‎scripts/typegen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const dts = await flatConfigsToRulesDTS(
1111
plugins: { '': { rules: Object.fromEntries(builtinRules) } },
1212
},
1313
],
14-
{ vue: true, unocss: true },
14+
{ vue: true, unocss: true, pnpm: true },
1515
),
1616
{ includeAugmentation: false, exportTypeName: 'Rules' },
1717
)

‎src/configs/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './jsdoc'
88
export * from './jsonc'
99
export * from './markdown'
1010
export * from './node'
11+
export * from './pnpm'
1112
export * from './prettier'
1213
export * from './regexp'
1314
export * from './sort'

‎src/configs/pnpm.ts

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

‎src/plugins.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports'
1414
export { default as pluginJsdoc } from 'eslint-plugin-jsdoc'
1515
export { default as pluginIgnore } from 'eslint-config-flat-gitignore'
1616
export { default as pluginDeMorgan } from 'eslint-plugin-de-morgan'
17+
export { default as pluginPnpm } from 'eslint-plugin-pnpm'
1718

1819
export * as pluginImport from 'eslint-plugin-import-x'
1920
export * as pluginJsonc from 'eslint-plugin-jsonc'

‎src/presets.ts

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
jsonc,
1010
markdown,
1111
node,
12+
pnpm,
1213
prettier,
1314
regexp,
1415
sortImports,
@@ -78,6 +79,7 @@ export async function sxzz(
7879
{
7980
command: enableCommand = true,
8081
markdown: enableMarkdown = true,
82+
pnpm: enablePnpm = false,
8183
prettier: enablePrettier = true,
8284
unocss: enableUnocss = hasUnocss(),
8385
vue: enableVue = hasVue(),
@@ -92,6 +94,7 @@ export async function sxzz(
9294
unocss: boolean
9395
sortKeys: boolean
9496
command: boolean
97+
pnpm: boolean
9598
}> = {},
9699
): Promise<Config[]> {
97100
const configs: Config[] = [...presetBasic(), ...yml(), ...presetJsonc()]
@@ -110,6 +113,9 @@ export async function sxzz(
110113
if (enableCommand) {
111114
configs.push(...command())
112115
}
116+
if (enablePnpm) {
117+
configs.push(...(await pnpm()))
118+
}
113119
if (Object.keys(config).length > 0) {
114120
configs.push(...(Array.isArray(config) ? config : [config]))
115121
}

0 commit comments

Comments
 (0)
Please sign in to comment.