codemods icon indicating copy to clipboard operation
codemods copied to clipboard

issue when we have Prisma name used in our files

Open AhmedElywa opened this issue 4 years ago • 2 comments

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 avatar Nov 25 '20 13:11 AhmedElywa

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

AhmedElywa avatar Nov 25 '20 13:11 AhmedElywa

If I have some time I'll have a look

williamluke4 avatar Nov 25 '20 13:11 williamluke4