diff --git a/README.md b/README.md index 5529bfc..85b1d15 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ jobs: - run: npm ci - run: npm run lint:json continue-on-error: true - - uses: ldiego73/eslint-report-action@v1 + - uses: ldiego73/eslint-report-action@v1.1 with: token: ${{ secrets.GITHUB_TOKEN }} report: reports/lint.json diff --git a/dist/index.js b/dist/index.js index b14d85d..9d3b54a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11,7 +11,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}u.g `)}function j0(e){let p=[];p.push("## Rules"),p.push("| :straight_ruler: **Rule** | :warning: **warning(s)** | :exclamation: **error(s)** | :wrench: **fixable** |"),p.push("|---------------------------|--------------------------|----------------------------|----------------------|");for(let a of e){let d=a.fixable?":white_check_mark:":"",r=Bd(a.name,a.link);p.push(`| ${r} | ${a.warnings} | ${a.errors} | ${d} |`)}return p.join(` `)}function qd(e,p,a){let d=[];return d.push(x0(e)),d.push(I0(p)),S.viewRules&&a.length>0&&d.push(j0(a)),d.join(` `)}var Ld=e=>S.totalProblems>0&&e>=S.totalProblems;function xd(e,p){let a=[],d=0;if(!!e.length){p>S.totalProblems&&a.push(`:point_up: *records were limited to ${S.totalProblems} problem(s)*`);for(let r of e){let{file:t,errors:s,warnings:o,issues:i}=r,n=t.replace(`${R.workspace}/`,""),l=`https://github.com/${R.owner}/${R.repository}/blob/${R.sha}/${n}`;a.push(`### [${n}](${l})`),a.push(`#### ${s} error(s), ${o} warning(s)`),a.push("| **Position** | **Issue** | **Message** | **Rule** |"),a.push("|--------------|-----------|-------------|----------|");for(let m of i){let{position:v,issue:_,message:h,rule:z}=m,V=jp(z),_e=`**${_}**.`,ie=Bd(z,V);if(a.push(`| ${v} | ${_e} | ${h} | ${ie} |`),d+=1,Ld(d))break}if(a.push("***"),Ld(d))break}return a.join(` -`)}}var U1=require("fs"),Id=require("path");function jd(e){let p=(0,Id.resolve)(e);if(!(0,U1.existsSync)(p))throw new Error(`The report ${e} doesn't exists`);let a=(0,U1.readFileSync)(p,"utf-8");return JSON.parse(a)}function Md(e){let p=0,a=0,d=0,r=0;for(let t of e){let{messages:s}=t;if(p+=1,!!s.length){a+=1;for(let o of s){let{severity:i}=o;i<2?r+=1:d+=1}}}return{files:p,filesWithError:a,errors:d,warnings:r,problems:d+r}}function $d(e){let p=[],a=0;for(let d of e){let{messages:r,filePath:t}=d;if(!r.length)continue;p.push({file:t,issues:[],errors:0,warnings:0}),a=p.length-1;let s=0,o=0;for(let i of r){let{line:n,column:l,message:m,ruleId:v,severity:_,fix:h}=i;p[a].issues.push({position:`${n}:${l}`,message:m,rule:v,issue:_<2?"Warning":"Error",fixable:!!h}),_<2?o+=1:s+=1}p[a].warnings=o,p[a].errors=s}return p}function Hd(e){let p=[];for(let a of e){let{file:d,issues:r}=a,t=d.replace(`${R.workspace}/`,"");for(let s of r){let{position:o,issue:i,message:n,rule:l}=s,[m]=o.split(":");p.push({start_line:Number(m),end_line:Number(m),annotation_level:i==="Warning"?"warning":"failure",message:`[${l}]: ${n}`,path:t})}}return p}function zd(e){return e.errors>0||S.failOnWarning&&e.warnings>0?"failure":"success"}function Wd(e){return e.reduce((p,a)=>p+a.issues.length,0)}function Kd(e,p){return p==="failure"?`There are ${e.problems} problem(s). ${e.errors} error(s) and ${e.warnings} warning(s)`:p==="success"&&e.warnings>0?`There are ${e.warnings} warning(s)`:`${S.title} complete. No errors found!`}(async()=>{try{let e=await kd(),p=jd(S.report||""),a=Md(p),d=$d(p),r=Cd(d),t=Hd(d),s=zd(a),o=Kd(a,s),i=Wd(d),n=qd(o,a,r),l=xd(d,i);await Vd(e,o,t),await Rd(e,s,n,l),s==="failure"?(we.error(o),process.exit(1)):s==="success"&&a.warnings>0?(we.warning(o),S.failOnWarning&&process.exit(1)):we.notice(o)}catch(e){we.setFailed(e.message)}})(); +`)}}var U1=require("fs"),Id=require("path");function jd(e){let p=(0,Id.resolve)(e);if(!(0,U1.existsSync)(p))throw new Error(`The report ${e} doesn't exists`);let a=(0,U1.readFileSync)(p,"utf-8");return JSON.parse(a)}function Md(e){let p=0,a=0,d=0,r=0;for(let t of e){let{messages:s}=t;if(p+=1,!!s.length){a+=1;for(let o of s){let{severity:i}=o;i<2?r+=1:d+=1}}}return{files:p,filesWithError:a,errors:d,warnings:r,problems:d+r}}function $d(e){let p=[],a=0;for(let d of e){let{messages:r,filePath:t}=d;if(!r.length)continue;p.push({file:t,issues:[],errors:0,warnings:0}),a=p.length-1;let s=0,o=0;for(let i of r){let{line:n,column:l,message:m,ruleId:v,severity:_,fix:h}=i;p[a].issues.push({position:`${n}:${l}`,message:m,rule:v,issue:_<2?"Warning":"Error",fixable:!!h}),_<2?o+=1:s+=1}p[a].warnings=o,p[a].errors=s}return p.sort((d,r)=>r.errors-d.errors||r.warnings-d.warnings)}function Hd(e){let p=[];for(let a of e){let{file:d,issues:r}=a,t=d.replace(`${R.workspace}/`,"");for(let s of r){let{position:o,issue:i,message:n,rule:l}=s,[m]=o.split(":");p.push({start_line:Number(m),end_line:Number(m),annotation_level:i==="Warning"?"warning":"failure",message:`[${l}]: ${n}`,path:t})}}return p.sort(a=>a.annotation_level==="warning"?1:-1)}function zd(e){return e.errors>0||S.failOnWarning&&e.warnings>0?"failure":"success"}function Wd(e){return e.reduce((p,a)=>p+a.issues.length,0)}function Kd(e,p){return p==="failure"?`There are ${e.problems} problem(s). ${e.errors} error(s) and ${e.warnings} warning(s)`:p==="success"&&e.warnings>0?`There are ${e.warnings} warning(s)`:`${S.title} complete. No errors found!`}(async()=>{try{let e=await kd(),p=jd(S.report||""),a=Md(p),d=$d(p),r=Cd(d),t=Hd(d),s=zd(a),o=Kd(a,s),i=Wd(d),n=qd(o,a,r),l=xd(d,i);await Vd(e,o,t),await Rd(e,s,n,l),s==="failure"?(we.error(o),process.exit(1)):s==="success"&&a.warnings>0?(we.warning(o),S.failOnWarning&&process.exit(1)):we.notice(o)}catch(e){we.setFailed(e.message)}})(); /*! * is-plain-object *