Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

unicorn/prefer-string-trim-start-end

Require trimStart() and trimEnd() instead of trimLeft() and trimRight()

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

Reported:

const command = input.trimLeft();
const line = text.trimRight();

Not reported:

const command = input.trimStart();
const line = text.trimEnd();