@E18e/Es Set Tostringtag

1.0.5Last update Aug 9, 2024
by@e18e

es-set-tostringtag Codemod

Introduction

This codemod removes the dependency on the es-set-tostringtag package and replaces its usage with the native Object.defineProperty and Symbol.toStringTag. By doing so, it eliminates unnecessary dependencies and leverages built-in ES features, enhancing performance and reducing bundle size.

Before

import setToStringTag from 'es-set-tostringtag';
const myObject = {};
setToStringTag(myObject, 'MyObject', { force: true });

After

const myObject = {};
Object.defineProperty(myObject, Symbol.toStringTag, {
configurable: true,
enumerable: false,
value: 'MyObject',
writable: false,
});

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now