Skip to content

linter: react/jsx-curly-brace-presence removes braces containing comments #23233

Description

@jeanne-cai

What version of Oxlint are you using?

1.68.0

What command did you run?

yarn oxlint -c oxlint.config.mjs

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

import { defineConfig } from 'oxlint';

export default defineConfig({
    categories: {
        correctness: 'off',
    },
    plugins: ['react'],
    rules: {
        'react/jsx-curly-brace-presence': 'error',
    },
});

What happened?

This rule ignores comments inside curly braces, but we would like to preserve them.

test.tsx:

<Component name={/* This is a comment */ 'test'} />;

<ComponentA>
    {
        // This is an another comment
        <ComponentB />
    }
</ComponentA>;

Output:

  × react(jsx-curly-brace-presence): Curly braces are unnecessary here.
   ╭─[test.tsx:1:42]
 1 │ <Component name={/* This is a comment */ 'test'} />;
   ·                                          ──────
 2 │ 
   ╰────
  help: Replace `{/* This is a comment */ 'test'}` with `"test"`.

  × react(jsx-curly-brace-presence): Curly braces are unnecessary here.
   ╭─[test.tsx:6:9]
 5 │         // This is an another comment
 6 │         <ComponentB />
   ·         ──────────────
 7 │     }
   ╰────
  help: remove the curly braces

Metadata

Metadata

Assignees

Labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions