Skip to content

linter: react/display-name false positive for exported default function declaration #23267

Description

@elusiveunit

What version of Oxlint are you using?

1.69.0

What command did you run?

oxlint

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

oxlint.config.ts:

import { defineConfig } from 'oxlint';

export default defineConfig({
	plugins: ['react'],
	rules: {
		'react/display-name': ['warn', { ignoreTranspilerName: true }],
	},
});

What happened?

Testing.tsx:

export default function Testing() {
	return <div>Text</div>;
}
Testing.displayName = 'Testing';

Output from npx oxlint:

  ⚠ react(display-name): Component definition is missing display name.
   ╭─[src/pages-helpers/Testing.tsx:1:1]
 1 │ ╭─▶ export default function Testing() {
 2 │ │       return <div>Text</div>;
 3 │ ╰─▶ }
 4 │     Testing.displayName = 'Testing';
   ╰────
  help: Add a `displayName` property to the component.

Found 1 warning and 0 errors.

Changing to named export (export function) removes the warning.

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