unicorn/prefer-string-trim-start-end
Require trimStart() and trimEnd() instead of trimLeft() and trimRight()
fixable
trimLeft() and trimRight() are old aliases for trimStart() and trimEnd(). The names are also wrong for text written from right to left, where the start of the string is on the right.
--fix renames the method.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/prefer-string-trim-start-end" = "error" # or "warn"Examples#
example.js2 problems
const command = input.trimLeftPrefer trimStart over trimLeft();
const line = text.trimRightPrefer trimEnd over trimRight();example.jsNo problems
const command = input.trimStart();
const line = text.trimEnd();