Skip to content

Linter plugins: Skip React Compiler rules for some files #19957

@overlookmotel

Description

@overlookmotel

@vitejs/plugin-react has implemented a heuristic for skipping React Compiler rules for certain files.

https://github.com/vitejs/vite-plugin-react/releases/tag/plugin-react%406.0.0-beta.0

We could apply the same logic in Oxlint.

Open questions

How do we implement this heuristic?

@vitejs/plugin-react searches the source text for certain strings. We could potentially implement via a different route.

Oxlint already walks the AST. We could pattern match on AST nodes instead of source text search. Would that be faster?

How to integrate with Oxlint?

  1. Special case logic which recognises (how?) that user is using React Compiler rules as a JS plugin, and adds skip logic before it.
  2. Make React compiler rules a "first class citizen" of Oxlint. Implementation would run React Compiler rules as a JS plugin, but that's an implementation detail which is transparent to the user (except that we warn them that it's slow).

Personally I favour the 2nd approach. It gives us more scope to improve it in future if we "own" it - in particular, we could find ways to improve perf.

Related: #10048

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions