ember/no-string-prototype-extensions
November 8, 2022 ยท View on GitHub
๐ผ This rule is enabled in the โ
recommended config.
By default, Ember extends certain native JavaScript objects with additional methods. This can lead to problems in some situations. One example is relying on these methods in an addon that is used inside an app that has the extensions disabled.
The prototype extensions for the String object were deprecated in RFC #236.
Rule Details
This rule will disallow method calls that match any of the forbidden String prototype extension method names.
Examples
Examples of incorrect code for this rule:
'myString'.dasherize();
someString.capitalize();
'<b>foo</b>'.htmlSafe();
Examples of correct code for this rule:
dasherize('myString');
capitalize(someString);
htmlSafe('<b>foo</b>');
Migration
Replace e.g.:
'myString'.dasherize();
with:
import { dasherize } from '@ember/string';
dasherize('myString');