Skip to content

Latest commit

 

History

History
67 lines (45 loc) · 1.39 KB

no-string-prototype-extensions.md

File metadata and controls

67 lines (45 loc) · 1.39 KB

no-string-prototype-extensions

✅ The "extends": "plugin:ember/recommended" property in a configuration file enables this rule.

Ember by default extends certain native JavaScript objects with additional methods. This can lead to problems in certain situations. One example is relying on these methods in addons, but that addon being used in an app that has the extensions disabled.

Additionally, the prototype extensions for the String object have been deprecated in RFC #236.

Rule Details

This rule will look for method calls that match any of the forbidden String prototype extension methods.

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');

References