From 1a3c6219b89737e02cf88ef5e604fc46f7c5aafa Mon Sep 17 00:00:00 2001 From: Ben Jervis Date: Wed, 15 Nov 2023 14:36:49 +1100 Subject: [PATCH] Fix curly brace erroring on child text nodes (#133) --- .changeset/strange-rings-explode.md | 26 ++++++++++++++++++++++++++ index.js | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .changeset/strange-rings-explode.md diff --git a/.changeset/strange-rings-explode.md b/.changeset/strange-rings-explode.md new file mode 100644 index 0000000..1f9290b --- /dev/null +++ b/.changeset/strange-rings-explode.md @@ -0,0 +1,26 @@ +--- +'eslint-config-seek': patch +--- + +Prevents the new curly-brace-presence rule from affecting children. + +In the previous version, [react/jsx-curly-brace-presence][brace rule] was added to the eslint rules. +This was primarily intended to catch unnecessarily using braces around string props. + +```diff +- ++ +``` + +Because of the configuration we provided, this had the unintended side effect of removing curly braces inside child text that were being used to prevent the [unescaped entities rule]. + +```diff +- The available props are {'"up"'} and {'"down"'} ++ The available props are "up" and "down" +// This is now an unescaped entity error +``` + +To fix this, the curly brace rule will now ignore children, and only alert on prop values. + +[brace rule]: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md +[unescaped entities rule]: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md diff --git a/index.js b/index.js index d979233..28b6644 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ const reactRules = { 'react/prop-types': OFF, 'react/jsx-curly-brace-presence': [ ERROR, - { props: 'never', children: 'never', propElementValues: 'always' }, + { props: 'never', children: 'ignore', propElementValues: 'always' }, ], };