* Use template strings in non-regression tests * Refactor non-regression tests to fix test failures Moved backtick to fix test 'getter/setter babel/babel-eslint#218' as indent matters Fixed line numbers for some tests * Use template strings in babel-eslint tests * Fix tests for babel-eslint Avoids error that shows when using template strings for tests: line 253 line comments line 260 block comments line 306 jsdoc Error: At loc.start.column: are different (6 !== 0) * Other small template literal changes * Add unpad to correctly indent template literals
15 lines
301 B
JavaScript
15 lines
301 B
JavaScript
// Remove padding from a string.
|
|
function unpad(str) {
|
|
const lines = str.split("\n");
|
|
const m = lines[1] && lines[1].match(/^\s+/);
|
|
if (!m) {
|
|
return str;
|
|
}
|
|
const spaces = m[0].length;
|
|
return lines.map(
|
|
(line) => line.slice(spaces)
|
|
).join("\n").trim();
|
|
}
|
|
|
|
module.exports = unpad;
|