jsx-eslint / eslint-plugin-react

React-specific linting rules for ESLint
MIT License
8.86k stars 2.75k forks source link

[Bug]: react/boolean-prop-naming - Cannot read properties of undefined (reading 'properties') #3733

Closed dylang closed 1 month ago

dylang commented 2 months ago

Is there an existing issue for this?

Description Overview

Exception during linting

TypeError: Cannot read properties of undefined (reading 'properties')
Occurred while linting /example..tsx:5
Rule: "react/boolean-prop-naming"
    at ./node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:396:24
    at Array.forEach (<anonymous>)
    at ./node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:393:35

Rule

        'react/boolean-prop-naming': [
            1,
            { rule: '(^(is|has|should|without)[A-Z]([A-Za-z0-9]?)+|disabled|required|checked|defaultChecked)' }
        ],

Code

import type React from 'react';

export const DataRow = (props: { label: string; value: string; } & React.HTMLAttributes<HTMLDivElement>) => {
    const { label, value, ...otherProps } = props;
    return (
        <div {...otherProps}>
            <span>{label}</span>
            <span>{value}</span>
        </div>
    );
};

Note: I found https://github.com/jsx-eslint/eslint-plugin-react/issues/3717 but it seems to be a different problem.

Expected Behavior

No exception thrown.

eslint-plugin-react version

v7.34.1

eslint version

v8.57.0

node version

v20.11.1

ljharb commented 2 months ago

3717 seems to be the same problem but perhaps with a different cause; this simplified code might help solve both :-) Thanks!