Skip to content

Add a rule no-comparison-of-unary-test #33

@barmac

Description

@barmac

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

This is a valid FEEL expression: foo == bar
However, it will always evaluate to null. That's because we are comparing variable foo to an unary test: = bar.
This will bite any FEEL novice who wrote code before as most programming languages use double or even triple = for comparisons.

Describe the solution you'd like

Warn a user when they pass a unary test to a comparison:

Comparison [0, 10]
  VariableName [0, 3]
  CompareOp [4, 5]
  SimplePositiveUnaryTest [5, 10]
    CompareOp [5, 6]
    VariableName [7, 10]

Describe alternatives you've considered

Require to enclose unary test in parenthesis. However, that does not solve the problem, and is cumbersome when we actually want to use an inline unary test: foo in (100, >100)

Additional context

Discovered in bpmn-io/properties-panel#394

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions