Next.js Comment Deletable Files

verified codemod icon

This automation is recommended when migrating from the /pages to the /app directory.

Next.js
jscodeshift
Estimated time saving
5 minutes/occurrence
Change mode
Assistive
Applicability criteria

Next.js version higher or equal to 13.4

Made by
Codemod.com
Codemod.com

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod next/13/comment-deletable-files
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Description

This codemod is recommended when migrating from the /pages to the /app directory.

It adds a comment to files that should be deleted and migrated to different files during the migration process.

Namely, such are the following files:

  • _document.*,
  • _app.*,
  • _error.*.

Example

Before

import 'highlight.js/styles/default.css';
import 'swagger-ui-react/swagger-ui.css';

import '../styles/globals.css';

function MyApp({ Component, pageProps }) {
	return <Component {...pageProps} />;
}

export default MyApp;

After

/*This file should be deleted. Please migrate its contents to appropriate files*/
import 'highlight.js/styles/default.css';
import 'swagger-ui-react/swagger-ui.css';

import '../styles/globals.css';

function MyApp({ Component, pageProps }) {
	return <Component {...pageProps} />;
}

export default MyApp;