Skip to content

Commit

Permalink
Support eslint 8+ flat plugin syntax out of the box for eslint-plugin…
Browse files Browse the repository at this point in the history
…-react-compiler (facebook#32120)

## Summary

The current docs for the react compiler eslint plugin is based on
integrating with the old-style eslint config format. This is generally
fine, but most plugins (and the [official
docs](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file))
are now describing themselves in the new format.

This PR has two changes:

- Update the exports to include a "flat configuration"
- Adds a README change describing how to handle both configs

The solution is semi-based on @guillaumebrunerie's answer in
reactwg/react-compiler#25 mixed with
reading the source code for
[eslint-plugin-react-refresh](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/blob/main/src/index.ts)

## How did you test this change?

I faked this API in the most recent deploy:

![Screenshot 2025-01-18 at 19 58
44](https://github.com/user-attachments/assets/ae0e4bea-fb96-4073-a5f7-c886d087b6af)

Then used that in my app:

![Screenshot 2025-01-18 at 20 04
33](https://github.com/user-attachments/assets/21f77158-7535-453a-b988-49cf59d22d71)

and get myself some compiler messages:

```
/Users/orta/dev/app/apps/puzzmo.com/src/palette/HoverPopover.tsx
  31:37  error  Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning)  react-compiler/react-compiler

/Users/orta/dev/app/apps/puzzmo.com/src/components/gameplay/PlayGamePauseOverlay.tsx
   33:7   error  Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)  react-compiler/react-compiler
   35:5   error  Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)  react-compiler/react-compiler
```

DiffTrain build for [18eaf51](facebook@18eaf51)
  • Loading branch information
vnlemanhthanh committed Jan 20, 2025
1 parent 3aec5d5 commit d61e403
Show file tree
Hide file tree
Showing 72 changed files with 336,298 additions and 461,838 deletions.
1,355 changes: 551 additions & 804 deletions compiled/babel-plugin-react-refresh/index.js

Large diffs are not rendered by default.

2,319 changes: 751 additions & 1,568 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js

Large diffs are not rendered by default.

2,322 changes: 751 additions & 1,571 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6f18664b82b61d34b30c794a151d7b032f8eabe0
18eaf51bd51fed8dfed661d64c306759101d0bfd
1 change: 1 addition & 0 deletions compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18eaf51bd51fed8dfed661d64c306759101d0bfd
Loading

0 comments on commit d61e403

Please sign in to comment.