useTrimStartEnd
Diagnostic Category: lint/nursery/useTrimStartEnd
Since: v1.9.0
Sources:
- Same as: 
unicorn/prefer-string-trim-start-end 
Description
Section titled DescriptionEnforce the use of String.trimStart() and String.trimEnd() over String.trimLeft() and String.trimRight().
While String.trimLeft() and String.trimRight() are aliases for String.trimStart() and String.trimEnd(),
only using the latter pair ensures consistency and is preferable for their direction-independent wording.
Note that String.trimStart() and String.trimEnd() methods do not take any parameters. Any arguments passed to these methods will be ignored.
See the MDN documentation for more details:
Examples
Section titled ExamplesInvalid
Section titled Invalidconst foo = bar.trimLeft();code-block.js:1:17 lint/nursery/useTrimStartEnd  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ⚠ Use trimStart instead of trimLeft.
  
  > 1 │ const foo = bar.trimLeft();
      │                 ^^^^^^^^
    2 │ 
  
  ℹ trimLeft is an alias for trimStart.
  
  ℹ Safe fix: Replace trimLeft with trimStart.
  
    1   │ - const·foo·=·bar.trimLeft();
      1 │ + const·foo·=·bar.trimStart();
    2 2 │   
  
const foo = bar.trimRight();code-block.js:1:17 lint/nursery/useTrimStartEnd  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ⚠ Use trimEnd instead of trimRight.
  
  > 1 │ const foo = bar.trimRight();
      │                 ^^^^^^^^^
    2 │ 
  
  ℹ trimRight is an alias for trimEnd.
  
  ℹ Safe fix: Replace trimRight with trimEnd.
  
    1   │ - const·foo·=·bar.trimRight();
      1 │ + const·foo·=·bar.trimEnd();
    2 2 │   
  
Valid
Section titled Validconst foo = bar.trimStart();const foo = bar.trimEnd();How to configure
Section titled How to configure{  "linter": {    "rules": {      "nursery": {        "useTrimStartEnd": "error"      }    }  }}