Skip to content

react/destructuring-assignment ignoreClassFields does not support nested objects #1947

@MrHen

Description

@MrHen

Using this rule:

        "react/destructuring-assignment": [
            "warn",
            "always",
            {
                "ignoreClassFields": true
            }
        ],

This code:

export default class Thing extends React.Component {
    state = {
        alpha: false,
        beta: this.props.beta,
        charlie: null,
    };
    // ...
}

Generates this warning:

[eslint] Must use destructuring props assignment (react/destructuring-assignment)

Version information:

$ npm ls eslint
@centriam/[email protected] /Users/adam.babcock/Source/cxlint/client
├── [email protected]
├─┬ [email protected]
│ └── [email protected]  deduped
└─┬ [email protected]
  └── [email protected]  extraneous

$ npm ls eslint-plugin-react
@centriam/[email protected] /Users/adam.babcock/Source/cxlint/client
├── [email protected]
└─┬ [email protected]
  └── [email protected]  extraneous

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