public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Matthias Heiserer <m.heiserer@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH manager 2/2] GUI: efi disk: cleanup - var to const
Date: Fri, 20 Jan 2023 12:16:39 +0100	[thread overview]
Message-ID: <a1b5707e-8260-d23e-38b2-5cc4c752aac1@proxmox.com> (raw)
In-Reply-To: <6b624905-ef72-1ddd-b940-f34d16523f3f@proxmox.com>

On 18.01.2023 15:03, Thomas Lamprecht wrote:
> Am 17/01/2023 um 13:17 schrieb Matthias Heiserer:
>> Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
>> ---
>>   www/manager6/qemu/HDEfi.js | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/www/manager6/qemu/HDEfi.js b/www/manager6/qemu/HDEfi.js
>> index ef3092a6..f6b7fc26 100644
>> --- a/www/manager6/qemu/HDEfi.js
>> +++ b/www/manager6/qemu/HDEfi.js
>> @@ -9,13 +9,13 @@ Ext.define('PVE.qemu.EFIDiskInputPanel', {
>>       vmconfig: {}, // used to select usused disks
>>   
>>       onGetValues: function(values) {
>> -	var me = this;
>> +	const me = this;
>>   
>>   	if (me.disabled) {
>>   	    return {};
>>   	}
>>   
>> -	var confid = 'efidisk0';
>> +	const confid = 'efidisk0';
>>   
>>   	if (values.hdimage) {
>>   	    me.drive.file = values.hdimage;
>> @@ -37,7 +37,7 @@ Ext.define('PVE.qemu.EFIDiskInputPanel', {
>>       },
>>   
>>       setNodename: function(nodename) {
>> -	var me = this;
>> +	const me = this;
>>   	me.down('#hdstorage').setNodename(nodename);
>>   	me.down('#hdimage').setStorage(undefined, nodename);
>>       },
>> @@ -50,7 +50,7 @@ Ext.define('PVE.qemu.EFIDiskInputPanel', {
>>       },
>>   
>>       initComponent: function() {
>> -	var me = this;
>> +	const me = this;
>>   
>>   	me.drive = {};
>>   
>> @@ -96,9 +96,9 @@ Ext.define('PVE.qemu.EFIDiskEdit', {
>>   
>>       width: 450,
>>       initComponent: function() {
>> -	var me = this;
>> +	const me = this;
>>   
>> -	var nodename = me.pveSelNode.data.node;
>> +	const nodename = me.pveSelNode.data.node;
>>   	if (!nodename) {
>>   	    throw "no node name specified";
>>   	}
> 
> I'm not that huge fan of applying JavaScript's const broadly to non-scalar values,
> as it's only a shallow constant and immutable; so no effect on array/object member.

I quite like const, especially with `const me = this`, because it tells 
me that I don't have to worry about the variable being reassigned.
But as long as there's a guideline on whether to use it, I'm happy :)
> 
> I mean we can start to use it more for scalar variables, as eslint catches overriding
> the const variable itself directly - but it probably makes sense to add some basic
> rules w.r.t. when/how it should be used over `let` in our JS style guide, something
> along the line of:
> 
> "Using `let` is fine in most context, and while `const` can have some advantages and
> possibly even avoid some specific bugs, it should only be applied to scalar values but
> not objects or arrays."
> 
> What do you think (apart from grammar/typos ;-))?

Looks good




  reply	other threads:[~2023-01-20 11:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 12:17 [pve-devel] [PATCH manager 1/2] GUI: efi disk: use correct version with aarch64 Matthias Heiserer
2023-01-17 12:17 ` [pve-devel] [PATCH manager 2/2] GUI: efi disk: cleanup - var to const Matthias Heiserer
2023-01-18 14:03   ` Thomas Lamprecht
2023-01-20 11:16     ` Matthias Heiserer [this message]
2023-01-20 13:59       ` Thomas Lamprecht
2023-01-18 14:07 ` [pve-devel] [PATCH manager 1/2] GUI: efi disk: use correct version with aarch64 Thomas Lamprecht
2023-01-20 12:56   ` Matthias Heiserer
2023-01-20 13:17     ` Thomas Lamprecht
2023-01-20 14:18       ` Matthias Heiserer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1b5707e-8260-d23e-38b2-5cc4c752aac1@proxmox.com \
    --to=m.heiserer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal