NAME002: method-shadows-component-api
Custom method has the name of a built-in component member
| Code | NAME002 |
| Name | method-shadows-component-api |
| Category | Naming (NAME) |
| Default severity | error |
| Enabled by default | yes |
| Fix available | no |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Reports component custom methods named like a member of Perspective's
component scripting object: getChild, getChildren, getSibling,
refreshBinding, focus, requestPrint, requestTooltip,
removeTooltip, requestContextMenu, removeContextMenu, and the
attributes props, custom, meta, position, children, parent,
view, session and page. The list is the component descriptor shipped
with Perspective 8.3 plus the documented navigation attributes.
Why is this bad?
Section titled “Why is this bad?”Custom methods are called as self.<name>(...) on the same object that
provides these members. Two things with one name cannot both be reached:
either the custom method is never called, or every script that relies on
the built-in member (self.getChild('X'), self.props.text) breaks for
this component.
Example
Section titled “Example”"customMethods": [ {"name": "refreshBinding", "params": ["path"], "script": "\tpass"}]Use instead:
"customMethods": [ {"name": "reloadData", "params": ["path"], "script": "\tpass"}]ign-lint
Section titled “ign-lint”No equivalent.
Generated from the rule metadata by iglint generate-docs; iglint rule NAME002 prints the same page in the terminal. Source: docs/rules/NAME002.md.