Removes isWhitespace calls and is-whitespace
imports and replaces them with trim()
calls.
is-whitespace
is a small utility that checks if a string contains only whitespace characters.
It's not a very performant way to check for whitespace, especially when used in a loop.
Before
//this could be any shape of import statement for is-whitespaceconst isWhitespace = require('is-whitespace');let str = ' ';let str2 = 'Hello';console.log(isWhitespace(str1)); // trueconsole.log(isWhitespace(str2)); // false
After
//remove the import statement related to is-whitespace. and replace isWhitespace with its equivalent implementation as shown below.let str = ' ';let str2 = 'Hello';console.log(str1.trim() === ''); // trueconsole.log(str2.trim() === ''); // false
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community