diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index c7b3e55d2e..c5467cc415 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -184,7 +184,7 @@ module.exports = { if (parentType === 'JSXAttribute') { textToReplace = `"${expressionType === 'TemplateLiteral' ? expression.quasis[0].value.raw - : expression.raw.substring(1, expression.raw.length - 1) + : expression.raw.slice(1, -1) }"`; } else if (jsxUtil.isJSX(expression)) { const sourceCode = context.getSourceCode(); @@ -222,7 +222,7 @@ module.exports = { const expression = literalNode.parent.type === 'JSXAttribute' ? `{"${escapeDoubleQuotes(escapeBackslashes( - literalNode.raw.substring(1, literalNode.raw.length - 1) + literalNode.raw.slice(1, -1) ))}"}` : wrapWithCurlyBraces(literalNode.raw); diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index 5de5bee1d6..6d19f201cd 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -250,7 +250,7 @@ function generateFixerFunction(node, context, reservedList) { sortableAttributeGroups.forEach((sortableGroup, ii) => { sortableGroup.forEach((attr, jj) => { const sortedAttr = sortedAttributeGroups[ii][jj]; - const sortedAttrText = source.substring(sortedAttr.range[0], attributeMap.get(sortedAttr).end); + const sortedAttrText = source.slice(sortedAttr.range[0], attributeMap.get(sortedAttr).end); fixers.push({ range: [attr.range[0], attributeMap.get(attr).end], text: sortedAttrText, @@ -266,10 +266,10 @@ function generateFixerFunction(node, context, reservedList) { const rangeEnd = firstFixer ? firstFixer.range[1] : -0; fixers.forEach((fix) => { - source = `${source.substr(0, fix.range[0])}${fix.text}${source.substr(fix.range[1])}`; + source = `${source.slice(0, fix.range[0])}${fix.text}${source.slice(fix.range[1])}`; }); - return fixer.replaceTextRange([rangeStart, rangeEnd], source.substr(rangeStart, rangeEnd - rangeStart)); + return fixer.replaceTextRange([rangeStart, rangeEnd], source.slice(rangeStart, rangeEnd)); }; } diff --git a/lib/rules/no-unescaped-entities.js b/lib/rules/no-unescaped-entities.js index 2ae5cdc6b9..3eaa7cd757 100644 --- a/lib/rules/no-unescaped-entities.js +++ b/lib/rules/no-unescaped-entities.js @@ -93,7 +93,7 @@ module.exports = { if (i === node.loc.end.line) { end = node.loc.end.column; } - rawLine = rawLine.substring(start, end); + rawLine = rawLine.slice(start, end); for (let j = 0; j < entities.length; j++) { for (let index = 0; index < rawLine.length; index++) { const c = rawLine[index]; diff --git a/lib/util/propTypesSort.js b/lib/util/propTypesSort.js index 3cfa1d0223..505f346a3b 100644 --- a/lib/util/propTypesSort.js +++ b/lib/util/propTypesSort.js @@ -181,10 +181,8 @@ function fixPropTypesSort( source = nodes.reduceRight((acc, attr, index) => { const sortedAttr = sortedAttributes[index]; const sourceCodeText = sourceCode.getText(); - let sortedAttrText = sourceCodeText.substring( - commentnodeMap.get(sortedAttr).start, - commentnodeMap.get(sortedAttr).end - ); + const commentNode = commentnodeMap.get(sortedAttr); + let sortedAttrText = sourceCodeText.slice(commentNode.start, commentNode.end); if (sortShapeProp && isShapeProp(sortedAttr.value)) { const shape = getShapeProperties(sortedAttr.value); if (shape) {