diff --git a/.prettierignore b/.prettierignore index 7095e7b34d..4edd8069bb 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,7 +7,4 @@ packages/react-refresh-utils/**/*.js packages/react-refresh-utils/**/*.d.ts packages/react-dev-overlay/lib/** **/__tmp__/** -# prettier can't handle the `import type {} from ''` syntax yet -test/integration/typescript-only-remove-type-imports/**/*.ts -test/integration/typescript-only-remove-type-imports/**/*.tsx lerna.json diff --git a/.prettierignore_staged b/.prettierignore_staged index d41a43ad66..3e87a0d626 100644 --- a/.prettierignore_staged +++ b/.prettierignore_staged @@ -2,7 +2,4 @@ **/_next/** **/dist/** packages/next/compiled/**/* -# prettier can't handle the `import type {} from ''` syntax yet -test/integration/typescript-only-remove-type-imports/**/*.ts -test/integration/typescript-only-remove-type-imports/**/*.tsx lerna.json diff --git a/bench/recursive-copy/run.js b/bench/recursive-copy/run.js index adff8be65a..c4bad36c88 100644 --- a/bench/recursive-copy/run.js +++ b/bench/recursive-copy/run.js @@ -20,7 +20,7 @@ const createSrcFolder = async () => { join(srcDir, `folder${i % 5}`, `folder${i + (1 % 5)}`, `file${i}`) ) - await Promise.all(files.map(file => fs.outputFile(file, 'hello'))) + await Promise.all(files.map((file) => fs.outputFile(file, 'hello'))) } async function run(fn) { diff --git a/docs/advanced-features/custom-document.md b/docs/advanced-features/custom-document.md index f748a0eb8c..f9e60d9797 100644 --- a/docs/advanced-features/custom-document.md +++ b/docs/advanced-features/custom-document.md @@ -71,9 +71,9 @@ class MyDocument extends Document { ctx.renderPage = () => originalRenderPage({ // useful for wrapping the whole react tree - enhanceApp: App => App, + enhanceApp: (App) => App, // useful for wrapping in a per-page basis - enhanceComponent: Component => Component, + enhanceComponent: (Component) => Component, }) // Run the parent `getInitialProps`, it now includes the custom `renderPage` diff --git a/docs/advanced-features/custom-server.md b/docs/advanced-features/custom-server.md index e1c8f91661..a9a5c89a5a 100644 --- a/docs/advanced-features/custom-server.md +++ b/docs/advanced-features/custom-server.md @@ -45,7 +45,7 @@ app.prepare().then(() => { } else { handle(req, res, parsedUrl) } - }).listen(3000, err => { + }).listen(3000, (err) => { if (err) throw err console.log('> Ready on http://localhost:3000') }) diff --git a/docs/advanced-features/dynamic-import.md b/docs/advanced-features/dynamic-import.md index 62a9f0241e..bfab9f15ea 100644 --- a/docs/advanced-features/dynamic-import.md +++ b/docs/advanced-features/dynamic-import.md @@ -55,7 +55,7 @@ To dynamically import the `Hello` component, you can return it from the [Promise import dynamic from 'next/dynamic' const DynamicComponent = dynamic(() => - import('../components/hello').then(mod => mod.Hello) + import('../components/hello').then((mod) => mod.Hello) ) function Home() { diff --git a/docs/api-reference/data-fetching/getInitialProps.md b/docs/api-reference/data-fetching/getInitialProps.md index 7965c7d0a6..651a8c5cdc 100644 --- a/docs/api-reference/data-fetching/getInitialProps.md +++ b/docs/api-reference/data-fetching/getInitialProps.md @@ -29,7 +29,7 @@ function Page({ stars }) { return
Next stars: {stars}
} -Page.getInitialProps = async ctx => { +Page.getInitialProps = async (ctx) => { const res = await fetch('https://api.github.com/repos/zeit/next.js') const json = await res.json() return { stars: json.stargazers_count } diff --git a/docs/api-reference/next.config.js/custom-webpack-config.md b/docs/api-reference/next.config.js/custom-webpack-config.md index 5e0f74a565..b4d0f2f393 100644 --- a/docs/api-reference/next.config.js/custom-webpack-config.md +++ b/docs/api-reference/next.config.js/custom-webpack-config.md @@ -24,7 +24,7 @@ module.exports = { config.plugins.push(new webpack.IgnorePlugin(/\/__tests__\//)) return config }, - webpackDevMiddleware: config => { + webpackDevMiddleware: (config) => { // Perform customizations to webpack dev middleware config // Important: return the modified config return config diff --git a/docs/api-reference/next.config.js/exportPathMap.md b/docs/api-reference/next.config.js/exportPathMap.md index 449f00e038..b8f560c786 100644 --- a/docs/api-reference/next.config.js/exportPathMap.md +++ b/docs/api-reference/next.config.js/exportPathMap.md @@ -23,7 +23,7 @@ Open `next.config.js` and add the following `exportPathMap` config: ```js module.exports = { - exportPathMap: async function( + exportPathMap: async function ( defaultPathMap, { dev, dir, outDir, distDir, buildId } ) { diff --git a/docs/api-reference/next/link.md b/docs/api-reference/next/link.md index e8c6647c18..1f13e4cf57 100644 --- a/docs/api-reference/next/link.md +++ b/docs/api-reference/next/link.md @@ -67,7 +67,7 @@ A `Link` to a dynamic route is a combination of the `href` and `as` props. A lin ```jsx const pids = ['id1', 'id2', 'id3'] { - pids.map(pid => ( + pids.map((pid) => ( Post {pid} diff --git a/docs/api-reference/next/router.md b/docs/api-reference/next/router.md index 5f6d63fa25..7648cd35be 100644 --- a/docs/api-reference/next/router.md +++ b/docs/api-reference/next/router.md @@ -20,7 +20,7 @@ function ActiveLink({ children, href }) { color: router.pathname === href ? 'red' : 'black', } - const handleClick = e => { + const handleClick = (e) => { e.preventDefault() router.push(href) } @@ -178,7 +178,7 @@ import { useCallback, useEffect } from 'react' import Router from 'next/router' export default function Login() { - const handleSubmit = useCallback(e => { + const handleSubmit = useCallback((e) => { e.preventDefault() fetch('/api/login', { @@ -187,7 +187,7 @@ export default function Login() { body: JSON.stringify({ /* Form data */ }), - }).then(res => { + }).then((res) => { // Do a fast client-side transition to the already prefetched dashboard page if (res.ok) Router.push('/dashboard') }) @@ -283,7 +283,7 @@ For example, to listen to the router event `routeChangeStart`, do the following: ```jsx import Router from 'next/router' -const handleRouteChange = url => { +const handleRouteChange = (url) => { console.log('App is changing to: ', url) } @@ -316,7 +316,7 @@ Router events should be registered when a component mounts ([useEffect](https:// import Router from 'next/router' useEffect(() => { - const handleRouteChange = url => { + const handleRouteChange = (url) => { console.log('App is changing to: ', url) } diff --git a/docs/api-routes/api-middlewares.md b/docs/api-routes/api-middlewares.md index 0c172c6eab..3c7cfe92f1 100644 --- a/docs/api-routes/api-middlewares.md +++ b/docs/api-routes/api-middlewares.md @@ -94,7 +94,7 @@ const cors = Cors({ // And to throw an error when an error happens in a middleware function runMiddleware(req, res, fn) { return new Promise((resolve, reject) => { - fn(req, res, result => { + fn(req, res, (result) => { if (result instanceof Error) { return reject(result) } diff --git a/docs/basic-features/data-fetching.md b/docs/basic-features/data-fetching.md index cfbbe07fc8..f38f802eca 100644 --- a/docs/basic-features/data-fetching.md +++ b/docs/basic-features/data-fetching.md @@ -56,7 +56,7 @@ Here’s an example which uses `getStaticProps` to fetch a list of blog posts fr function Blog({ posts }) { return ( @@ -100,7 +100,7 @@ For TypeScript, you can use the `GetStaticProps` type from `next`: ```ts import { GetStaticProps } from 'next' -export const getStaticProps: GetStaticProps = async context => { +export const getStaticProps: GetStaticProps = async (context) => { // ... } ``` @@ -123,7 +123,7 @@ import path from 'path' function Blog({ posts }) { return (