unicorn/prefer-string-trim-start-end Style
What it does
String#trimLeft()
and String#trimRight()
are aliases of String#trimStart()
and String#trimEnd()
. This is to ensure consistency and use direction-independent wording.
Why is this bad?
The trimLeft
and trimRight
names are confusing and inconsistent with the rest of the language.
Example
Examples of incorrect code for this rule:
javascript
str.trimLeft();
str.trimRight();
Examples of correct code for this rule:
javascript
str.trimStart();
str.trimEnd();