Skip to content

[MOB-9256]: Added TypeScript linting rule: prefer-for-of #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions .eslintrc
Copy link

@lposen lposen Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just thinking... we should probably find a way to standardize this across the entire frontend. It would be awesome if the eslint config in iterable-frontend could be importable.

cc: @nbaldwin @notyourbear

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that's a good idea 👍

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"max-classes-per-file": "off",
"object-curly-newline": "off",
"no-shadow": "off",
"prefer-const": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/comma-spacing": 2,
"@typescript-eslint/explicit-function-return-type": "off",
Expand Down
39 changes: 17 additions & 22 deletions src/embedded/embeddedPlacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,19 @@ export class EmbeddedMessageElements {
if (elements?.buttons) {
const buttonsJson: any = [];

for (let i = 0; i < elements.buttons.length; i++) {
buttonsJson.push(
EmbeddedMessageElementsButton.toJSONObject(elements.buttons[i])
);
}
elements.buttons?.forEach((button) =>
buttonsJson.push(EmbeddedMessageElementsButton.toJSONObject(button))
);

elementsJson.buttons = buttonsJson;
}

if (elements?.text) {
const textJson: any = [];

for (let i = 0; i < elements.text.length; i++) {
textJson.push(
EmbeddedMessageElementsText.toJSONObject(elements.text[i])
);
}
elements.text?.forEach((text) =>
textJson.push(EmbeddedMessageElementsText.toJSONObject(text))
);

elementsJson.text = textJson;
}
Expand Down Expand Up @@ -250,12 +247,11 @@ export class EmbeddedMessageElements {
let buttons: EmbeddedMessageElementsButton[] | null = [];

if (buttonsJson) {
for (let i = 0; i < buttonsJson.length; i++) {
const buttonJson: any = buttonsJson[i];
const button: EmbeddedMessageElementsButton =
EmbeddedMessageElementsButton.fromJSONObject(buttonJson);
buttons?.push(button);
}
buttonsJson.forEach((button) => {
const buttonFromJson: EmbeddedMessageElementsButton =
EmbeddedMessageElementsButton.fromJSONObject(button);
buttons?.push(buttonFromJson);
});
} else {
buttons = null;
}
Expand All @@ -264,12 +260,11 @@ export class EmbeddedMessageElements {
let texts: EmbeddedMessageElementsText[] | null = [];

if (textsJson) {
for (let i = 0; i < textsJson.length; i++) {
const textJson: any = textsJson[i];
const text: EmbeddedMessageElementsText =
EmbeddedMessageElementsText.fromJSONObject(textJson);
texts?.push(text);
}
textsJson.forEach((text) => {
const textFromJson: EmbeddedMessageElementsText =
EmbeddedMessageElementsText.fromJSONObject(text);
texts?.push(textFromJson);
});
} else {
texts = null;
}
Expand Down
Loading