11import path from "node:path" ;
22
33import fg from "fast-glob" ;
4- import readYamlFile from "read-yaml-file" ;
4+ import readYamlFileModule from "read-yaml-file" ;
55import { readExactProjectManifest } from "@pnpm/read-project-manifest" ;
6+ const readYamlFile = readYamlFileModule . default ;
67
78export default {
89 utils : { getProjects } ,
910 rules : {
10- "scope-enum" : ( ctx ) =>
11- getProjects ( ctx ) . then ( ( packages ) => [ 2 , "always" , packages ] ) ,
11+ "scope-enum" : ( ctx = { } ) =>
12+ getProjects ( ctx ) . then ( ( packages : any ) => [ 2 , "always" , packages ] ) ,
1213 } ,
1314} ;
1415
15- function requirePackagesManifest ( dir ) {
16- return readYamlFile ( path . join ( dir , "pnpm-workspace.yaml" ) ) . catch ( ( err ) => {
17- if ( err . code === "ENOENT" ) {
18- return null ;
19- }
16+ function requirePackagesManifest ( dir : any ) {
17+ return readYamlFile ( path . join ( dir , "pnpm-workspace.yaml" ) ) . catch (
18+ ( err : any ) => {
19+ if ( err . code === "ENOENT" ) {
20+ return null ;
21+ }
2022
21- throw err ;
22- } ) ;
23+ throw err ;
24+ } ,
25+ ) ;
2326}
2427
25- function normalizePatterns ( patterns ) {
28+ function normalizePatterns ( patterns : any ) {
2629 const normalizedPatterns = [ ] ;
2730 for ( const pattern of patterns ) {
2831 normalizedPatterns . push ( pattern . replace ( / \/ ? $ / , "/package.json" ) ) ;
@@ -32,9 +35,9 @@ function normalizePatterns(patterns) {
3235 return normalizedPatterns ;
3336}
3437
35- function findWorkspacePackages ( cwd ) {
38+ function findWorkspacePackages ( cwd : any ) {
3639 return requirePackagesManifest ( cwd )
37- . then ( ( manifest ) => {
40+ . then ( ( manifest : any ) => {
3841 const patterns = normalizePatterns (
3942 ( manifest && manifest . packages ) || [ "**" ] ,
4043 ) ;
@@ -45,27 +48,29 @@ function findWorkspacePackages(cwd) {
4548
4649 return fg ( patterns , opts ) ;
4750 } )
48- . then ( ( entries ) => {
51+ . then ( ( entries : any ) => {
4952 const paths = Array . from (
50- new Set ( entries . map ( ( entry ) => path . join ( cwd , entry ) ) ) ,
53+ new Set ( entries . map ( ( entry : any ) => path . join ( cwd , entry ) ) ) ,
5154 ) ;
5255
5356 return Promise . all (
54- paths . map ( ( manifestPath ) => readExactProjectManifest ( manifestPath ) ) ,
57+ paths . map ( ( manifestPath : any ) =>
58+ readExactProjectManifest ( manifestPath ) ,
59+ ) ,
5560 ) ;
5661 } )
57- . then ( ( manifests ) => {
58- return manifests . map ( ( manifest ) => manifest . manifest ) ;
62+ . then ( ( manifests : any ) => {
63+ return manifests . map ( ( manifest : any ) => manifest . manifest ) ;
5964 } ) ;
6065}
6166
62- function getProjects ( context ) {
67+ function getProjects ( context : any ) {
6368 const ctx = context || { } ;
6469 const cwd = ctx . cwd || process . cwd ( ) ;
6570
66- return findWorkspacePackages ( cwd ) . then ( ( projects ) => {
71+ return findWorkspacePackages ( cwd ) . then ( ( projects : any ) => {
6772 return projects
68- . reduce ( ( projects , project ) => {
73+ . reduce ( ( projects : any , project : any ) => {
6974 const name = project . name ;
7075
7176 if ( name ) {
0 commit comments