Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,18 @@ function tryCompileFunction(
fn,
);
if (suppressionsInFunction.length > 0) {
return {
kind: 'error',
error: suppressionsToCompilerError(suppressionsInFunction),
};
if (!programContext.opts.noEmit) {
return {
kind: 'error',
error: suppressionsToCompilerError(suppressionsInFunction),
};
}
/* ESLint mode: log suppression but continue analysis */
logError(
suppressionsToCompilerError(suppressionsInFunction),
programContext,
fn.node.loc ?? null,
);
}

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

## Input

```javascript
// @noEmit
import {useEffect} from 'react';
import {useKnownIncompatible} from 'ReactCompilerKnownIncompatibleTest';

function MyHook() {
const data = useKnownIncompatible();

useEffect(() => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return data;
}

export const FIXTURE_ENTRYPOINT = {
fn: MyHook,
params: [],
};

```


## Error

```
Found 1 error:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Test expectation shows "Found 1 error" but the implementation will produce 2 errors. The eslint suppression on line 9 of the test file (react-hooks/exhaustive-deps) is in DEFAULT_ESLINT_SUPPRESSIONS and will be detected. In ESLint mode, the code logs this suppression error (Program.ts:744-748) then continues compilation, which throws an incompatible-library error that also gets logged (Program.ts:647 via handleError). The expected output should state "Found 2 errors:" and include both the suppression error and the incompatible-library error.

Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.eslint-mode-detects-incompatible-library-with-suppression.expect.md
Line: 30:30

Comment:
[P1] Test expectation shows "Found 1 error" but the implementation will produce 2 errors. The eslint suppression on line 9 of the test file (`react-hooks/exhaustive-deps`) is in DEFAULT_ESLINT_SUPPRESSIONS and will be detected. In ESLint mode, the code logs this suppression error (Program.ts:744-748) then continues compilation, which throws an incompatible-library error that also gets logged (Program.ts:647 via handleError). The expected output should state "Found 2 errors:" and include both the suppression error and the incompatible-library error.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: expected output says "Found 1 error" but the implementation produces 2 errors: the react-hooks/exhaustive-deps suppression on line 9 is in DEFAULT_ESLINT_SUPPRESSIONS (Program.ts:338), so in ESLint mode it logs this suppression error (Program.ts:744-748), then continues compilation which throws the incompatible-library error that also gets logged (Program.ts:647). the output should state "Found 2 errors:" and include both errors

Suggested change
Found 1 error:
Found 2 errors:
Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.eslint-mode-detects-incompatible-library-with-suppression.expect.md
Line: 30:30

Comment:
**syntax:** expected output says "Found 1 error" but the implementation produces 2 errors: the `react-hooks/exhaustive-deps` suppression on line 9 is in DEFAULT_ESLINT_SUPPRESSIONS (Program.ts:338), so in ESLint mode it logs this suppression error (Program.ts:744-748), then continues compilation which throws the incompatible-library error that also gets logged (Program.ts:647). the output should state "Found 2 errors:" and include both errors

```suggestion
Found 2 errors:
```

How can I resolve this? If you propose a fix, please make it concise.


Compilation Skipped: Use of incompatible library

This API returns functions which cannot be memoized without leading to stale UI. To prevent this, by default React Compiler will skip memoizing this component/hook. However, you may see issues if values from this API are passed to other components/hooks that are memoized.

error.eslint-mode-detects-incompatible-library-with-suppression.ts:6:15
4 |
5 | function MyHook() {
> 6 | const data = useKnownIncompatible();
| ^^^^^^^^^^^^^^^^^^^^ useKnownIncompatible is known to be incompatible
7 |
8 | useEffect(() => {
9 | // eslint-disable-next-line react-hooks/exhaustive-deps
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @noEmit
import {useEffect} from 'react';
import {useKnownIncompatible} from 'ReactCompilerKnownIncompatibleTest';

function MyHook() {
const data = useKnownIncompatible();

useEffect(() => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return data;
}

export const FIXTURE_ENTRYPOINT = {
fn: MyHook,
params: [],
};
Loading