Skip to content

react/jsx-indent throws an error with props default to true #2119

Closed
@keqingrong

Description

@keqingrong

Version:

"eslint": "^5.11.1",
"eslint-plugin-react": "^7.12.2"

Config:

"react/jsx-indent": ["warn",  2, { "checkAttributes": true }]

Code:

function Foo() {
  return (
    <input
      type="radio"
      defaultChecked
    />
  );
}

If no value passed for a prop, ESLint will crash and throw an error like this:

TypeError: Cannot read property 'type' of null
    at handleAttribute (D:\Workspace\eslint-demo\node_modules\eslint-plugin-react\lib\rules\jsx-indent.js:256:42)

https://github.com/yannickcr/eslint-plugin-react/blob/230c7e018b876a17336729f0f079f535227e3d0b/lib/rules/jsx-indent.js#L256

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