Unverified Commit 9b3bd73b authored by Leah's avatar Leah Committed by GitHub

prettier fix for `next-swc` (#47873)

This enables the existing prettier config to auto apply to code inside
the `next-swc` package
parent 191acdf8
......@@ -13,7 +13,8 @@ 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/**/*
packages/next-swc/crates/next-core/js/src/compiled/**/*
packages/next-swc/crates/**/tests/**/output*
packages/next-swc/target/**/*
packages/next-swc/native/**/*
packages/next-codemod/transforms/__testfixtures__/**/*
......
......@@ -3,5 +3,5 @@ import dynamic from 'next/dynamic'
const DynamicComponentWithCustomLoading = dynamic(
() => import('../components/hello'),
{ loading: () => <p>...</p> },
"3rd"
'3rd'
)
import dynamic from 'next/dynamic'
const DynamicComponentWithCustomLoading = dynamic(
() => import('../components/hello'),
{ loading: () => <p>...</p> },
"3rd"
)
import dynamic from 'next/dynamic';
const DynamicComponentWithCustomLoading = dynamic(()=>import('../components/hello'), {
loading: ()=><p>...</p>
}, '3rd');
const getStaticProps = async () => {}
export { a as getServerSideProps }
export { a as getServerSideProps }
......@@ -2,6 +2,6 @@
x You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps
,-[input.js:1:1]
1 | const getStaticProps = async () => {}
2 | export { a as getServerSideProps }
2 | export { a as getServerSideProps }
: ^^^^^^^^^^^^^^^^^^
`----
export { a as getServerSideProps } from './input'
export { getStaticPaths } from 'a'
// This is a comment.
"use strict";
'use strict'
/**
* This is a comment.
*/
import "client-only"
import 'client-only'
export default function () {
return null;
return null
}
// This is a comment.
"use strict";
'use strict';
/**
* This is a comment.
*/ import "client-only";
*/ import 'client-only';
export default function() {
return null;
}
export function getServerSideProps (){
}
export function getServerSideProps() {}
export default function () {
return null;
return null
}
x NEXT_RSC_ERR_INVALID_API: getServerSideProps
,-[input.js:1:1]
1 | export function getServerSideProps (){
1 | export function getServerSideProps() {}
: ^^^^^^^^^^^^^^^^^^
2 | }
`----
export function getStaticProps (){
}
export function getStaticProps() {}
export default function () {
return null;
return null
}
x NEXT_RSC_ERR_INVALID_API: getStaticProps
,-[input.js:1:1]
1 | export function getStaticProps (){
1 | export function getStaticProps() {}
: ^^^^^^^^^^^^^^
2 | }
`----
// This is a comment.
"use strict";
'use strict'
/**
* This is a comment.
*/
import "server-only"
import 'server-only'
export default function () {
return null;
return null
}
// This is a comment.
"use strict";
'use strict';
/**
* This is a comment.
*/ import "server-only";
*/ import 'server-only';
export default function() {
return null;
}
......@@ -2,6 +2,6 @@
x NEXT_RSC_ERR_CLIENT_IMPORT: server-only
,-[input.js:8:1]
8 |
9 | import "server-only"
9 | import 'server-only'
: ^^^^^^^^^^^^^^^^^^^^
`----
import "react"
"use client"
import 'react'
;('use client')
export default function () {
return null;
return null
}
import "react";
export default function () {
return null;
import 'react';
'use client';
export default function() {
return null;
}
x NEXT_RSC_ERR_CLIENT_DIRECTIVE
,-[input.js:2:1]
2 |
3 | "use client"
: ^^^^^^^^^^^^
x NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN
,-[input.js:1:1]
1 | import 'react'
2 | ;('use client')
: ^^^^^^^^^^^^^^
`----
// This is a comment.
"use strict";
'use strict'
/**
* This is a comment.
*/
import "client-only"
import 'client-only'
export default function () {
return null;
return null
}
// This is a comment.
"use strict";
'use strict';
/**
* This is a comment.
*/ import "client-only";
*/ import 'client-only';
export default function() {
return null;
}
......@@ -2,6 +2,6 @@
x NEXT_RSC_ERR_SERVER_IMPORT: client-only
,-[input.js:8:1]
8 |
9 | import "client-only"
9 | import 'client-only'
: ^^^^^^^^^^^^^^^^^^^^
`----
export function getServerSideProps (){
}
export function getServerSideProps() {}
export default function () {
return null;
return null
}
x NEXT_RSC_ERR_INVALID_API: getServerSideProps
,-[input.js:1:1]
1 | export function getServerSideProps (){
1 | export function getServerSideProps() {}
: ^^^^^^^^^^^^^^^^^^
2 | }
`----
export function getStaticProps (){
}
export function getStaticProps() {}
export default function () {
return null;
return null
}
x NEXT_RSC_ERR_INVALID_API: getStaticProps
,-[input.js:1:1]
1 | export function getStaticProps (){
1 | export function getStaticProps() {}
: ^^^^^^^^^^^^^^
2 | }
`----
......@@ -5,17 +5,17 @@ import { createContext } from 'react'
import { useEffect, useImperativeHandle } from 'react'
import {
Component,
createFactory,
PureComponent,
Component,
createFactory,
PureComponent,
useDeferredValue,
useInsertionEffect,
useLayoutEffect,
useReducer,
useRef,
useSyncExternalStore
} from "react"
useInsertionEffect,
useLayoutEffect,
useReducer,
useRef,
useSyncExternalStore,
} from 'react'
export default function () {
return null;
return null
}
import { useState } from 'react';
import { createContext } from 'react';
import { useEffect, useImperativeHandle } from 'react';
import { Component, createFactory, PureComponent, useDeferredValue, useInsertionEffect, useLayoutEffect, useReducer, useRef, useSyncExternalStore } from "react";
import { Component, createFactory, PureComponent, useDeferredValue, useInsertionEffect, useLayoutEffect, useReducer, useRef, useSyncExternalStore } from 'react';
export default function() {
return null;
}
......@@ -29,71 +29,71 @@
x NEXT_RSC_ERR_REACT_API: Component
,-[input.js:7:1]
7 | import {
8 | Component,
: ^^^^^^^^^
9 | createFactory,
8 | Component,
: ^^^^^^^^^
9 | createFactory,
`----
x NEXT_RSC_ERR_REACT_API: createFactory
,-[input.js:8:1]
8 | Component,
9 | createFactory,
: ^^^^^^^^^^^^^
10 | PureComponent,
8 | Component,
9 | createFactory,
: ^^^^^^^^^^^^^
10 | PureComponent,
`----
x NEXT_RSC_ERR_REACT_API: PureComponent
,-[input.js:9:1]
9 | createFactory,
10 | PureComponent,
: ^^^^^^^^^^^^^
9 | createFactory,
10 | PureComponent,
: ^^^^^^^^^^^^^
11 | useDeferredValue,
`----
x NEXT_RSC_ERR_REACT_API: useDeferredValue
,-[input.js:10:1]
10 | PureComponent,
10 | PureComponent,
11 | useDeferredValue,
: ^^^^^^^^^^^^^^^^
12 | useInsertionEffect,
12 | useInsertionEffect,
`----
x NEXT_RSC_ERR_REACT_API: useInsertionEffect
,-[input.js:11:1]
11 | useDeferredValue,
12 | useInsertionEffect,
: ^^^^^^^^^^^^^^^^^^
13 | useLayoutEffect,
12 | useInsertionEffect,
: ^^^^^^^^^^^^^^^^^^
13 | useLayoutEffect,
`----
x NEXT_RSC_ERR_REACT_API: useLayoutEffect
,-[input.js:12:1]
12 | useInsertionEffect,
13 | useLayoutEffect,
: ^^^^^^^^^^^^^^^
14 | useReducer,
12 | useInsertionEffect,
13 | useLayoutEffect,
: ^^^^^^^^^^^^^^^
14 | useReducer,
`----
x NEXT_RSC_ERR_REACT_API: useReducer
,-[input.js:13:1]
13 | useLayoutEffect,
14 | useReducer,
: ^^^^^^^^^^
15 | useRef,
13 | useLayoutEffect,
14 | useReducer,
: ^^^^^^^^^^
15 | useRef,
`----
x NEXT_RSC_ERR_REACT_API: useRef
,-[input.js:14:1]
14 | useReducer,
15 | useRef,
: ^^^^^^
16 | useSyncExternalStore
14 | useReducer,
15 | useRef,
: ^^^^^^
16 | useSyncExternalStore,
`----
x NEXT_RSC_ERR_REACT_API: useSyncExternalStore
,-[input.js:15:1]
15 | useRef,
16 | useSyncExternalStore
: ^^^^^^^^^^^^^^^^^^^^
17 | } from "react"
15 | useRef,
16 | useSyncExternalStore,
: ^^^^^^^^^^^^^^^^^^^^
17 | } from 'react'
`----
import {
findDOMNode,
flushSync,
unstable_batchedUpdates,
} from "react-dom"
import { findDOMNode, flushSync, unstable_batchedUpdates } from 'react-dom'
export default function () {
return null;
return null
}
import { findDOMNode, flushSync, unstable_batchedUpdates } from "react-dom";
import { findDOMNode, flushSync, unstable_batchedUpdates } from 'react-dom';
export default function() {
return null;
}
x NEXT_RSC_ERR_REACT_API: findDOMNode
,-[input.js:1:1]
1 | import {
2 | findDOMNode,
: ^^^^^^^^^^^
3 | flushSync,
1 | import { findDOMNode, flushSync, unstable_batchedUpdates } from 'react-dom'
: ^^^^^^^^^^^
`----
x NEXT_RSC_ERR_REACT_API: flushSync
,-[input.js:2:1]
2 | findDOMNode,
3 | flushSync,
: ^^^^^^^^^
4 | unstable_batchedUpdates,
,-[input.js:1:1]
1 | import { findDOMNode, flushSync, unstable_batchedUpdates } from 'react-dom'
: ^^^^^^^^^
`----
x NEXT_RSC_ERR_REACT_API: unstable_batchedUpdates
,-[input.js:3:1]
3 | flushSync,
4 | unstable_batchedUpdates,
: ^^^^^^^^^^^^^^^^^^^^^^^
5 | } from "react-dom"
,-[input.js:1:1]
1 | import { findDOMNode, flushSync, unstable_batchedUpdates } from 'react-dom'
: ^^^^^^^^^^^^^^^^^^^^^^^
`----
// This is a comment.
"use strict";
'use strict'
/**
* This is a comment.
*/
import "react-dom/server"
import 'react-dom/server'
import "react-dom/client"
import 'react-dom/client'
export default function () {
return null;
return null
}
// This is a comment.
"use strict";
'use strict';
/**
* This is a comment.
*/ import "react-dom/server";
import "react-dom/client";
*/ import 'react-dom/server';
import 'react-dom/client';
export default function() {
return null;
}
......@@ -2,13 +2,13 @@
x NEXT_RSC_ERR_SERVER_IMPORT: react-dom/server
,-[input.js:8:1]
8 |
9 | import "react-dom/server"
9 | import 'react-dom/server'
: ^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x NEXT_RSC_ERR_SERVER_IMPORT: react-dom/client
,-[input.js:10:1]
10 |
11 | import "react-dom/client"
11 | import 'react-dom/client'
: ^^^^^^^^^^^^^^^^^^^^^^^^^
`----
'use sevrer'
export async function foo () {}
export async function foo() {}
import 'react'
('use sevrer')
;('use sevrer')
// ^Tools like Prettier sometimes do this.
x The "use server" directive must be at the top of the file, and cannot be wrapped in parentheses.
,-[input.js:2:1]
2 |
3 | ('use sevrer')
: ^^^^^^^^^^^^^^
,-[input.js:1:1]
1 | import 'react'
2 | ;('use sevrer')
: ^^^^^^^^^^^^^^
`----
'use strict';
'use strict'
// comment
'use server';
'use server'
export function bar() {}
'use server';
'use server'
export default class Component {
render() {
return null;
return null
}
}
......@@ -4,7 +4,7 @@
2 |
3 | ,-> export default class Component {
4 | | render() {
5 | | return null;
5 | | return null
6 | | }
7 | `-> }
`----
......@@ -5,5 +5,5 @@ const foo = async () => {
const bar = async () => {
const x = 1
'use server'
;('use server')
}
x The "use server" directive must be at the top of the function body.
,-[input.js:7:1]
7 | const x = 1
8 | 'use server'
: ^^^^^^^^^^^^
9 | }
`----
x The "use server" directive must be at the top of the file.
,-[input.js:2:1]
2 |
3 | 'use server'
: ^^^^^^^^^^^^
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')
: ^^^^^^^^^^^^^^
`----
......@@ -3,5 +3,5 @@ import dynamic from 'next/dynamic'
const DynamicComponent = dynamic(() => import(`../components/hello`))
const componentRoot = '@/some-components'
const Component1 = dynamic(() => import(`${componentRoot}/component1`));
const Component2 = dynamic(() => import(`${componentRoot}/component2`));
\ No newline at end of file
const Component1 = dynamic(() => import(`${componentRoot}/component1`))
const Component2 = dynamic(() => import(`${componentRoot}/component2`))
import dynamic from 'next/dynamic'
const DynamicComponent = dynamic(() => handleImport(import('./components/hello')), {
loading: () => null,
ssr: false,
});
\ No newline at end of file
const DynamicComponent = dynamic(
() => handleImport(import('./components/hello')),
{
loading: () => null,
ssr: false,
}
)
......@@ -4,4 +4,4 @@ function About(props) {
return <h3>My AMP About Page!</h3>
}
export default About
\ No newline at end of file
export default About
......@@ -4,4 +4,4 @@ function About(props) {
return <h3>My AMP About Page!</h3>
}
export default About
\ No newline at end of file
export default About
export default function Home() {
return <div data-test-id="1" data-custom="1a">
<div data-custom="2">
<h1 data-testid="3">Hello World!</h1>
return (
<div data-test-id="1" data-custom="1a">
<div data-custom="2">
<h1 data-testid="3">Hello World!</h1>
</div>
</div>
</div>
)
}
export default function Home() {
return <div data-test-id="1">
<div>
<div>
<h1 data-testid="3">Hello World!</h1>
<h1 data-testid="3">Hello World!</h1>
</div>
</div>
</div>;
</div>;
}
export default function Home() {
return <div data-test-id="1" data-custom="1a">
<div data-custom="2">
<h1 data-testid="3" nested={() => (<div data-testid="4">nested</div>)}>Hello World!</h1>
return (
<div data-test-id="1" data-custom="1a">
<div data-custom="2">
<h1 data-testid="3" nested={() => <div data-testid="4">nested</div>}>
Hello World!
</h1>
</div>
</div>
</div>
)
}
export default function Home() {
return <div data-custom="1a">
<div data-custom="2">
<div data-custom="2">
<h1 nested={()=><div>nested</div>}>Hello World!</h1>
<h1 nested={()=><div>nested</div>}>
</div>
Hello World!
</div>;
</h1>
</div>
</div>;
}
// This is a comment.
"use strict";
'use strict'
/**
* This is a comment.
*/
"use client";
'use client'
// This is a comment.
"foo";
'foo'
"use client";
'use client'
import "fs"
"bar";
import 'fs'
;('bar')
// This is a comment.
1 + 1;
"baz";
1 + 1
;('baz')
export default function () {
return null;
return null
}
// This is a comment.
/* __next_internal_client_entry_do_not_use__ default auto */ "use strict";
/* __next_internal_client_entry_do_not_use__ default auto */ 'use strict';
// This is a comment.
"foo";
import "fs";
"bar";
'foo';
import 'fs';
'bar';
// This is a comment.
1 + 1;
"baz";
'baz';
export default function() {
return null;
return null;
}
// This is a comment.
"use strict";
'use strict'
/**
* This is a comment.
*/
"use client";
'use client'
// This is a comment.
"random-directive";
'random-directive'
import "fs"
"qwerty";
import 'fs'
;('qwerty')
// This is a comment.
1 + 1;
"sasaya";
1 + 1
;('sasaya')
export default function () {
return null;
return null
}
export const a = 1
......
......@@ -25,12 +25,12 @@ const variableMutation = graphql`
`
commitMutation(
environment,
graphql`
query InputUsedInFunctionCallMutation {
someMutation
}
`
environment,
graphql`
query InputUsedInFunctionCallMutation {
someMutation
}
`
)
function SomeMutationComponent() {
......
console.log("remove console test at top level");
console.log('remove console test at top level')
export function shouldRemove() {
console.log("remove console test in function");
console.error("remove console test in function / error");
console.log('remove console test in function')
console.error('remove console test in function / error')
}
export function locallyDefinedConsole() {
let console = {
log: () => { },
};
console.log();
log: () => {},
}
console.log()
}
export function capturedConsole() {
let console = {
log: () => { },
};
log: () => {},
}
function innerFunc() {
console.log();
console.log()
}
}
export function overrideInParam(console) {
console.log("")
console.log('')
}
export function overrideInParamObjectPatPropAssign({ console }) {
console.log("")
console.log('')
}
export function overrideInParamObjectPatPropKeyValue({ c: console }) {
console.log("")
console.log('')
}
export function overrideInParamObjectPatPropKeyValueNested({ c: { console } }) {
console.log("")
console.log('')
}
export function overrideInParamArray([ console ]) {
console.log("")
export function overrideInParamArray([console]) {
console.log('')
}
......@@ -5,32 +5,30 @@ export function shouldRemove() {
}
export function locallyDefinedConsole() {
let console = {
log: ()=>{
}
log: ()=>{}
};
console.log();
}
export function capturedConsole() {
let console = {
log: ()=>{
}
log: ()=>{}
};
function innerFunc() {
console.log();
}
}
export function overrideInParam(console) {
console.log("");
console.log('');
}
export function overrideInParamObjectPatPropAssign({ console }) {
console.log("");
console.log('');
}
export function overrideInParamObjectPatPropKeyValue({ c: console }) {
console.log("");
console.log('');
}
export function overrideInParamObjectPatPropKeyValueNested({ c: { console } }) {
console.log("");
console.log('');
}
export function overrideInParamArray([console]) {
console.log("");
console.log('');
}
let console = {
log: (msg) => {},
};
}
function func1() {
console.log("remove console test in function");
console.log('remove console test in function')
}
console.log("remove console test at top level");
console.log('remove console test at top level')
let console = {
log: (msg)=>{
}
log: (msg)=>{}
};
function func1() {
console.log("remove console test in function");
console.log('remove console test in function');
}
console.log("remove console test at top level");
console.log('remove console test at top level');
// app/send.ts
"use server";
'use server'
export async function myAction(a, b, c) {
console.log('a')
}
......
// app/send.ts
"use server";
'use server'
import 'db'
......@@ -8,4 +8,4 @@ console.log('side effect')
const foo = async () => {
console.log('function body')
}
export { foo }
\ No newline at end of file
export { foo }
import deleteFromDb from 'db'
export function Item({ id1, id2 }) {
async function deleteItem() {
"use server";
await deleteFromDb(id1);
await deleteFromDb(id2);
}
return <Button action={deleteItem}>Delete</Button>;
}
\ No newline at end of file
async function deleteItem() {
'use server'
await deleteFromDb(id1)
await deleteFromDb(id2)
}
return <Button action={deleteItem}>Delete</Button>
}
'use server'
async function foo () {}
export default foo
\ No newline at end of file
async function foo() {}
export default foo
......@@ -3,5 +3,5 @@
const foo = async function () {}
export default foo
const bar = async function() {}
const bar = async function () {}
export { bar }
......@@ -2,4 +2,4 @@
export async function foo() {
async function bar() {}
}
\ No newline at end of file
}
'use server'
export default async (a, b) => { console.log(a, b) }
export default async (a, b) => {
console.log(a, b)
}
import deleteFromDb from 'db'
const v1 = 'v1';
const v1 = 'v1'
export function Item({ id1, id2 }) {
const v2 = id2;
const deleteItem = async () => {
"use server";
await deleteFromDb(id1);
await deleteFromDb(v1);
await deleteFromDb(v2);
}
return <Button action={deleteItem}>Delete</Button>;
const v2 = id2
const deleteItem = async () => {
'use server'
await deleteFromDb(id1)
await deleteFromDb(v1)
await deleteFromDb(v2)
}
return <Button action={deleteItem}>Delete</Button>
}
const f = (x) => {
async function g(y, ...z) {
'use server'
return x + y + z[0]
}
async function g(y, ...z) {
'use server'
return x + y + z[0]
}
}
const g = (x) => {
f = async (y, ...z) => {
'use server'
return x + y + z[0]
}
f = async (y, ...z) => {
'use server'
return x + y + z[0]
}
}
import deleteFromDb from 'db'
const v1 = 'v1';
const v1 = 'v1'
export function Item({ id1, id2 }) {
const v2 = id2;
return <>
<Button action={async () => {
"use server";
await deleteFromDb(id1);
await deleteFromDb(v1);
await deleteFromDb(v2);
}}>Delete</Button>
<Button action={async function () {
"use server";
await deleteFromDb(id1);
await deleteFromDb(v1);
await deleteFromDb(v2);
}}>Delete</Button>
const v2 = id2
return (
<>
<Button
action={async () => {
'use server'
await deleteFromDb(id1)
await deleteFromDb(v1)
await deleteFromDb(v2)
}}
>
Delete
</Button>
<Button
action={async function () {
'use server'
await deleteFromDb(id1)
await deleteFromDb(v1)
await deleteFromDb(v2)
}}
>
Delete
</Button>
</>
)
}
......@@ -4,17 +4,25 @@ export function Item({ id1 , id2 }) {
const v2 = id2;
return <>
<Button action={$$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [
<Button action={$$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [
id1,
v2
], $$ACTION_0}>Delete</Button>
], $$ACTION_0}>
<Button action={$$ACTION_2 = async function() {
Delete
</Button>
<Button action={$$ACTION_2 = async function() {
return $$ACTION_3($$ACTION_2.$$bound);
}, $$ACTION_2.$$typeof = Symbol.for("react.server.reference"), $$ACTION_2.$$id = "56a859f462d35a297c46a1bbd1e6a9058c104ab8", $$ACTION_2.$$bound = [
id1,
v2
], $$ACTION_2}>Delete</Button>
], $$ACTION_2}>
Delete
</Button>
</>;
}
......
export function Item({ value }) {
return <>
<Button action={async (value2) => {
"use server";
return value * value2;
}}>Multiple</Button>
return (
<>
<Button
action={async (value2) => {
'use server'
return value * value2
}}
>
Multiple
</Button>
</>
)
}
/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ export function Item({ value }) {
return <>
<Button action={$$ACTION_0 = async (value2)=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [
<Button action={$$ACTION_0 = async (value2)=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [
value
], $$ACTION_0}>Multiple</Button>
], $$ACTION_0}>
Multiple
</Button>
</>;
}
......
async function myAction(a, b, c) {
"use server";
'use server'
console.log('a')
}
export default function Page() {
return <Button action={myAction}>Delete</Button>;
}
\ No newline at end of file
return <Button action={myAction}>Delete</Button>
}
......@@ -2,18 +2,24 @@ import { validator, another } from 'auth'
const x = 1
export default function Page () {
export default function Page() {
const y = 1
return <Foo action={validator(async function (z) {
'use server'
return x + y + z
})} />
return (
<Foo
action={validator(async function (z) {
'use server'
return x + y + z
})}
/>
)
}
validator(async () => {
'use server'
})
another(validator(async () => {
'use server'
}))
another(
validator(async () => {
'use server'
})
)
// app/send.ts
"use server";
'use server'
export async function myAction(a, b, c) {
console.log('a')
}
\ No newline at end of file
}
"use server";
'use server'
export async function a() {}
export async function b() {}
export async function c() {}
......@@ -7,6 +7,6 @@ function d() {}
function Foo() {
async function e() {
"use server"
'use server'
}
}
import deleteFromDb from 'db'
const v1 = 'v1';
const v1 = 'v1'
export function Item({ id1, id2 }) {
const v2 = id2;
async function deleteItem() {
"use server";
await deleteFromDb(id1);
await deleteFromDb(v1);
await deleteFromDb(v2);
}
return <Button action={deleteItem}>Delete</Button>;
}
\ No newline at end of file
const v2 = id2
async function deleteItem() {
'use server'
await deleteFromDb(id1)
await deleteFromDb(v1)
await deleteFromDb(v2)
}
return <Button action={deleteItem}>Delete</Button>
}
......@@ -4,61 +4,73 @@ const f3 = 1
var f4
let f5
const [f6, [f7, ...f8], {f9}, { f10, f11: [f12], f13: f14, f15: { f16 }, ...f17 }, ...f18] = []
const [
f6,
[f7, ...f8],
{ f9 },
{
f10,
f11: [f12],
f13: f14,
f15: { f16 },
...f17
},
...f18
] = []
if (true) {
const g19 = 1;
const g19 = 1
}
function x() {
const f2 = 1;
const g20 = 1;
const f2 = 1
const g20 = 1
}
export function y(p, [p1, { p2 }], ...p3) {
const f2 = 1
const f11 = 1
const f19 = 1
const f2 = 1
const f11 = 1
const f19 = 1
if (true) {
const f8 = 1
}
async function action() {
"use server";
if (true) {
const f8 = 1
}
const f17 = 1
async function action() {
'use server'
if (true) {
const f18 = 1
const f19 = 1
}
const f17 = 1
console.log(
f,
f1,
f2,
f3,
f4,
f5,
f6,
f7,
f8,
f2(f9),
f12,
f11,
f16.x,
f17,
f18,
p,
p1,
p2,
p3,
g19,
g20,
globalThis
)
if (true) {
const f18 = 1
const f19 = 1
}
return <Button action={action}>Delete</Button>
console.log(
f,
f1,
f2,
f3,
f4,
f5,
f6,
f7,
f8,
f2(f9),
f12,
f11,
f16.x,
f17,
f18,
p,
p1,
p2,
p3,
g19,
g20,
globalThis
)
}
return <Button action={action}>Delete</Button>
}
import deleteFromDb from 'db'
export function Item(product,foo ,bar) {
async function deleteItem() {
"use server";
await deleteFromDb(product.id,product?.foo,product.bar.baz,product[foo, bar]);
}
return <Button action={deleteItem}>Delete</Button>;
}
\ No newline at end of file
export function Item(product, foo, bar) {
async function deleteItem() {
'use server'
await deleteFromDb(
product.id,
product?.foo,
product.bar.baz,
product[(foo, bar)]
)
}
return <Button action={deleteItem}>Delete</Button>
}
async function myAction(a, b, c) {
// comment
"use strict";
"use server";
'use strict'
'use server'
console.log('a')
}
export default function Page() {
return <Button action={myAction}>Delete</Button>;
}
\ No newline at end of file
return <Button action={myAction}>Delete</Button>
}
/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ async function myAction(a, b, c) {
// comment
"use strict";
'use strict';
console.log('a');
}
myAction.$$typeof = Symbol.for("react.server.reference");
......@@ -10,4 +10,4 @@ myAction.$$with_bound = false;
export const $$ACTION_0 = myAction;
export default function Page() {
return <Button action={myAction}>Delete</Button>;
}
\ No newline at end of file
}
// app/send.ts
"use server";
'use server'
async function foo () {}
async function foo() {}
export { foo }
async function bar() {}
......
let shouldBeRemoved = 'should be removed'
export function removeFunction() {
console.log(shouldBeRemoved);
console.log(shouldBeRemoved)
}
let shouldBeKept = 'should be kept'
export default function shouldBeKept() {
console.log(shouldBeKept)
}
\ No newline at end of file
}
......@@ -5,12 +5,13 @@ export async function keep() {
let shouldBeRemoved = 'should be removed'
export function removeFunction() {
console.log(shouldBeRemoved);
console.log(shouldBeRemoved)
}
export let removeVarDeclaration = 'should be removed'
export let removeVarDeclarationUndefined // should also be removed
export let multipleDecl = 'should be removed', keep1 = 'should be kept'
export let multipleDecl = 'should be removed',
keep1 = 'should be kept'
export let keep2 = 'should be kept'
export class RemoveClass {
......@@ -23,13 +24,13 @@ let x = 'x'
let y = 'y'
// This should be removed
export {x, y as z}
export { x, y as z }
let keep3 = 'should be kept'
let asKeep = 'should be kept'
let removeNamed = 'should be removed'
export {keep3, asKeep as keep4, removeNamed}
export { keep3, asKeep as keep4, removeNamed }
export default function removeDefault() {
console.log('should be removed')
......
export async function getServerSideProps({ query }) {
return { props: { prop: query.prop } };
return { props: { prop: query.prop } }
}
export default function GspPage({ prop }) {
return <div id="prop">{prop}</div>;
}
\ No newline at end of file
return <div id="prop">{prop}</div>
}
export default function Home({}) {
return (
<div>
<p>Hello World</p>
</div>
)
return (
<div>
<p>Hello World</p>
</div>
)
}
export async function getStaticProps() {
await import('_http_common').then((http) => console.log(http))
return {
props: {},
}
}
\ No newline at end of file
await import('_http_common').then((http) => console.log(http))
return {
props: {},
}
}
export const revalidateInSeconds = 5 * 60;
export const revalidateInSeconds = 5 * 60
export const getStaticProps = async () => {
return {
props: {},
revalidate: revalidateInSeconds,
};
};
}
}
export default function Home({}) {
return (
<div>
<p>Hello World</p>
</div>
<div>
<p>Hello World</p>
</div>
)
}
\ No newline at end of file
}
export default function Home() {
return <h1>Hello World!</h1>
}
\ No newline at end of file
return <h1>Hello World!</h1>
}
import { useState, useEffect } from 'react'
import { Root, Children, JSXMemberExpression, AttributeValue, AttributeJSX, ValueInRender, ValueInEffect, UnusedInRender } from '../'
import {
Root,
Children,
JSXMemberExpression,
AttributeValue,
AttributeJSX,
ValueInRender,
ValueInEffect,
UnusedInRender,
} from '../'
export default function Test() {
const [x, setX] = useState(ValueInRender.value)
......@@ -33,6 +42,6 @@ export async function getStaticProps() {
// this import reference should be removed
UnusedInRender.value,
],
}
},
}
}
import mixed from 'esm';
import mixed from 'esm'
console.log(mixed.foo)
console.log(mixed.foo);
module.exports = mixed;
\ No newline at end of file
module.exports = mixed
export default 1
Object.defineProperty(exports, "__esModule", { value: true });
Object.defineProperty(exports, '__esModule', { value: true })
export default 1
console.log("__esModule")
console.log('__esModule')
Object.defineProperty({}, '__esModule', { value: true })
Object.defineProperty()
import css from 'styled-jsx/css';
import css from 'styled-jsx/css'
export default css`
@media (max-width: 870px) {
......@@ -7,4 +7,4 @@ export default css`
display: none;
}
}
`;
\ No newline at end of file
`
import fs from 'fs'
import other from 'other'
......@@ -15,7 +13,6 @@ export async function getStaticProps() {
class Foo {}
export default function Home() {
return <div />
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment