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.
Examples
Examples of incorrect code for this rule:
javascript
str.trimLeft();
str.trimRight();Examples of correct code for this rule:
javascript
str.trimStart();
str.trimEnd();How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny unicorn/prefer-string-trim-start-endjson
{
"rules": {
"unicorn/prefer-string-trim-start-end": "error"
}
}