fix(types): improve TypeScript strictness compatibility and modernize test exports
This commit is contained in:
@@ -69,13 +69,14 @@ export const indentWithPrefix = (stringArg: string, prefixArg: string): string =
|
||||
export const normalize = (stringArg: string): string => {
|
||||
let resultString: string;
|
||||
let splitStringArray: string[] = splitStringAtLineBreak(stringArg);
|
||||
let minCommonLeftOffset: number;
|
||||
let minCommonLeftOffset: number | undefined;
|
||||
|
||||
const deIndentRegex = /^(\s*)/;
|
||||
const emptyLineRegex = /^(\s*)$/;
|
||||
|
||||
for (let stringItem of splitStringArray) {
|
||||
let offsetString = deIndentRegex.exec(stringItem)[1];
|
||||
const regexMatch = deIndentRegex.exec(stringItem);
|
||||
let offsetString = regexMatch ? regexMatch[1] : '';
|
||||
if (
|
||||
(typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset) &&
|
||||
!emptyLineRegex.test(stringItem)
|
||||
@@ -84,8 +85,9 @@ export const normalize = (stringArg: string): string => {
|
||||
}
|
||||
}
|
||||
let resultSplitStringArray = [];
|
||||
const commonLeftOffset = minCommonLeftOffset || 0;
|
||||
for (let stringItem of splitStringArray) {
|
||||
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
||||
resultSplitStringArray.push(stringItem.substr(commonLeftOffset));
|
||||
}
|
||||
resultString = joinStringWithLineBreaks(resultSplitStringArray);
|
||||
return resultString;
|
||||
|
||||
Reference in New Issue
Block a user