@samitouri / QOS-React-2 / commits / 059365d726

[eslint-plugin] Temporarily only lint on 'use forget'

Temporarily enabling 'use forget' only mode for the linter to address #1751 so we can land the stack internally

Lauren Tan committed Jun 20, 2023 at 12:30 UTC 059365d7260d5d7ba2a722aa5b427ab2d3b50877
2 files changed +11 -6
compiler/forget/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
+10 -6
@@ -23,6 +23,7 @@ const tests: ForgetTestCases = {
23 name: "Basic example",
24 code: normalizeIndent`
25 function foo(x, y) {
26 + 'use forget';
27 if (x) {
28 return foo(false, y);
29 }
@@ -34,6 +35,7 @@ const tests: ForgetTestCases = {
35 name: "Unsupported syntax",
36 code: normalizeIndent`
37 function foo(x) {
38 + 'use forget';
39 var y = 1;
40 return y * x;
41 }
@@ -45,6 +47,7 @@ const tests: ForgetTestCases = {
47 name: "[InvalidInput] Ref access during render",
48 code: normalizeIndent`
49 function Component(props) {
50 + 'use forget';
51 const ref = useRef(null);
52 const value = ref.current;
53 return value;
@@ -53,11 +56,11 @@ const tests: ForgetTestCases = {
56 errors: [
57 {
58 message:
56 - "[ReactForget] InvalidInput: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $23:TObject<BuiltInRefValue> (5:5)",
57 - line: 5,
59 + "[ReactForget] InvalidInput: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $23:TObject<BuiltInRefValue> (6:6)",
60 + line: 6,
61 column: 10,
62 endColumn: 15,
60 - endLine: 5,
63 + endLine: 6,
64 },
65 ],
66 },
@@ -65,6 +68,7 @@ const tests: ForgetTestCases = {
68 name: "[Invariant] Defined after use",
69 code: normalizeIndent`
70 function Component(props) {
71 + 'use forget';
72 let y = function () {
73 m(x);
74 };
@@ -77,11 +81,11 @@ const tests: ForgetTestCases = {
81 errors: [
82 {
83 message:
80 - "[ReactForget] Invariant: EnterSSA: Expected identifier to be defined before being used. Identifier x$2 is undefined (7:7)",
81 - line: 7,
84 + "[ReactForget] Invariant: EnterSSA: Expected identifier to be defined before being used. Identifier x$2 is undefined (8:8)",
85 + line: 8,
86 column: 3,
87 endColumn: 17,
84 - endLine: 7,
88 + endLine: 8,
89 },
90 ],
91 },
compiler/forget/packages/eslint-plugin-react-forget/src/rules/ReactForgetDiagnostics.ts
+1
@@ -27,6 +27,7 @@ const rule: Rule.RuleModule = {
27 const filename = context.filename ?? context.getFilename();
28
29 const opts: Partial<PluginOptions> = {
30 + enableOnlyOnUseForgetDirective: true,
31 panicOnBailout: false,
32 environment: {
33 validateHooksUsage: true,