diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 92c794caf07f..8c423b2f1044 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -299,10 +299,10 @@ function getMemberRawName( const { name, type } = util.getNameFromMember(member, sourceCode); if (type === util.MemberNameType.Quoted) { - return name.substr(1, name.length - 2); + return name.slice(1, -1); } if (type === util.MemberNameType.Private) { - return name.substr(1); + return name.slice(1); } return name; } diff --git a/packages/typescript-estree/src/convert-comments.ts b/packages/typescript-estree/src/convert-comments.ts index 737b01b242f8..effc4ead9077 100644 --- a/packages/typescript-estree/src/convert-comments.ts +++ b/packages/typescript-estree/src/convert-comments.ts @@ -36,7 +36,7 @@ export function convertComments( range[1] - textStart - 2; comments.push({ type, - value: code.substr(textStart, textEnd), + value: code.slice(textStart, textStart + textEnd), range, loc, }); diff --git a/packages/typescript-estree/src/create-program/shared.ts b/packages/typescript-estree/src/create-program/shared.ts index a0e654c90979..53d6fe9ee4de 100644 --- a/packages/typescript-estree/src/create-program/shared.ts +++ b/packages/typescript-estree/src/create-program/shared.ts @@ -57,7 +57,7 @@ const correctPathCasing = useCaseSensitiveFileNames function getCanonicalFileName(filePath: string): CanonicalPath { let normalized = path.normalize(filePath); if (normalized.endsWith(path.sep)) { - normalized = normalized.substr(0, normalized.length - 1); + normalized = normalized.slice(0, -1); } return correctPathCasing(normalized) as CanonicalPath; } diff --git a/packages/website-eslint/src/mock/path.js b/packages/website-eslint/src/mock/path.js index 3d04551e2e79..a93a1a650d1a 100644 --- a/packages/website-eslint/src/mock/path.js +++ b/packages/website-eslint/src/mock/path.js @@ -95,7 +95,7 @@ export function resolve() { // posix version export function normalize(path) { let isPathAbsolute = isAbsolute(path), - trailingSlash = substr(path, -1) === '/'; + trailingSlash = path.endsWith('/'); // Normalize the path path = normalizeArray( @@ -136,8 +136,8 @@ export function join() { // path.relative(from, to) // posix version export function relative(from, to) { - from = resolve(from).substr(1); - to = resolve(to).substr(1); + from = resolve(from).slice(1); + to = resolve(to).slice(1); function trim(arr) { let start = 0; @@ -191,7 +191,7 @@ export function dirname(path) { if (dir) { // It has a dirname, strip trailing slash - dir = dir.substr(0, dir.length - 1); + dir = dir.slice(0, -1); } return root + dir; @@ -200,8 +200,8 @@ export function dirname(path) { export function basename(path, ext) { let f = splitPath(path)[2]; // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); + if (ext && f.slice(-1 * ext.length) === ext) { + f = f.slice(0, f.length - ext.length); } return f; } @@ -231,14 +231,3 @@ function filter(xs, f) { } return res; } - -// String.prototype.substr - negative index don't work in IE8 -const substr = - 'ab'.substr(-1) === 'b' - ? function (str, start, len) { - return str.substr(start, len); - } - : function (str, start, len) { - if (start < 0) start = str.length + start; - return str.substr(start, len); - }; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy