jsx-eslint/eslint-plugin-react

[Feature] react/jsx-one-expression-per-line tag filtering

Open

#2501 aperta il 21 nov 2019

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (2797 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (8630 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

const enabled = condition => (condition ? <Trans>Enabled</Trans> : <Trans>Disabled</Trans>)

// Current aspect with rule activated
return (
  <Trans>
    <b>Charges</b>
    {' '}
    are
    {' '}
    {enabled(canCharge)}
    {' '}
    and
    {' '}
    <b>payout</b>
    {' '}
    are
    {' '}
    {enabled(payoutsEnabled)}
  </Trans>
)
// Viewed by translating engine
// '<0>Charges</0>{0}are{1}{2}{3}and{4}<1>payout</1>{5}are{6}{7}'

// Desired aspect
return (
  <Trans>
    <b>Charges</b> are {enabled(canCharge)} and <b>payout</b> are {enabled(payoutsEnabled)}
  </Trans>
)
// Viewed by translating engine
// '<0>Charges</0> are {0} and <1>payout</1> are {1}'

In this case it's very annoying to have this all new line for text formatting and it will be interpreted as variable by my translating engine.

So a tag filtering would be great like this:

"react/jsx-one-expression-per-line": ["error", { "exceptTags": ["Trans", "p", "span", "b"] }]

Guida contributor