Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
ProprietaryReplaces Object.prototype.hasOwnProperty.call(obj, key), Object.hasOwnProperty.call(obj, key), and ({}).hasOwnProperty.call(obj, key) (empty object literal receiver) with the equivalent ES2022 Object.hasOwn(obj, key), leaving the argument list untouched. No change is made when comments exist inside the callee or when the global Object is shadowed. The fixed code requires an ES2022+ runtime. Replicates the autofix of the ESLint rule prefer-object-has-own under its default options.
org. openrewrite. javascript. cleanup. PreferObjectHasOwnmod run . --recipe= org. openrewrite. javascript. cleanup. PreferObjectHasOwnInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.