Skip to content

Is it possible to catch a single prop where the prop is a multiline object? #3210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
girvo opened this issue Feb 18, 2022 · 0 comments · Fixed by #3260
Closed

Is it possible to catch a single prop where the prop is a multiline object? #3210

girvo opened this issue Feb 18, 2022 · 0 comments · Fixed by #3260

Comments

@girvo
Copy link

girvo commented Feb 18, 2022

Specifically the formatting that I want to catch is this:

<div style={{
   background: 'red'
}}
>

The JSX rules I have so far as as follows:

    "react/jsx-closing-tag-location": [2],
    "react/jsx-curly-spacing": [2, "never"],
    "react/jsx-curly-newline": [2, "never"],
    "react/jsx-closing-bracket-location": [2, "tag-aligned"],
    "react/jsx-equals-spacing": [2, "never"],
    "react/jsx-indent": [2, 2, { "checkAttributes": true, "indentLogicalExpressions": true }],
    "react/jsx-indent-props": [2, 2],
    "react/jsx-max-props-per-line": [1, { "maximum": { "single": 3, "multiline": 1 } }],
    "react/jsx-no-useless-fragment": [2],
    "react/jsx-one-expression-per-line": [2, { "allow": "single-child" }],
    "react/jsx-tag-spacing": [2, { "beforeSelfClosing": "always", "beforeClosing": "never" }],

The big issue is this is a single prop, that happens to be an object. I would love to enforce that this prop must be put on a newline but I cannot see a way to achieve that from reading the JSX rules in depth. Any suggestions?

The correct formatting I'd like to enforce is:

<div
  style={{
    background: 'red'
  }}
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant