Skip to content

[no-unnecessary-condition] should enable ignoreRhs #17

Closed
@EdJoPaTo

Description

@EdJoPaTo

The rule option ignoreRhs should be enabled. This is an error I had which is gone with the option enabled:

interface Foo {
	bar?: string[];
}

const obj: Foo = {};
const alwaysArray = obj.bar || [];

With message 6:32 Unnecessary conditional, value is always truthy. which marks the array on the right side as unnecessary condition as [] is always true. Which is exactly what I want in this case.

Documentation: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions