Skip to content

Dont-Use-Wrappers-For-Builtins

Documentation Index

Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt

Use this file to discover all available pages before exploring further.

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

Section titled “Sourcery rule id: dont-use-wrappers-for-builtins”

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

const items = new Boolean(true);
const items = true;

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