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

[bug] Heruistic of deciding whether something is component is impacted by satisfies #843

Closed
pawelblaszczyk5 opened this issue Oct 22, 2024 · 2 comments
Labels
Status: Released The issue has been released Type: Bug Something isn't working

Comments

@pawelblaszczyk5
Copy link

Describe the bug

Hello 👋
I'm not 100% sure whether this is a bug and how to treat that. There're some issues with heurisitc that decides whether something is component or not. I'm using this plugin within my Remix app and stuff like Remix loader and action which are functions exported from route modules are sometimes flagged as components.

I've tried to dive into what exactly causes that and one thing that caught me off guard is the fact that me using satisfies impact this somehow?

Screenshots using the built-in debug config:

While typing these functions with satisfies they're somehow inferred as components?

image

When they're typed exactly the same, but I'm not using satisfies they aren't identified as components:

image

This causes problems with some issues e.g. "prefer readonly props". Thanks in advance for looking into it and for the time spent on this plugin 😃

Reproduction

Here's a repository with the debug rules setup - https://github.com/pawelblaszczyk5/react-eslint-x-repro

app/root.tsx file has these exports typed with satisfies
app/routes/_index.tsx don't use satisfies

Expected behavior

These functions ideally wouldn't be marked as components, using/not using satisfies shouldn't impact the way they're identified under the hood?

Platform and versions

eslint: 9.13.0,
typescript-eslint: 8.11.0,
@eslint-react/eslint-plugin: 1.15.0

The rest is not applicable here but I can provide anything more needed.

Stack trace

n/a

Additional context

n/a

@Rel1cx Rel1cx added the Type: Bug Something isn't working label Oct 22, 2024
@Rel1cx
Copy link
Owner

Rel1cx commented Oct 22, 2024

Thank you for providing the reproduction and it's good to see someone actually using the debug rules.

You are correct; these functions should not be marked as components. This is indeed a bug.

It appears that when accessing the parent node to retrieve the function's variable name and checking its capitalization, we did not account for cases where it is wrapped by TypeScript's as and satisfies expressions, which affected the component detection.

@Rel1cx Rel1cx closed this as completed in 9e9bfa8 Oct 22, 2024
@pawelblaszczyk5
Copy link
Author

Thanks a lot!

@Rel1cx Rel1cx added the Status: Released The issue has been released label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Released The issue has been released Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants