What language is this for?
TypeScript / Angular HTML templates
Which rule?
Rule: S6819 – Prefer tag over ARIA role
Why do you believe it’s a false-positive?
This warning is a false positive because the rule incorrectly flags the valid, WCAG-compliant usage of:
role="region" aria-labelledby="..."
This pattern is fully correct, recommended by WAI-ARIA, and necessary when using Angular Material components such as <mat-card> ( Angular Material UI component library )
Sonar’s rule S6819 is a heuristic, not a WCAG requirement.
The rule only checks whether role="region" exists and flags it blindly, even when:
-
The region has a visible heading
-
The region is correctly labelled using aria-labelledby
-
The component is a UI library element (e.g., Angular Material) that cannot change its host element
In this scenario, the ARIA implementation follows best practices and meets WCAG 1.3.1, 2.4.1, and 4.1.2.
Therefore, the warning triggered by S6819 is a false-positive.
Are you using:
-
SonarQube Server
- Enterprise Edition v2025.1.4
SonarQube for IDE?
VSCode
How can we reproduce the problem?
Sonar incorrectly reports an issue on this valid Angular template code:
<mat-card role="region" aria-labelledby="reportsHeading" appearance="outlined">
<mat-card-header>
<mat-card-title id="reportsHeading">Reports</mat-card-title>
</mat-card-header>
<mat-card-content>
<p>Some content here</p>
</mat-card-content>
</mat-card>
Why this is valid:
-
<mat-card>cannot be replaced with<section>because Angular Material controls its host element. -
role="region"+aria-labelledby="reportsHeading"is the proper WAI-ARIA pattern for creating a labelled landmark. -
This satisfies WAI-ARIA Authoring Practices 1.2 and WCAG 1.3.1 / 2.4.6.
-
Many Angular libraries rely on ARIA roles to create accessible landmarks.
Despite this, Sonar triggers:
“Use
<section>instead of role=‘region’ to ensure accessibility across devices.” (S6819)
This is inaccurate and conflicts with official accessibility guidance.
