未验证 提交 f3ffbedd 编写于 作者: R Robert Massaioli 提交者: GitHub

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.
上级 6a927e6b
......@@ -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}",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册