forked from treehouse/mastodon
Replace deprecated String.prototype.substr() (#17949)
* Replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated * Change String.prototype.substring() to String.prototype.slice() .substring() and .slice() work very similary but .slice() is a bit faster and stricter * Add ESLint rule to forbid usage of .substr and .substring .substr() is deprecated and .substring() is very similar to .slice() so better to use .slice() at all times Signed-off-by: Tobias Speicher <rootcommander@gmail.com>rebase/4.0.0rc2
parent
80ded02a4b
commit
0ec695e036
|
@ -79,6 +79,11 @@ module.exports = {
|
||||||
'no-irregular-whitespace': 'error',
|
'no-irregular-whitespace': 'error',
|
||||||
'no-mixed-spaces-and-tabs': 'warn',
|
'no-mixed-spaces-and-tabs': 'warn',
|
||||||
'no-nested-ternary': 'warn',
|
'no-nested-ternary': 'warn',
|
||||||
|
'no-restricted-properties': [
|
||||||
|
'error',
|
||||||
|
{ property: 'substring', message: 'Use .slice instead of .substring.' },
|
||||||
|
{ property: 'substr', message: 'Use .slice instead of .substr.' },
|
||||||
|
],
|
||||||
'no-trailing-spaces': 'warn',
|
'no-trailing-spaces': 'warn',
|
||||||
'no-undef': 'error',
|
'no-undef': 'error',
|
||||||
'no-unreachable': 'error',
|
'no-unreachable': 'error',
|
||||||
|
|
|
@ -124,7 +124,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
|
||||||
for (let id in aPool) {
|
for (let id in aPool) {
|
||||||
let emoji = aPool[id],
|
let emoji = aPool[id],
|
||||||
{ search } = emoji,
|
{ search } = emoji,
|
||||||
sub = value.substr(0, length),
|
sub = value.slice(0, length),
|
||||||
subIndex = search.indexOf(sub);
|
subIndex = search.indexOf(sub);
|
||||||
|
|
||||||
if (subIndex !== -1) {
|
if (subIndex !== -1) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ const trim = (text, len) => {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
return text.substring(0, cut) + (text.length > len ? '…' : '');
|
return text.slice(0, cut) + (text.length > len ? '…' : '');
|
||||||
};
|
};
|
||||||
|
|
||||||
const domParser = new DOMParser();
|
const domParser = new DOMParser();
|
||||||
|
|
|
@ -91,7 +91,7 @@ export const fileNameFromURL = str => {
|
||||||
const pathname = url.pathname;
|
const pathname = url.pathname;
|
||||||
const index = pathname.lastIndexOf('/');
|
const index = pathname.lastIndexOf('/');
|
||||||
|
|
||||||
return pathname.substring(index + 1);
|
return pathname.slice(index + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default @injectIntl
|
export default @injectIntl
|
||||||
|
|
Loading…
Reference in New Issue