Skip to content

Config to add strings #2

@bytehala

Description

@bytehala

Hi, I found a reddit thread where you mention the possibility of adding strings as errors:

https://www.reddit.com/r/reactjs/comments/x4iipz/comment/imx220n/

"jsx-no-leaked-values/jsx-no-leaked-values": [
  "error", 
  {
    "string": true,
  }
]

This would be really helpful in React Native because rendering strings in RN will cause a crash:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md#rule-details

const Example = () => {
  return (
    <>
      {0 && <Something />}
      {/* React: renders undesired 0 */}
      {/* React Native: crashes 💥 */}

      {NaN && <Something />}
      {/* React: renders undesired NaN */}
      {/* React Native: crashes 💥 */}

      {'' && <Something />}
      {/* React: renders nothing */}
      {/* React Native, with React < 18: crashes 💥 */}
    </>
  )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions