Skip to content

Dont-Use-Wrappers-For-Builtins

Sourcery rule id: dont-use-wrappers-for-builtins

Description

Don't use new syntax with String, Number and Boolean objects

Before

const items = new Boolean(true);

After

const items = true;

Explanation

Although possible, there arenโ€™t any good reasons to use these primitive wrappers as constructors. They tend to confuse other developers more than anything else because they seem like they should act as primitives, but they do not.

If you wish to convert a value to another type, use these without the new syntax.

From ESLint