src/content/docs/linter/rules/use-trim-start-end.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.9.0` - Diagnostic Category: [`lint/style/useTrimStartEnd`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule has a [**safe**](/linter/#safe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`unicorn/prefer-string-trim-start-end`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-trim-start-end.md){
"linter": {
"rules": {
"style": {
"useTrimStartEnd": "error"
}
}
}
}
Enforce 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:
const foo = bar.trimLeft();
const foo = bar.trimRight();
const foo = bar.trimStart();
const foo = bar.trimEnd();