Skip to content

[react/jsx-max-props-per-line] Consider line-length #3200

Open

Description

There should be an option which also considers the number of characters in the specific line.

If I have shorter lines like:

<input type="email" name="email" autoComplete="on" minLength={5} onChange={handleChange} />

it shouldn't warn, but for longer lines, with the same amount of properties it should:

<div role="button" aria-label={i18n.MENU_BUTTON_LABEL} tabIndex={0} onClick={visibilityState !== VisibilityState.SHOWN ? showNavigation : hideNavigation} onKeyPress={Utils.dispatchClickOnActionKey}>

because adding line-breaks in the first case, makes the code more unreadable, while in the second case it get's more readable.

If I have just one prop, but with a very long value, it shouldn't be enforced to move it into a separate line, but for the same number characters in two props, the readability could improved with a line-break.

My setup would then looks like:

'react/jsx-max-props-per-line': ['error', { maximum: 1, minimumLength: 120 }],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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