Skip to content

Prefer String#trimStart() / String#trimEnd() over String#trimLeft() / String#trimRight() ​

💼 This rule is enabled in the ✅ recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

String#trimLeft() and String#trimRight() are aliases of String#trimStart() and String#trimEnd(). This is to ensure consistency and use direction-independent wording.

Fail ​

js
const foo = bar.trimLeft();
const foo = bar.trimRight();

Pass ​

js
const foo = bar.trimStart();
const foo = bar.trimEnd();

Released under the Apache License 2.0.