Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jsnajdr opened this issue Oct 23, 2023 · 0 comments
Labels
[Package] ESLint plugin /packages/eslint-plugin [Type] Bug An existing feature does not function as intended

Comments

@jsnajdr
Copy link
Member

jsnajdr commented Oct 23, 2023

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.

@jsnajdr jsnajdr added [Type] Bug An existing feature does not function as intended [Package] ESLint plugin /packages/eslint-plugin labels Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] ESLint plugin /packages/eslint-plugin [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

1 participant