Skip to content

The no-unused-vars-before-return ESLint rule reports false positive on JSX usage #55552

Open

Description

Write this code:

function lazyEdit( load ) {
  const Load = lazy( load );
  return function LoadEdit( props ) {
    return (
      <Suspense fallback={ null }>
        <Load { ...props } />
      </Suspense>
    );
  };
}

It defines a Load local variable and uses it in the returned function, as a JSX component type.

But the @wordpress/no-unused-vars-before-return incorrectly flags it as unused:

Screenshot 2023-10-23 at 17 14 49

Apparently the rule doesn't find the usage in a JSX markup that is nested inside a local function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Package] ESLint plugin/packages/eslint-plugin/packages/eslint-plugin[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions