diff --git a/.changeset/sweet-donuts-repeat.md b/.changeset/sweet-donuts-repeat.md new file mode 100644 index 0000000000..d8df15b670 --- /dev/null +++ b/.changeset/sweet-donuts-repeat.md @@ -0,0 +1,5 @@ +--- +"@asyncapi/generator-react-sdk": patch +--- + +Use the `new Array()` constructor form in the react-sdk string utilities instead of calling `Array()` without `new`, as flagged by SonarCloud. Behaviour is unchanged. diff --git a/apps/react-sdk/src/utils/withIndendation.ts b/apps/react-sdk/src/utils/withIndendation.ts index 504d91535d..ecada7ae32 100644 --- a/apps/react-sdk/src/utils/withIndendation.ts +++ b/apps/react-sdk/src/utils/withIndendation.ts @@ -43,5 +43,5 @@ export function withIndendation(content: string = '', size: number, type: Indent */ function getIndentation(size: number = 0, type: IndentationTypes = IndentationTypes.SPACES): string { const whitespaceChar = type === IndentationTypes.SPACES ? ' ' : '\t'; - return Array(size).fill(whitespaceChar).join(""); + return new Array(size).fill(whitespaceChar).join(""); } diff --git a/apps/react-sdk/src/utils/withNewLines.ts b/apps/react-sdk/src/utils/withNewLines.ts index fe6a903497..4de8d598b0 100644 --- a/apps/react-sdk/src/utils/withNewLines.ts +++ b/apps/react-sdk/src/utils/withNewLines.ts @@ -6,6 +6,6 @@ * @returns {string} */ export function withNewLines(content: string = '', number: number = 0): string { - const newLines = Array(number).fill('\n').join(''); + const newLines = new Array(number).fill('\n').join(''); return content + newLines; }