# yoda

Disallow literal-first comparisons

A literal-first comparison reverses the subject-first order used by other comparisons.
Instead, you SHOULD put the checked value first and reverse a relational operator when required.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function isReady(state: string): boolean {
    return "ready" === state;
}
```

## Accepted

```ds title="main.ds"
function isReady(state: string): boolean {
    return state === "ready";
}
```

## Prior art

- [ESLint · yoda](https://eslint.org/docs/latest/rules/yoda)

[language/linter/src/rules/style/yoda.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/yoda.rs#L8)
