cli icon indicating copy to clipboard operation
cli copied to clipboard

Allow empty issues in `AuditOutputs`

Open BioPhoton opened this issue 1 year ago • 0 comments

At the moment I can't add empty issues to a AuditOutput/AuditReport.

This leads to code like this:

  let auditOutput: AuditOutput = {
    slug: 'slug',
    score: 1,
    value: data.length,
    displayValue,
  };

  const issues = rawData.filter(ofInterest).map(mapToIssue);

  // add details if issues given
  if (issues.length) {
    auditOutput = {
      ...auditOutput,
      details: {
        issues,
      },
    };
  }
  
  return auditOutput;

instead of this:

  let auditOutput: AuditOutput = {
    slug: 'slug',
    score: 1,
    value: data.length,
    displayValue,
    details: {
        issues: rawData.filter(ofInterest).map(mapToIssue)
      }
  };
 
  return auditOutput;

Changing the typing to allow empty issues would improve DX for plugin authors

BioPhoton avatar Nov 19 '23 21:11 BioPhoton