Skip to content

Latest commit

 

History

History
69 lines (44 loc) · 1.57 KB

no-string-prototype-extensions.md

File metadata and controls

69 lines (44 loc) · 1.57 KB

ember/no-string-prototype-extensions

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

References

Related Rules