@@ -6,7 +6,7 @@ import findUp from 'next/dist/compiled/find-up'
66import  semver  from  'next/dist/compiled/semver' 
77import  *  as  CommentJson  from  'next/dist/compiled/comment-json' 
88
9- import  {  formatResults  }  from  './customFormatter' 
9+ import  {  LintResult ,   formatResults  }  from  './customFormatter' 
1010import  {  writeDefaultConfig  }  from  './writeDefaultConfig' 
1111import  {  existsSync ,  findPagesDir  }  from  '../find-pages-dir' 
1212import  { 
@@ -29,7 +29,8 @@ async function lint(
2929  eslintrcFile : string  |  null , 
3030  pkgJsonPath : string  |  null , 
3131  eslintOptions : any  =  null , 
32-   reportErrorsOnly : boolean  =  false 
32+   reportErrorsOnly : boolean  =  false , 
33+   maxWarnings : number  =  - 1 
3334) : Promise < 
3435  |  string 
3536  |  null 
@@ -116,10 +117,16 @@ async function lint(
116117
117118  const  formattedResult  =  formatResults ( baseDir ,  results ) 
118119  const  lintEnd  =  process . hrtime ( lintStart ) 
120+   const  totalWarnings  =  results . reduce ( 
121+     ( sum : number ,  file : LintResult )  =>  sum  +  file . warningCount , 
122+     0 
123+   ) 
119124
120125  return  { 
121126    output : formattedResult . output , 
122-     isError : ESLint . getErrorResults ( results ) ?. length  >  0 , 
127+     isError :
128+       ESLint . getErrorResults ( results ) ?. length  >  0  || 
129+       ( maxWarnings  >=  0  &&  totalWarnings  >  maxWarnings ) , 
123130    eventInfo : { 
124131      durationInSeconds : lintEnd [ 0 ] , 
125132      eslintVersion : eslintVersion , 
@@ -143,7 +150,8 @@ export async function runLintCheck(
143150  lintDirs : string [ ] , 
144151  lintDuringBuild : boolean  =  false , 
145152  eslintOptions : any  =  null , 
146-   reportErrorsOnly : boolean  =  false 
153+   reportErrorsOnly : boolean  =  false , 
154+   maxWarnings : number  =  - 1 
147155) : ReturnType < typeof  lint >  { 
148156  try  { 
149157    // Find user's .eslintrc file 
@@ -205,7 +213,8 @@ export async function runLintCheck(
205213      eslintrcFile , 
206214      pkgJsonPath , 
207215      eslintOptions , 
208-       reportErrorsOnly 
216+       reportErrorsOnly , 
217+       maxWarnings 
209218    ) 
210219  }  catch  ( err )  { 
211220    throw  err 
0 commit comments