Skip to content

[FEATURE] ui5-linter: detect invalid string values for boolean, int, and float properties in XML Views #1114

Description

@devtomtom

Is your feature request related to a problem? Please describe.

Commit d77c863 in sap.ui.core made the runtime log an error when a string value assigned to a boolean, int, or float property in an XML View cannot be parsed, e.g., width="abc" on an int property now triggers a console error instead of silently falling back to false/NaN.

Describe the solution you'd like

The UI5 linter should detect the same class of invalid values statically at lint time, before the app is run, so that:

  • Developers get early feedback during development
  • The ui5-modernization plugin can auto-correct these values

Affected types and invalid value examples

Type Invalid example Runtime behavior after d77c863
boolean "yes", "1", "TRUE" error log, value ignored
int "abc", "2fA", "123,8", "123.8" error log, value ignored
float "abc", "2.5fA", "123,8" error log, value ignored

Note on partial-parse cases ("2fA", "123,8"): these were not caught by d77c863 itself, but a follow-up fix tightened parseValue to use Number(), so they will also fail on a legacy-free runtime. The linter rule should cover both the fully-unparseable and the partial-parse cases.

Detection approach
For a property whose DataType is int or float or boolean, when the XML attribute value is a string literal:

  • boolean: flag any value other than "true" or "false"
  • float: flag when isNaN(Number(value))
  • int: flag when isNaN(Number(value)) or !Number.isInteger(Number(value))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

detectionAn issue related to detection capabilities

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions