Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/member-ordering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/src/convert-comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/src/create-program/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
23 changes: 6 additions & 17 deletions packages/website-eslint/src/mock/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
};