| 1 |
from ..annotations import get_annotation_elements |
| 2 |
from ..errors import CompileWarning |
| 3 |
from ..language import Property |
| 4 |
from .utils import LinterRule |
| 5 |
|
| 6 |
|
| 7 |
class MissingUserFacingProperties(LinterRule): |
| 8 |
id = "missing_user_facing_text" |
| 9 |
severity = "suggestion" |
| 10 |
category = "a11y" |
| 11 |
|
| 12 |
def check(self, type, child, stack): |
| 13 |
properties = child.content.children[Property] |
| 14 |
# This ensures only the unique elements are run through |
| 15 |
unique_elements = set() |
| 16 |
for user_facing_property, _ in user_facing_properties: |
| 17 |
if user_facing_property not in unique_elements: |
| 18 |
unique_elements.add(user_facing_property) |
| 19 |
if type == user_facing_property or user_facing_property == None: |
| 20 |
if not properties: |
| 21 |
self.problems.append( |
| 22 |
CompileWarning( |
| 23 |
f"{type} is missing required user-facing text property", |
| 24 |
child.signature_range, |
| 25 |
id=self.id, |
| 26 |
) |
| 27 |
) |
| 28 |
|
| 29 |
|
| 30 |
user_facing_properties = get_annotation_elements() |