Update for-in loop to work with eslint:recommended (#99721)

The code in the automatic template will fail this eslint rule: https://eslint.org/docs/rules/no-prototype-builtins. This is just plain annoying.

This change will make the snippet generated code not fail the linter. It will also avoid the subtle bugs that the eslint rule was made to avoid in the first place.
This commit is contained in:
Robert Massaioli 2020-06-10 16:52:58 +10:00 committed by GitHub
parent 6a927e6bb5
commit f3ffbedd41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -151,7 +151,7 @@
"prefix": "forin",
"body": [
"for (const ${1:key} in ${2:object}) {",
"\tif (${2:object}.hasOwnProperty(${1:key})) {",
"\tif (Object.prototype.hasOwnProperty.call(${2:object}, ${1:key})) {",
"\t\tconst ${3:element} = ${2:object}[${1:key}];",
"\t\t$0",
"\t}",