Androz2091 / discord-giveaways

🎉 Complete framework to facilitate the creation of giveaways using discord.js
https://discord-giveaways.js.org
MIT License
335 stars 127 forks source link

unused var #348

Closed Dragonizedpizza closed 3 years ago

Dragonizedpizza commented 3 years ago

https://github.com/Androz2091/discord-giveaways/blob/master/src/Manager.js#L387 Why is the messageID param in there, even though its not used?

Nico105 commented 3 years ago

For key-value DBs, like enmap. Ik tchnically we could also get it from giveawayData, but that shouldn't matter much.

Dragonizedpizza commented 3 years ago

For key-value DBs, like enmap. Ik tchnically we could also get it from giveawayData, but that shouldn't matter much.

eslint throws an error for unused var

Nico105 commented 3 years ago

only if you view it through node_modules and have eslint enabled for that path (I think) for package development there is 'no-unused-vars': 0 in the config file

Dragonizedpizza commented 3 years ago

only if you view it through node_modules and have eslint enabled for that path (I think) for package development there is 'no-unused-vars': 0 in the config file

I meant my eslint, when I'm extending the class

Nico105 commented 3 years ago

ahh yeah... I guess since we're breaking the db examples in v13 anyway, i guess i will remove it and use giveawayData.messageId

Nico105 commented 3 years ago

Or would it be to inconvinient to add a eslint disable comment? Since for sql dbs the key is, think, always/mostly required no? Im unsure

Androz2091 commented 3 years ago

You can simply remove the param when extending the class right? It won't throw an error.

Nico105 commented 3 years ago

You can simply remove the param when extending the class right? It won't throw an error.

function(messageId, giveawayData) Something has to be there right, so hdym "remove"?

Dragonizedpizza commented 3 years ago

You can simply remove the param when extending the class right? It won't throw an error.

discord-giveaways will still internally pass the messageId param, and the method would consider it as giveawayData

Androz2091 commented 3 years ago

This code should be valid with eslint:

saveGiveaway (messageID, data) {
console.log(data);
// as the second argument was used, no error is thrown for the messageID param 
}

Am I wrong?

Dragonizedpizza commented 3 years ago

yes, but the lib doesn't require the messageID param at all

Dragonizedpizza commented 3 years ago

also, the error was about messageID, not data, so console.log(messageID)

Androz2091 commented 3 years ago

Nop, because if you use the second param (data), eslint will see that you have no other way than declaring messageID even if you don't use it

Nico105 commented 3 years ago

yeah I checked it myself right now, no error when 1st is not used but 2nd is.

@Dragonizedpizza did you add args: all in your config? since only then would it error for me

Dragonizedpizza commented 3 years ago

nope

Nico105 commented 3 years ago

nope

weird, are you sure its not from some other rule maybe that you have customized?

Nico105 commented 3 years ago

I will close this for now since this seems to be coming from somewhere else/the devs own settings.

Dragonizedpizza commented 3 years ago

I will close this for now since this seems to be coming from somewhere else/the devs own settings.

but the messageId param is literally pointless

Nico105 commented 3 years ago

I will close this for now since this seems to be coming from somewhere else/the devs own settings.

but the messageId param is literally pointless

it's more readable than referencing from the object i guess. => more practical in a way. As said key-value, and most of the db examples use it.

Ik it is a little out of place in the default (json) functions, but I guess Androz thought into the future or smth. EDIT: yeah exactly that, the commit is named so: https://github.com/Androz2091/discord-giveaways/commit/f1d1878df74c9376057ff729733d0b6b6ee55d7b = key-value was intended