From 4354edadf4d519e7cb3f5ab1d565c35acecb2751 Mon Sep 17 00:00:00 2001 From: Leah Date: Fri, 21 Apr 2023 20:52:08 +0200 Subject: [PATCH] fix snapshots broken by prettier (also fix .prettierignore) (#48586) ### What? Fix snapshots that were no longer fulfilling the original purpose after prettier had its way. The `.prettierignore` also had the old `target/` directory (prior to the `Cargo.toml` move in #48198) so running `pnpm prettier-fix` formatted files in the `target/` directory --- .prettierignore | 40 +++++++++++-------- .../client-graph/use-client/input.js | 4 +- .../client-graph/use-client/output.js | 1 - .../client-graph/use-client/output.stderr | 10 ++--- .../tests/errors/server-actions/8/input.js | 4 +- .../tests/errors/server-actions/8/output.js | 1 + .../errors/server-actions/8/output.stderr | 8 ++++ .../tests/errors/server-actions/9/input.js | 4 +- .../tests/errors/server-actions/9/output.js | 1 + .../errors/server-actions/9/output.stderr | 10 ++--- .../client-graph/client-entry/input.js | 8 +++- .../client-graph/client-entry/output.js | 4 +- .../server-graph/client-entry/input.js | 8 +++- .../core/tests/loader/issue-32553/input.js | 3 +- packages/next-swc/crates/next-build/build.rs | 4 +- 15 files changed, 70 insertions(+), 40 deletions(-) diff --git a/.prettierignore b/.prettierignore index 9ba6c5b6e9de1..8f620ce2ae63c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,31 +1,39 @@ -node_modules -**/.next/** -**/_next/** -**/dist/** +# Build artifacts +.next/ +.turbo/ +_next/ +__tmp__/ +dist/ +node_modules/ +target/ +compiled/ + +lerna.json +test-timings.json +pnpm-lock.yaml + packages/next/src/bundles/webpack/packages/*.runtime.js packages/next/src/bundles/webpack/packages/lazy-compilation-*.js -packages/next/src/compiled/** -packages/react-refresh-utils/**/*.js -packages/react-refresh-utils/**/*.d.ts -packages/react-dev-overlay/lib/** -**/__tmp__/** -lerna.json + .github/actions/next-stats-action/.work .github/actions/issue-validator/index.mjs .github/actions/issue-labeler/lib/index.js -packages/next-swc/crates/next-core/js/src/compiled/**/* + packages/next-swc/crates/**/tests/**/output* -packages/next-swc/target/**/* +packages/next-swc/crates/core/tests/loader/issue-32553/input.js packages/next-swc/native/**/* -packages/next-codemod/transforms/__testfixtures__/**/* -packages/next-codemod/transforms/__tests__/**/* + +packages/next-codemod/transforms/__testfixtures__/** +packages/next-codemod/transforms/__tests__/** packages/next-codemod/**/*.js packages/next-codemod/**/*.d.ts + packages/next-env/**/*.d.ts -test-timings.json + test/**/out/** test/development/basic/hmr/components/parse-error.js + bench/nested-deps/pages/**/* bench/nested-deps/components/**/* -pnpm-lock.yaml + **/convex/_generated/** diff --git a/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/input.js b/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/input.js index f596a11550cd1..40c4c830b0a34 100644 --- a/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/input.js +++ b/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/input.js @@ -1,5 +1,7 @@ import 'react' -;('use client') + +// prettier-ignore +'use client' export default function () { return null diff --git a/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.js b/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.js index 840a45ad97feb..bc702e4c65f04 100644 --- a/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.js +++ b/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.js @@ -1,5 +1,4 @@ import 'react'; -'use client'; export default function() { return null; } diff --git a/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.stderr b/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.stderr index 7be30ea0e46fa..6612b3a33d057 100644 --- a/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.stderr +++ b/packages/next-swc/crates/core/tests/errors/react-server-components/client-graph/use-client/output.stderr @@ -1,7 +1,7 @@ - x NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN - ,-[input.js:1:1] - 1 | import 'react' - 2 | ;('use client') - : ^^^^^^^^^^^^^^ + x NEXT_RSC_ERR_CLIENT_DIRECTIVE + ,-[input.js:3:1] + 3 | // prettier-ignore + 4 | 'use client' + : ^^^^^^^^^^^^ `---- diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/8/input.js b/packages/next-swc/crates/core/tests/errors/server-actions/8/input.js index 82167cb53ce0f..df7c2ff253ec7 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/8/input.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/8/input.js @@ -5,5 +5,7 @@ const foo = async () => { const bar = async () => { const x = 1 - ;('use server') + + // prettier-ignore + 'use server' } diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/8/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/8/output.js index 273fb077b5c25..329134acc154c 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/8/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/8/output.js @@ -5,5 +5,6 @@ export const $$ACTION_1 = async (closure)=>{ var $$ACTION_0; const bar = async ()=>{ const x = 1; + // prettier-ignore 'use server'; }; diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/8/output.stderr b/packages/next-swc/crates/core/tests/errors/server-actions/8/output.stderr index e69de29bb2d1d..c4f7406218d3f 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/8/output.stderr +++ b/packages/next-swc/crates/core/tests/errors/server-actions/8/output.stderr @@ -0,0 +1,8 @@ + + x The "use server" directive must be at the top of the function body. + ,-[input.js:9:1] + 9 | // prettier-ignore + 10 | 'use server' + : ^^^^^^^^^^^^ + 11 | } + `---- diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/9/input.js b/packages/next-swc/crates/core/tests/errors/server-actions/9/input.js index 8671beb440c17..57d30b5aa7d27 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/9/input.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/9/input.js @@ -1,2 +1,4 @@ import 'my-module' -;('use server') + +// prettier-ignore +'use server' diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/9/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/9/output.js index 3bb78b3693b64..74a80677fc0bf 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/9/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/9/output.js @@ -1,2 +1,3 @@ import 'my-module'; +// prettier-ignore 'use server'; diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/9/output.stderr b/packages/next-swc/crates/core/tests/errors/server-actions/9/output.stderr index 70b9286eb4fde..2dc39c2900bde 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/9/output.stderr +++ b/packages/next-swc/crates/core/tests/errors/server-actions/9/output.stderr @@ -1,7 +1,7 @@ - x The "use server" directive must be at the top of the file, and cannot be wrapped in parentheses. - ,-[input.js:1:1] - 1 | import 'my-module' - 2 | ;('use server') - : ^^^^^^^^^^^^^^ + x The "use server" directive must be at the top of the file. + ,-[input.js:3:1] + 3 | // prettier-ignore + 4 | 'use server' + : ^^^^^^^^^^^^ `---- diff --git a/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/input.js b/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/input.js index b90ea564bdf02..cd959224f9ee2 100644 --- a/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/input.js +++ b/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/input.js @@ -15,12 +15,16 @@ 'use client' import 'fs' -;('bar') + +// prettier-ignore +'bar' // This is a comment. 1 + 1 -;('baz') + +// prettier-ignore +'baz' export default function () { return null diff --git a/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/output.js b/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/output.js index fb3d6987479c1..cbef357e0a8f3 100644 --- a/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/output.js +++ b/packages/next-swc/crates/core/tests/fixture/react-server-components/client-graph/client-entry/output.js @@ -3,10 +3,12 @@ // This is a comment. 'foo'; import 'fs'; +// prettier-ignore 'bar'; // This is a comment. 1 + 1; +// prettier-ignore 'baz'; export default function() { - return null; + return null; } diff --git a/packages/next-swc/crates/core/tests/fixture/react-server-components/server-graph/client-entry/input.js b/packages/next-swc/crates/core/tests/fixture/react-server-components/server-graph/client-entry/input.js index 4275f2ca942f8..8ed68126b4082 100644 --- a/packages/next-swc/crates/core/tests/fixture/react-server-components/server-graph/client-entry/input.js +++ b/packages/next-swc/crates/core/tests/fixture/react-server-components/server-graph/client-entry/input.js @@ -13,12 +13,16 @@ 'random-directive' import 'fs' -;('qwerty') + +// prettier-ignore +'qwerty' // This is a comment. 1 + 1 -;('sasaya') + +// prettier-ignore +'sasaya' export default function () { return null diff --git a/packages/next-swc/crates/core/tests/loader/issue-32553/input.js b/packages/next-swc/crates/core/tests/loader/issue-32553/input.js index a86d6ddb53596..02143e79a2e71 100644 --- a/packages/next-swc/crates/core/tests/loader/issue-32553/input.js +++ b/packages/next-swc/crates/core/tests/loader/issue-32553/input.js @@ -1,2 +1 @@ -;
children
-;('<>hello') +
children
; '<>hello' diff --git a/packages/next-swc/crates/next-build/build.rs b/packages/next-swc/crates/next-build/build.rs index 46fc9a94dfe0d..fe7deb8608b61 100644 --- a/packages/next-swc/crates/next-build/build.rs +++ b/packages/next-swc/crates/next-build/build.rs @@ -1,11 +1,9 @@ -use turbo_binding::turbo::tasks_build::{generate_register, rerun_if_glob}; +use turbo_binding::turbo::tasks_build::generate_register; use vergen::{vergen, Config}; fn main() { generate_register(); - rerun_if_glob("tests/integration/*/*", "tests/integration"); - // Attempt to collect some build time env values but will skip if there are any // errors. let _ = vergen(Config::default());