Skip to content

chore(drizzle): remove unused variables #12336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jordisala1991
Copy link

@jordisala1991 jordisala1991 commented May 7, 2025

What?

Remove unused parameters on the migration file.

Why?

Because it is reported by eslint as unused parameters

How?

Removing them by default, if someone needs to use them, they can still add them back.

@jordisala1991 jordisala1991 changed the title chore: Remove unused variables chore: remove unused variables May 7, 2025
@jordisala1991 jordisala1991 changed the title chore: remove unused variables chore(drizzle): remove unused variables May 7, 2025
Comment on lines +16 to 21
export async function up({ db }: MigrateUpArgs): Promise<void> {
${indent(upSQL)}
}

export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
export async function down({ db }: MigrateDownArgs): Promise<void> {
${indent(downSQL)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db is also not used:
export async function up(): Promise<void>
export async function down(): Promise<void>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db is used in the generated migration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's a function generator, I see.
I'm not familiar with this part of the code, so at first glance, it's not obvious to me that what indent returns may contain db but not payload or req. Perhaps it depends on the use case and could be a problem for other people, but not for you?
Unless there's a good reason, I prefer to play it safe and leave it as is. It's not a big deal. Codegen will always depend on the user's eslint configuration, and removing parameters, if there are any, is trivial and takes a second.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this eslint rule is not auto fixable. It must be fixed manually. Are there any case where other variable than db might be used here by default?

If you prefer not to touch it because you are unsure of the edge cases, I am fine with it, but it takes time for each migration you generate (right now I am manually removing them). To me it is a quality of life improvement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any case where other variable than db might be used here by default?

That's the key question.
I agree it would be an improvement if this were the case, but the time it would take to investigate whether it's safe should be longer than removing an unused parameter.
If you want to provide an explanation that doesn't require in-depth analysis, I'd be happy to review it. Otherwise, I'd say we close this PR.
In either case, thanks for your feedback and time!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a deeper look at the code to see if I can be sure only db will be used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants