refactor(editor): enable the noUncheckedIndexedAccess rule for the block-database package (#9691)

close: BS-2269
This commit is contained in:
zzj3720 committed 2025-01-14 14:35:46 +00:00
1 parent aa2a8fbf9b
commit ff295f383f
24 files changed
+324 -344

No files matched your search

@@ -1,3 +1,6 @@
import { format } from 'date-fns/format';
import { parse } from 'date-fns/parse';
import { t } from '../../core/logical/type-presets.js';
import { propertyType } from '../../core/property/property-config.js';
@@ -6,12 +9,12 @@ export const datePropertyModelConfig = datePropertyType.modelConfig<number>({
name: 'Date',
type: () => t.date.instance(),
defaultData: () => ({}),
cellToString: ({ value }) => value?.toString() ?? '',
cellToString: ({ value }) => format(value, 'yyyy-MM-dd'),
cellFromString: ({ value }) => {
const isDateFormat = !isNaN(Date.parse(value));
const date = parse(value, 'yyyy-MM-dd', new Date());
return {
value: isDateFormat ? +new Date(value) : null,
value: +date,
};
},
cellToJson: ({ value }) => value ?? null,