Use shorthand promise resolution method
3import { revalidatePath } from "next/cache";
4
5export async function revalidatePathAction(path: string) {
6 return new Promise((resolve) => resolve(revalidatePath(path, "page")));7}
Description
If the executor argument to a promise constructor only calls the reject
or resolve
and exits, then the code can refactored to use Promise#reject
or Promise#resolve
instead.
Bad Practice
new Promise((resolve, reject) => {
resolve(getItem())
})
new Promise(function (resolve, reject) {
reject("oops")
})
Recommended
Promise.resolve(getItem())
Promise.reject("oops")