Skip to content

Conversation

@SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Oct 19, 2025

The PR adds autofix for theno-new-wrappers rule:

// Valid
const text = String(someValue);
const num = Number(someValue);
const object = new MyString();

// Auto Fix
const stringObject = new String("Hello world");
// turns into
const stringObject = String("Hello world");

const numberObject = new Number(0x721);
// turns into
const numberObject = Number(0x721);

const booleanObject = new Boolean(false);
// turns into
const booleanObject = Boolean(false);

// No Auto Fix
const stringObject = new String
const numberObject = new Number
const booleanObject = new Boolean

Note that the autofix does change the behavior of the original code; the right-hand value becomes a primitive value instead of an object wrapper. But in most cases, the auto-fixed code is desired. And if anyone does really need the original behavior, they should not enable this rule in the first place.


I'd appreciate it if you tag my PR w/ hacktoberfest-accepted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant