jsx-eslint / eslint-plugin-react

React-specific linting rules for ESLint
MIT License
9.01k stars 2.77k forks source link

[Bug]: `jsx-curly-brace-presence` creating invalid code when auto-fixing #3814

Closed dennisoelkers closed 2 months ago

dennisoelkers commented 2 months ago

Is there an existing issue for this?

Description Overview

In version 7.35.1, #3798 is introducing a regression for us, it is changing:

help={'The maximum time range for searches. (i.e. "P30D" for 30 days, "PT24H" for 24 hours)'}

to

help="The maximum time range for searches. (i.e. "P30D" for 30 days, "PT24H" for 24 hours)"

which is obviously an incorrect string.

Expected Behavior

It should not auto-fix this statement.

eslint-plugin-react version

v7.35.1

eslint version

v8.57.0

node version

v18.20.4

ljharb commented 2 months ago

I think it could autofix it, but to escape the double quotes instead? (the longer term fix is to use curly quotes, since straight quotes are never typographically correct in prose)

one way or the other tho, i'll get a fix out.

ljharb commented 2 months ago

k yeah, it just has to not autofix it, and you'll need to manually fix the straight quotes.

ljharb commented 2 months ago

I'll try to get a v7.35.2 out with this today.

dennisoelkers commented 2 months ago

Thanks for the quick fix and release, @ljharb!