Skip to content

Commit

Permalink
fix: handle linting reports without name and id
Browse files Browse the repository at this point in the history
Closes #4473
  • Loading branch information
jarekdanielak committed Sep 11, 2024
1 parent 0d4d758 commit 51627dd
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions client/src/app/panel/tabs/linting/LintingTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ function LintingTabItem(props) {
const {
category,
documentation = {},
id,
name,
message,
rule
} = report;
Expand All @@ -112,6 +110,7 @@ function LintingTabItem(props) {
}

const { url: documentationUrl = null } = documentation;
const reportName = getReportName(report);

return <div
onClick={ onClick }
Expand All @@ -124,7 +123,7 @@ function LintingTabItem(props) {
{ category === 'error' ? <ErrorIcon width="16" height="16" /> : null }
{ category === 'warn' ? <WarningIcon width="16" height="16" /> : null }
{ category === 'info' ? <InfoIcon width="16" height="16" /> : null }
<span className="linting-tab-item__label">{ name || id }</span>
<span className="linting-tab-item__label">{ reportName }</span>
</button>
<div className="linting-tab-item__content">
{ message }
Expand All @@ -147,14 +146,11 @@ function LintingTabItem(props) {
function getReportName(report) {
const {
id,
name
name,
} = report;

if (name) {
return name.toLowerCase();
}

return id.toLowerCase();
const reportName = name || id || '';
return reportName.toLowerCase();
}

/**
Expand Down

0 comments on commit 51627dd

Please sign in to comment.