@samitouri / QOS-React-2 / commits / 3634980183

[eslint] Switch compiler to "infer" mode

Lauren Tan committed Nov 3, 2023 at 16:27 UTC 3634980183b88501a0726ac318b600d706036ad4
2 files changed +5 -12
compiler/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
+4 -11
@@ -29,7 +29,6 @@ const tests: ForgetTestCases = {
29 name: "Basic example",
30 code: normalizeIndent`
31 function foo(x, y) {
32 - 'use forget';
32 if (x) {
33 return foo(false, y);
34 }
@@ -44,7 +43,6 @@ const tests: ForgetTestCases = {
43 text: string = 'Hello!',
44 onClick: () => void,
45 ) {
47 - 'use forget';
46 return <div onClick={onClick}>{text}</div>;
47 }
48 `,
@@ -53,7 +51,6 @@ const tests: ForgetTestCases = {
51 name: "Unsupported syntax",
52 code: normalizeIndent`
53 function foo(x) {
56 - 'use forget';
54 var y = 1;
55 return y * x;
56 }
@@ -64,7 +61,6 @@ const tests: ForgetTestCases = {
61 name: "[Invariant] Defined after use",
62 code: normalizeIndent`
63 function Component(props) {
67 - 'use forget';
64 let y = function () {
65 m(x);
66 };
@@ -81,7 +77,6 @@ const tests: ForgetTestCases = {
77 name: "[InvalidInput] Ref access during render",
78 code: normalizeIndent`
79 function Component(props) {
84 - 'use forget';
80 const ref = useRef(null);
81 const value = ref.current;
82 return value;
@@ -91,10 +86,10 @@ const tests: ForgetTestCases = {
86 {
87 message:
88 "[ReactForget] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)",
94 - line: 6,
89 + line: 5,
90 column: 10,
91 endColumn: 15,
97 - endLine: 6,
92 + endLine: 5,
93 },
94 ],
95 },
@@ -103,9 +98,8 @@ const tests: ForgetTestCases = {
98 // Indentation is intentionally weird so it doesn't add extra whitespace
99 code: normalizeIndent`
100 function Component(props) {
106 - 'use forget';
101 // eslint-disable-next-line react-hooks/rules-of-hooks
108 - Component();
102 + return <div>{props.foo}</div>;
103 }`,
104 errors: [
105 {
@@ -115,9 +109,8 @@ const tests: ForgetTestCases = {
109 {
110 output: normalizeIndent`
111 function Component(props) {
118 - 'use forget';
112
120 - Component();
113 + return <div>{props.foo}</div>;
114 }`,
115 },
116 ],
compiler/packages/eslint-plugin-react-forget/src/rules/ReactForgetDiagnostics.ts
+1 -1
@@ -59,7 +59,7 @@ function isReportableDiagnostic(
59
60 const COMPILER_OPTIONS: Partial<PluginOptions> = {
61 noEmit: true,
62 - compilationMode: "annotation",
62 + compilationMode: "infer",
63 panicThreshold: "CRITICAL_ERRORS",
64 environment: {
65 validateHooksUsage: true,