This rule raises an issue when trimLeft() or trimRight() methods are used on strings.

Why is this an issue?

The trimLeft() and trimRight() methods are deprecated aliases for trimStart() and trimEnd(). While they still work, they exist only for backward compatibility and may be removed in future JavaScript versions.

The newer method names are preferred because:

Using deprecated methods can make your code appear outdated and may cause issues if these aliases are eventually removed from JavaScript engines.

What is the potential impact?

Using deprecated methods may lead to maintenance issues if the aliases are removed in future JavaScript versions. While the immediate impact is minimal, it can affect code consistency and maintainability.

How to fix?

Replace trimLeft() with trimStart() and trimRight() with trimEnd(). These methods have identical functionality.

Non-compliant code example

const text = '  hello world  ';
const leftTrimmed = text.trimLeft(); // Noncompliant
const rightTrimmed = text.trimRight(); // Noncompliant

Compliant code example

const text = '  hello world  ';
const leftTrimmed = text.trimStart();
const rightTrimmed = text.trimEnd();

Documentation