refactor(editor): enable the noUncheckedIndexedAccess rule for the data-view package (#9351)

close: BS-2230
This commit is contained in:
zzj3720
2024-12-26 14:00:11 +00:00
parent 040f427e9e
commit 188cabc7d7
40 changed files with 258 additions and 123 deletions

View File

@@ -233,9 +233,12 @@ export class FilterConditionView extends SignalWatcher(ShadowlessElement) {
if (!type || !argValues || !data) {
return;
}
const argDataList = argValues.map((v, i) =>
v ? { value: v, type: type.args[i + 1] } : undefined
);
const argDataList = argValues.map((v, i) => {
if (v == null) return undefined;
const argType = type.args[i + 1];
if (!argType) return undefined;
return { value: v, type: argType };
});
const valueString = data.shortString?.(...argDataList) ?? '';
if (valueString) {
return `${name}${valueString}`;

View File

@@ -262,6 +262,9 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
private _clickConditionOps(target: HTMLElement, i: number) {
const filter = this.filterGroup.value.conditions[i];
if (!filter) {
return;
}
popFilterableSimpleMenu(popupTargetFromElement(target), [
menu.group({
items: [

View File

@@ -202,6 +202,9 @@ export class FilterRootView extends SignalWatcher(ShadowlessElement) {
private _clickConditionOps(target: HTMLElement, i: number) {
const filter = this.filterGroup.value.conditions[i];
if (!filter) {
return;
}
popFilterableSimpleMenu(popupTargetFromElement(target), [
menu.action({
name: filter.type === 'filter' ? 'Turn into group' : 'Wrap in group',

View File

@@ -259,7 +259,7 @@ export const popViewOptions = (
return;
}
const isSelected =
meta.type === view.manager.currentView$.value.type;
meta.type === view.manager.currentView$.value?.type;
const iconStyle = styleMap({
fontSize: '24px',
color: isSelected
@@ -285,10 +285,11 @@ export const popViewOptions = (
</div>
`,
select: () => {
view.manager.viewChangeType(
view.manager.currentViewId$.value,
meta.type
);
const id = view.manager.currentViewId$.value;
if (!id) {
return;
}
view.manager.viewChangeType(id, meta.type);
dataViewInstance.clearSelection();
},
class: {},

View File

@@ -148,7 +148,11 @@ export class DataViewHeaderViews extends WidgetBase {
}
const views = this.viewManager.views$.value;
const index = views.findIndex(v => v === id);
const view = this.viewManager.viewGet(views[index]);
const viewId = views[index];
if (!viewId) {
return;
}
const view = this.viewManager.viewGet(viewId);
if (!view) {
return;
}