From 120bba597dea0915129f8bb9f849891135629f58 Mon Sep 17 00:00:00 2001 From: Adam Patterson Date: Fri, 3 Oct 2025 10:27:20 -0700 Subject: [PATCH] LibJS: Remove using-declaration.js from .prettierignore This is the second and final commit to remove using-declaration from .prettierignore. While there is standard formatting changes here, there is also scoping changes for the 'using' declarations due to the following error: Libraries/LibJS/Tests/using-declaration.js: SyntaxError: Using declaration cannot appear in the top level when source type is `script` or in the bare case statement. --- .prettierignore | 3 -- Libraries/LibJS/Tests/using-declaration.js | 48 +++++++++++++++------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.prettierignore b/.prettierignore index 64d77eb4f1..cfd7151e78 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,9 +2,6 @@ Libraries/LibJS/Tests/invalid-lhs-in-assignment.js Libraries/LibJS/Tests/unicode-identifier-escape.js Libraries/LibJS/Tests/modules/failing.mjs -# FIXME: Remove once prettier is updated to support using declarations. -Libraries/LibJS/Tests/using-declaration.js - Tests/LibWeb/Crash/wpt-import/ Tests/LibWeb/Ref/input/wpt-import Tests/LibWeb/Text/input/wpt-import diff --git a/Libraries/LibJS/Tests/using-declaration.js b/Libraries/LibJS/Tests/using-declaration.js index 1c36029eb0..50318d5855 100644 --- a/Libraries/LibJS/Tests/using-declaration.js +++ b/Libraries/LibJS/Tests/using-declaration.js @@ -307,9 +307,14 @@ describe("works in a bunch of scopes", () => { } switch (2) { - case 3: - using notDisposed = { [Symbol.dispose]() { expect().fail("not-disposed 1"); } }; - case 2: + case 3: { + using notDisposed = { + [Symbol.dispose]() { + expect().fail("not-disposed 1"); + }, + }; + } + case 2: { expect(disposeFull).toEqual([]); using a = pusher("a"); expect(disposeFull).toEqual([]); @@ -318,22 +323,35 @@ describe("works in a bunch of scopes", () => { expect(disposeFull).toEqual([]); expect(b.val).toBe("b"); - expect(disposeInner).toBeFalse(); - // fallthrough - case 1: { - expect(disposeFull).toEqual([]); - expect(disposeInner).toBeFalse(); - - using inner = { [Symbol.dispose]() { disposeInner = true; } } - expect(disposeInner).toBeFalse(); } + // fallthrough + case 1: + { + expect(disposeFull).toEqual([]); + expect(disposeInner).toBeFalse(); + + using inner = { + [Symbol.dispose]() { + disposeInner = true; + }, + }; + + expect(disposeInner).toBeFalse(); + } expect(disposeInner).toBeTrue(); - using c = pusher("c"); - expect(c.val).toBe("c"); + { + using c = pusher("c"); + expect(c.val).toBe("c"); + } break; - case 0: - using notDisposed2 = { [Symbol.dispose]() { expect().fail("not-disposed 2"); } }; + case 0: { + using notDisposed2 = { + [Symbol.dispose]() { + expect().fail("not-disposed 2"); + }, + }; + } } expect(disposeInner).toBeTrue();