Skip to content

Commit ab08f66

Browse files
refactor: apply ES2019 optional catch binding and array methods (#4036)
1 parent f98fa63 commit ab08f66

File tree

5 files changed

+6
-27
lines changed

5 files changed

+6
-27
lines changed

src/collection-preferences/visible-content.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ export default function VisibleContentPreference({
3333
}: VisibleContentPreferenceProps) {
3434
const idPrefix = useUniqueId('visible-content');
3535

36-
const flatOptionsIds = options.reduce<string[]>(
37-
(ids, group) => [...ids, ...group.options.reduce<string[]>((groupIds, option) => [...groupIds, option.id], [])],
38-
[]
39-
);
36+
const flatOptionsIds = options.flatMap(group => group.options.map(option => option.id));
4037

4138
const onToggle = (id: string) => {
4239
if (!isVisible(id, value)) {

src/internal/plugins/api.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ function findUpApi(currentWindow: WindowWithApi): AwsuiApi | undefined {
5151
}
5252

5353
return findUpApi(currentWindow.parent as WindowWithApi);
54-
55-
// Consumers in the past have not always been able to support not specifiying the value so we keep and ignore
56-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
57-
} catch (ex) {
54+
} catch {
5855
// Most likely a cross-origin access error
5956
return undefined;
6057
}

src/internal/utils/check-safe-url.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ export function checkSafeUrl(component: string, url: string | undefined | null):
1515
let parsedUrl: URL;
1616
try {
1717
parsedUrl = new URL(url);
18-
19-
// Consumers in the past have not always been able to support not specifiying the value so we keep and ignore
20-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
21-
} catch (e) {
18+
} catch {
2219
// If the URL cannot be parsed by the browser, it likely does not pose a security risk.
2320
return;
2421
}

src/mixed-line-bar-chart/make-scaled-series.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,9 @@ function getAllX<T>(series: ReadonlyArray<InternalChartSeries<T>>) {
118118
break;
119119
}
120120
}
121-
const allDataX: T[] = [];
122-
addDataXSet.forEach(x => allDataX.push(x));
123-
124-
return allDataX;
121+
return Array.from(addDataXSet);
125122
}
126123

127124
function flatten<T>(arrays: T[][]): T[] {
128-
const merged: T[] = [];
129-
for (const array of arrays) {
130-
for (const item of array) {
131-
merged.push(item);
132-
}
133-
}
134-
return merged;
125+
return arrays.flat();
135126
}

src/table/body-cell/inline-editor.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ export function InlineEditor<ItemType>({
6363
await submitEdit(item, column, currentEditValue);
6464
setCurrentEditLoading(false);
6565
finishEdit();
66-
67-
// Consumers in the past have not always been able to support not specifiying the value so we keep and ignore
68-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
69-
} catch (e) {
66+
} catch {
7067
setCurrentEditLoading(false);
7168
focusLockRef.current?.focusFirst();
7269
}

0 commit comments

Comments
 (0)