prisma / codemods

A Collection of Codemods for Prisma 2
https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/codemods
34 stars 3 forks source link

issue when we have Prisma name used in our files #10

Open AhmedElywa opened 3 years ago

AhmedElywa commented 3 years ago

issue when we have Prisma name used in our files

Before the codemod

import { PrismaClient } from '@prisma/client'
import { PrismaDelete, onDeleteArgs } from '@paljs/plugins'

class Prisma extends PrismaClient {
  constructor(options?: PrismaClientOptions) {
    super(options)
  }

  async onDelete(args: onDeleteArgs) {
    const prismaDelete = new PrismaDelete(this)
    await prismaDelete.onDelete(args)
  }
}

const prisma = new Prisma()

After the codemod

import { PrismaClient, Prisma } from '@prisma/client'
import { PrismaDelete, onDeleteArgs } from '@paljs/plugins'

class Prisma extends PrismaClient {
  constructor(options?: Prisma.PrismaClientOptions) {
    super(options)
  }

  async onDelete(args: onDeleteArgs) {
    const prismaDelete = new PrismaDelete(this)
    await prismaDelete.onDelete(args)
  }
}

const prisma = new Prisma()

Expected output

import { PrismaClient, Prisma as PrismaType } from '@prisma/client'
import { PrismaDelete, onDeleteArgs } from '@paljs/plugins'

class Prisma extends PrismaClient {
  constructor(options?: PrismaType.PrismaClientOptions) {
    super(options)
  }

  async onDelete(args: onDeleteArgs) {
    const prismaDelete = new PrismaDelete(this)
    await prismaDelete.onDelete(args)
  }
}

const prisma = new Prisma()
AhmedElywa commented 3 years ago

But look, it's not a big deal developer can do this manually

williamluke4 commented 3 years ago

If I have some time I'll have a look