You need to sign in to do that
Don't have an account?
Arut Jothi
Usage of let keyword, JS fat arrow & JS functional constructs in Lightning component
Does Salesforce security review reject a package/ lightning component if the following are used in lightning component code?
(a) let keyword, instead of var
(b) JS fat arrow (=>) within the controller/ helper functions (this is esp. useful for cleaner coding when used with .then or .catch contructs)
(c) JS functional programming contructs such as array.map(), array.forEach(), array.filter() etc.
I've used this in my component and it works fine, but PMD check throws an error. While I was able to confirm that PMD check throws an error because it might not have JS rules defined to specifically check for 'let' keyword and it views them defined as without 'var'. Eventually, it considers them as global variable while they aren't (they are local scoped and initialized with 'let'). Salesforce documentation doesn't specifically indicate whether these can be used or not , esp. with regards to security review of the package.
I did see Salesforce using let keywords in the Salesforce Inspector code which tells me that they might allow but not sure.
Does anyone know if this could cause security review failure??
(a) let keyword, instead of var
(b) JS fat arrow (=>) within the controller/ helper functions (this is esp. useful for cleaner coding when used with .then or .catch contructs)
(c) JS functional programming contructs such as array.map(), array.forEach(), array.filter() etc.
I've used this in my component and it works fine, but PMD check throws an error. While I was able to confirm that PMD check throws an error because it might not have JS rules defined to specifically check for 'let' keyword and it views them defined as without 'var'. Eventually, it considers them as global variable while they aren't (they are local scoped and initialized with 'let'). Salesforce documentation doesn't specifically indicate whether these can be used or not , esp. with regards to security review of the package.
I did see Salesforce using let keywords in the Salesforce Inspector code which tells me that they might allow but not sure.
Does anyone know if this could cause security review failure??
No, this will not impact security review. I have already contributed code that uses such syntax.
Most of what you mentioned (let, fat arrow functions...) is supported by all browsers including IE11 because this is part of the ES6 standard. However, there are a few things are not supported by IE11 around array functions. Array.find() being the most annoying one.
Note that you will get warnings if you try to lint your code with the Salesforce CLI lint plugin but that is only because the plugin is set to check on ES5 (you cannot change this setting for now).
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
All Answers
No, this will not impact security review. I have already contributed code that uses such syntax.
Most of what you mentioned (let, fat arrow functions...) is supported by all browsers including IE11 because this is part of the ES6 standard. However, there are a few things are not supported by IE11 around array functions. Array.find() being the most annoying one.
Note that you will get warnings if you try to lint your code with the Salesforce CLI lint plugin but that is only because the plugin is set to check on ES5 (you cannot change this setting for now).
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra