macovidvaccines.com icon indicating copy to clipboard operation
macovidvaccines.com copied to clipboard

Avoid foo.hasOwnProperty() per eslint:no-prototype-builtins

Open johnhawkinson opened this issue 3 years ago • 2 comments

Instead use the more "fun" and seemingly excessively verbose: Object.prototype.hasOwnProperty.call(foo, "prop")

See https://eslint.org/docs/rules/no-prototype-builtins but basically not all objects need have the methods from Object.prototype in EMCAScript 5.1, and even if they do they can be subtly/maliciously overridden.

This tripped me up because I had eslint set to a stricter mode than we do, with "eslint:recommended" in my extends section of .eslintrc.js.

On the other hand, feel free to tell me to "shove it," and that this is needlessly strict and excessively verbose, and we don't need to worry about it

johnhawkinson avatar Apr 02 '21 16:04 johnhawkinson

Or, can this just be reflected in the "eslintConfig" in package.json?

harcod avatar Apr 02 '21 20:04 harcod

I don't have a problem with stricter checking. Maybe you should add a .eslintrc.js to the project so that we are all using the same standard.

I tend to agree. Perhaps update the PR with the .eslintrc file so everyone follows the same rules. In the same PR include the fixes required to comply with the new rules (maybe this is the only one?)

iann avatar Apr 10 '21 12:04 iann