Skip to content

SCR305: unresolved-component-reference

getSibling/getChild with a literal name that matches no component

Code SCR305
Name unresolved-component-reference
Category Scripts (SCR)
Default severity error
Enabled by default yes
Fix available no
ign-lint equivalent ComponentReferenceValidationRule

Follows component navigation in view scripts from self (the component, or the view for view-level scripts) through .parent, .getParent(), .view, .rootContainer, getSibling('X'), getChild('A/B') and local aliases (card = self.getSibling('Card')), and reports a literal name that no component of the view has at that place:

  • getSibling('X'): the component's parent has no child X;
  • getChild('A/B'): a path segment names no child of the container reached so far;
  • self.view.getChild('root/A'): the path starts at the root container (paths that do not start with the root's name are not checked).

Navigation that cannot be followed (non-literal names, children[i], components reached through parameters) is not checked, and neither are lookups below components that do not hold children in this view (embedded views, and other components without a children array that are not containers).

The lookup returns None at run time and the next attribute access fails with AttributeError. A wrong name is usually a component that was renamed or moved.

self.getSibling('TotalLabel').props.text = str(total)

Use instead (the sibling is called Total):

self.getSibling('Total').props.text = str(total)
  • validate-scripts (default true): when false the rule reports nothing (ign-lint's validate_scripts).

Equivalent of the script part of ComponentReferenceValidationRule, with its wording in iglint ign-lint. ign-lint reports a missing sibling twice and also reports navigation that goes above the root container (self.parent.parent... from a child of the root); iglint reports each lookup once and does not guess what navigation above the root returns.

Set in [rules.SCR305] of iglint.toml (or [tool.iglint.rules.SCR305] in pyproject.toml).

Option Type Default Description
validate-scripts boolean true Check component lookups in scripts.

ign-lint kwargs in a rule_config.json: validate_scripts -> validate-scripts.


Generated from the rule metadata by iglint generate-docs; iglint rule SCR305 prints the same page in the terminal. Source: docs/rules/SCR305.md.