@@ -22,6 +22,7 @@ export async function generate(
2222
2323 const visited = new Set < string > ( ) ;
2424 const defs = new Map < any , [ string , string ] > ( ) ;
25+ const stats : Record < string , number > = { } ;
2526
2627 for ( const nodeModulesDir of nodeModulesDirs ) {
2728 const pkgs = readdirDirSync ( nodeModulesDir ) ;
@@ -37,12 +38,17 @@ export async function generate(
3738 plugin = plugin . default ;
3839 }
3940 if ( plugin . rules ) {
41+ stats [ pluginName ] = 0 ;
4042 for ( const ruleName in plugin . rules ) {
4143 const rule = plugin . rules [ ruleName ] ;
4244 if ( subPkg === 'eslint-plugin' ) {
43- addRule ( pkg , ruleName , rule ) ;
45+ if ( addRule ( pkg , ruleName , rule ) ) {
46+ stats [ pluginName ] ++ ;
47+ }
4448 } else {
45- addRule ( pkg , `${ subPkg . slice ( 'eslint-plugin-' . length ) } /${ ruleName } ` , rule ) ;
49+ if ( addRule ( pkg , `${ subPkg . slice ( 'eslint-plugin-' . length ) } /${ ruleName } ` , rule ) ) {
50+ stats [ pluginName ] ++ ;
51+ }
4652 }
4753 }
4854 }
@@ -56,20 +62,26 @@ export async function generate(
5662 }
5763 if ( plugin . rules ) {
5864 const scope = pkg . replace ( 'eslint-plugin-' , '' ) ;
65+ stats [ pkg ] = 0 ;
5966 for ( const ruleName in plugin . rules ) {
6067 const rule = plugin . rules [ ruleName ] ;
61- addRule ( scope , ruleName , rule ) ;
68+ if ( addRule ( scope , ruleName , rule ) ) {
69+ stats [ pkg ] ++ ;
70+ }
6271 }
6372 }
6473 }
6574 else if ( pkg === 'eslint' ) {
6675 const rulesDir = path . join ( nodeModulesDir , pkg , 'lib' , 'rules' ) ;
6776 const ruleFiles = fs . readdirSync ( rulesDir ) ;
77+ stats [ 'eslint' ] = 0 ;
6878 for ( const ruleFile of ruleFiles ) {
6979 if ( ruleFile . endsWith ( '.js' ) ) {
7080 const ruleName = ruleFile . replace ( '.js' , '' ) ;
7181 const rule = await loader ( path . join ( rulesDir , ruleFile ) ) ;
72- addRule ( undefined , ruleName , rule ) ;
82+ if ( addRule ( undefined , ruleName , rule ) ) {
83+ stats [ 'eslint' ] ++ ;
84+ }
7385 }
7486 }
7587 }
@@ -84,7 +96,7 @@ export async function generate(
8496 line ( `type ${ typeName } = ${ typeString } ;` ) ;
8597 }
8698
87- return dts ;
99+ return { dts, stats } ;
88100
89101 function addRule ( scope : string | undefined , ruleName : string , rule : any ) {
90102 let ruleKey : string ;
@@ -95,7 +107,7 @@ export async function generate(
95107 }
96108
97109 if ( visited . has ( ruleKey ) ) {
98- return ;
110+ return false ;
99111 }
100112 visited . add ( ruleKey ) ;
101113
@@ -138,6 +150,7 @@ export async function generate(
138150 } else {
139151 line ( `'${ ruleKey } '?: any[],` ) ;
140152 }
153+ return true ;
141154 }
142155
143156 function line ( line : string ) {
0 commit comments