Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 1.29 KB

prefer-string-trim-start-end.md

File metadata and controls

24 lines (16 loc) · 1.29 KB

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

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

Pass

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