Skip to content

Add a rule prefer-covariant-props #1454

Closed
@julienw

Description

@julienw

With react and flow, it's very common to type props like this:

type Props = {
  prop1: string,
  prop2: number
};

However this makes it possible to write to the props object, like this: this.props.prop1 = 'foo' which is to be avoided.
To force this with flow, the solution is to use covariant properties:

type Props = {
  +prop1: string,
  +prop2: number
};

It would be useful to have an eslint rule to force this pattern.

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