Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
style(core): fix eslint error
Dushusir071fffdd6951
diff --git a/package.json b/package.jsonindex d759cdda9e..2f68173b16 100644--- a/package.json+++ b/package.json@@ -33,7 +33,7 @@},"engines": {"node": "^16.20.0",- "pnpm": "^8.6.1"+ "pnpm": "^8.6.2"},"author": "DreamNum <[email protected]>","license": "MIT",diff --git a/packages/core/src/Shared/Generate.ts b/packages/core/src/Shared/Generate.tsindex 963796f91f..aff3041ee0 100644--- a/packages/core/src/Shared/Generate.ts+++ b/packages/core/src/Shared/Generate.ts@@ -1,6 +1,7 @@import numeral from 'numeral';+import { IKeyType } from './Types';-export const error = {+export const error: IKeyType<string> = {v: '#VALUE!', // 错误的参数或运算符n: '#NAME?', // 公式名称错误na: '#N/A', // 函数或公式中没有可用数值diff --git a/packages/core/src/Shared/IOHttp.ts b/packages/core/src/Shared/IOHttp.tsindex 70e1acbc59..f36d9f7028 100644--- a/packages/core/src/Shared/IOHttp.ts+++ b/packages/core/src/Shared/IOHttp.ts@@ -1,4 +1,6 @@-function deleteEmpty(object: object) {+import { IKeyType, IKeyValue } from './Types';++function deleteEmpty(object: IKeyValue) {if (object) {Object.keys(object).forEach((key) => {const value = object[key];@@ -10,7 +12,7 @@ function deleteEmpty(object: object) {return object;}-function extend(src: object, ...target: object[]) {+function extend(src: IKeyValue, ...target: IKeyValue[]) {for (const item of target) {if (item) {for (const key in item) {@@ -25,7 +27,7 @@ function extend(src: object, ...target: object[]) {return src;}-function objectToUrlSearch(object: object) {+function objectToUrlSearch(object: IKeyValue) {if (unDef(object)) return '';let str = '';for (const key in object) {@@ -57,7 +59,7 @@ function urlSearchToObject(search: string) {search = search.substring(index);search = search.replace(/\?/, '');const array = search.split('&');- const object = {+ const object: IKeyType<string> = {$$url: url,};array.forEach((value) => {diff --git a/packages/core/src/Shared/IOSocket.ts b/packages/core/src/Shared/IOSocket.tsindex b3244870cc..b893e00e8d 100644--- a/packages/core/src/Shared/IOSocket.ts+++ b/packages/core/src/Shared/IOSocket.ts@@ -1,3 +1,5 @@+import { IKeyValue } from './Types';+function isDef(v: any) {return v !== undefined && v !== null;}@@ -10,7 +12,7 @@ function isBlank(v: string) {return unDef(v) || v.toString() === '';}-function extend(src: object, ...target: object[]) {+function extend(src: IKeyValue, ...target: IKeyValue[]) {for (const item of target) {if (item) {for (const key in item) {diff --git a/packages/core/src/Shared/ObjectArray.ts b/packages/core/src/Shared/ObjectArray.tsindex 3f88e78a94..c3103e8d22 100644--- a/packages/core/src/Shared/ObjectArray.ts+++ b/packages/core/src/Shared/ObjectArray.ts@@ -1,4 +1,4 @@-import { Nullable } from './Types';+import { IKeyValue, Nullable } from './Types';/*** Predicate Function type@@ -298,7 +298,7 @@ export class ObjectArray<T> {const array = this._array;const length = this._length;if (length > 0) {- const fragment = {};+ const fragment: IKeyValue = {};let effective = 0;for (let i = start; i < end; i++) {const item = array[i];diff --git a/packages/core/src/Shared/Tools.ts b/packages/core/src/Shared/Tools.tsindex 8eb79513af..dc5176ec2b 100644--- a/packages/core/src/Shared/Tools.ts+++ b/packages/core/src/Shared/Tools.ts@@ -274,7 +274,10 @@ export class Tools {return (oneValue as Date).getTime() === towValue.getTime();}if (Tools.isRegExp(oneValue)) {- return (oneValue as string).toString() === towValue.toString();+ return (+ (oneValue as unknown as string).toString() ===+ towValue.toString()+ );}return oneValue === towValue;}@@ -293,7 +296,7 @@ export class Tools {return true;}- function diffObject(oneObject: object, towObject: object) {+ function diffObject(oneObject: IKeyValue, towObject: IKeyValue) {const oneKeys = Object.keys(oneObject);const towKeys = Object.keys(towObject);if (oneKeys.length !== towKeys.length) {@@ -333,7 +336,7 @@ export class Tools {return clone;}if (this.isObject(value)) {- const clone = {};+ const clone: IKeyValue = {};Object.keys(value as IKeyValue).forEach((key) => {const item = (value as IKeyValue)[key];clone[key] = Tools.deepClone(item);@@ -649,8 +652,8 @@ export class Tools {* @param extendJson* @returns*/- static commonExtend<T>(originJson: object, extendJson: object): T {- let resultJsonObject = {};+ static commonExtend<T>(originJson: IKeyValue, extendJson: IKeyValue): T {+ let resultJsonObject: IKeyValue = {};for (let attr in originJson) {resultJsonObject[attr] = originJson[attr];@@ -667,7 +670,7 @@ export class Tools {return resultJsonObject as unknown as T;}- static commonExtend1<T>(originJson: object, extendJson: object): T {+ static commonExtend1<T>(originJson: IKeyValue, extendJson: IKeyValue): T {for (let attr in originJson) {if (extendJson[attr] == null) {extendJson[attr] = originJson[attr];@@ -677,7 +680,7 @@ export class Tools {}static arrayToObject(array: IKeyValue[][]) {- const obj = {};+ const obj: IKeyValue = {};array.forEach((row, i) => {obj[i] = {};row.forEach((column, j) => {diff --git a/packages/core/src/Sheets/Apply/HideSheet.ts b/packages/core/src/Sheets/Apply/HideSheet.tsindex 306766902f..106e5b55f1 100644--- a/packages/core/src/Sheets/Apply/HideSheet.ts+++ b/packages/core/src/Sheets/Apply/HideSheet.ts@@ -1,6 +1,7 @@import { Worksheet } from '../Domain/Worksheet';import { BooleanNumber } from '../../Enum';-import { CommandUnit, ISetWorkSheetHideActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetWorkSheetHideActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/InsertColumn.ts b/packages/core/src/Sheets/Apply/InsertColumn.tsindex d6c6f9d66e..d03f966d67 100644--- a/packages/core/src/Sheets/Apply/InsertColumn.ts+++ b/packages/core/src/Sheets/Apply/InsertColumn.ts@@ -1,6 +1,7 @@import { IColumnData } from '../../Interfaces';import { ObjectArray, ObjectArrayPrimitiveType } from '../../Shared/ObjectArray';-import { CommandUnit, IRemoveColumnAction } from '../../Command';+import { CommandUnit } from '../../Command';+import { IRemoveColumnAction } from '../Action';/*** Inserts addData into columnDatadiff --git a/packages/core/src/Sheets/Apply/InsertRange.ts b/packages/core/src/Sheets/Apply/InsertRange.tsindex 0c03c5858d..4be577720e 100644--- a/packages/core/src/Sheets/Apply/InsertRange.ts+++ b/packages/core/src/Sheets/Apply/InsertRange.ts@@ -1,7 +1,8 @@import { Dimension } from '../../Enum';import { ICellData, IRangeData } from '../../Interfaces';import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared';-import { CommandUnit, IInsertRangeActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { IInsertRangeActionData } from '../Action';/***@@ -45,11 +46,7 @@ export function InsertRange(// insert cell value from userfor (let r = endRow; r >= startRow; r--) {for (let c = startColumn; c <= endColumn; c++) {- cellMatrix.setValue(- r,- c,- (cellValue as ICellData)[r - startRow][c - startColumn]- );+ cellMatrix.setValue(r, c, cellValue[r - startRow][c - startColumn]);}}} else if (shiftDimension === Dimension.COLUMNS) {@@ -70,11 +67,7 @@ export function InsertRange(// }for (let r = startRow; r <= endRow; r++) {for (let c = endColumn; c >= startColumn; c--) {- cellMatrix.setValue(- r,- c,- (cellValue as ICellData)[r - startRow][c - startColumn]- );+ cellMatrix.setValue(r, c, cellValue[r - startRow][c - startColumn]);}}}@@ -108,7 +101,7 @@ export function InsertRangeApply(unit: CommandUnit, data: IInsertRangeActionDatacellMatrix.setValue(r,c,- (data.cellValue as ICellData)[r - startRow][c - startColumn]+ data.cellValue[r - startRow][c - startColumn]);}}@@ -132,7 +125,7 @@ export function InsertRangeApply(unit: CommandUnit, data: IInsertRangeActionDatacellMatrix.setValue(r,c,- (data.cellValue as ICellData)[r - startRow][c - startColumn]+ data.cellValue[r - startRow][c - startColumn]);}}diff --git a/packages/core/src/Sheets/Apply/InsertSheet.ts b/packages/core/src/Sheets/Apply/InsertSheet.tsindex b9d0c1aa36..a496b89d4c 100644--- a/packages/core/src/Sheets/Apply/InsertSheet.ts+++ b/packages/core/src/Sheets/Apply/InsertSheet.ts@@ -1,6 +1,7 @@import { Workbook, Worksheet } from '../Domain';import { IWorksheetConfig } from '../../Interfaces';-import { CommandUnit, IInsertSheetActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { IInsertSheetActionData } from '../Action';export function InsertSheet(workbook: Workbook,diff --git a/packages/core/src/Sheets/Apply/RemoveColumn.ts b/packages/core/src/Sheets/Apply/RemoveColumn.tsindex 10891bd699..dac296231d 100644--- a/packages/core/src/Sheets/Apply/RemoveColumn.ts+++ b/packages/core/src/Sheets/Apply/RemoveColumn.ts@@ -1,6 +1,7 @@import { IColumnData } from '../../Interfaces';import { ObjectArray, ObjectArrayPrimitiveType } from '../../Shared';-import { CommandUnit, IRemoveColumnAction } from '../../Command';+import { CommandUnit } from '../../Command';+import { IRemoveColumnAction } from '../Action';/*** Deletes the specified number of columns in columnDatadiff --git a/packages/core/src/Sheets/Apply/RemoveColumnData.ts b/packages/core/src/Sheets/Apply/RemoveColumnData.tsindex e56f768449..763f0cd9f5 100644--- a/packages/core/src/Sheets/Apply/RemoveColumnData.ts+++ b/packages/core/src/Sheets/Apply/RemoveColumnData.ts@@ -1,6 +1,7 @@import { ICellData } from '../../Interfaces';import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';-import { CommandUnit, IRemoveColumnDataAction } from '../../Command';+import { CommandUnit } from '../../Command';+import { IRemoveColumnDataAction } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/RemoveRow.ts b/packages/core/src/Sheets/Apply/RemoveRow.tsindex f7302b6667..b84edc8c08 100644--- a/packages/core/src/Sheets/Apply/RemoveRow.ts+++ b/packages/core/src/Sheets/Apply/RemoveRow.ts@@ -1,6 +1,7 @@import { IRowData } from '../../Interfaces';import { ObjectArray, ObjectArrayPrimitiveType } from '../../Shared';-import { CommandUnit, IRemoveRowActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { IRemoveRowActionData } from '../Action';/*** Deletes the specified number of rows in rowDatadiff --git a/packages/core/src/Sheets/Apply/RemoveRowData.ts b/packages/core/src/Sheets/Apply/RemoveRowData.tsindex 7b111f1529..000d3ec018 100644--- a/packages/core/src/Sheets/Apply/RemoveRowData.ts+++ b/packages/core/src/Sheets/Apply/RemoveRowData.ts@@ -1,6 +1,7 @@import { ICellData } from '../../Interfaces';import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';-import { CommandUnit, IRemoveRowDataActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { IRemoveRowDataActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/RemoveSheet.ts b/packages/core/src/Sheets/Apply/RemoveSheet.tsindex 73dd0362b5..1b649b1a28 100644--- a/packages/core/src/Sheets/Apply/RemoveSheet.ts+++ b/packages/core/src/Sheets/Apply/RemoveSheet.ts@@ -1,6 +1,7 @@import { Workbook } from '../Domain';import { IWorksheetConfig } from '../../Interfaces';-import { CommandUnit, IRemoveSheetActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { IRemoveSheetActionData } from '../Action';export function RemoveSheet(workbook: Workbook,diff --git a/packages/core/src/Sheets/Apply/SetBorder.ts b/packages/core/src/Sheets/Apply/SetBorder.tsindex 137a766ff7..516c34f8d2 100644--- a/packages/core/src/Sheets/Apply/SetBorder.ts+++ b/packages/core/src/Sheets/Apply/SetBorder.ts@@ -1,7 +1,8 @@import { Styles } from '../Domain';import { ICellData, IStyleData } from '../../Interfaces';import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared';-import { BorderStyleData, CommandUnit } from '../../Command';+import { CommandUnit } from '../../Command';+import { BorderStyleData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetColumnHide.ts b/packages/core/src/Sheets/Apply/SetColumnHide.tsindex 48af48b7ec..e250b1412d 100644--- a/packages/core/src/Sheets/Apply/SetColumnHide.ts+++ b/packages/core/src/Sheets/Apply/SetColumnHide.ts@@ -1,5 +1,6 @@import { ColumnManager } from '../Domain/ColumnManager';-import { CommandUnit, ISetColumnShowActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetColumnShowActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetColumnShow.ts b/packages/core/src/Sheets/Apply/SetColumnShow.tsindex eec28fe2bd..3a29e5508a 100644--- a/packages/core/src/Sheets/Apply/SetColumnShow.ts+++ b/packages/core/src/Sheets/Apply/SetColumnShow.ts@@ -1,5 +1,6 @@import { ColumnManager } from '../Domain/ColumnManager';-import { CommandUnit, ISetColumnShowActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetColumnShowActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetColumnWidth.ts b/packages/core/src/Sheets/Apply/SetColumnWidth.tsindex 190bc0ffda..fad29a369f 100644--- a/packages/core/src/Sheets/Apply/SetColumnWidth.ts+++ b/packages/core/src/Sheets/Apply/SetColumnWidth.ts@@ -1,5 +1,6 @@import { ColumnManager } from '../Domain/ColumnManager';-import { CommandUnit, ISetColumnWidthActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetColumnWidthActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetHiddenGridlines.ts b/packages/core/src/Sheets/Apply/SetHiddenGridlines.tsindex 2809acaa09..5a0710e059 100644--- a/packages/core/src/Sheets/Apply/SetHiddenGridlines.ts+++ b/packages/core/src/Sheets/Apply/SetHiddenGridlines.ts@@ -1,5 +1,6 @@import { Worksheet } from '../Domain/Worksheet';-import { CommandUnit, ISetHiddenGridlinesActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetHiddenGridlinesActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetHideRows.ts b/packages/core/src/Sheets/Apply/SetHideRows.tsindex 197c68e355..75682251d1 100644--- a/packages/core/src/Sheets/Apply/SetHideRows.ts+++ b/packages/core/src/Sheets/Apply/SetHideRows.ts@@ -1,5 +1,6 @@import { RowManager } from '../Domain/RowManager';-import { CommandUnit, ISetRowHideActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetRowHideActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetNamedRange.ts b/packages/core/src/Sheets/Apply/SetNamedRange.tsindex 35009c499e..68de487a47 100644--- a/packages/core/src/Sheets/Apply/SetNamedRange.ts+++ b/packages/core/src/Sheets/Apply/SetNamedRange.ts@@ -1,5 +1,6 @@import { INamedRange } from '../../Interfaces/INamedRange';-import { CommandUnit, ISetNamedRangeActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetNamedRangeActionData } from '../Action';export function SetNamedRange(namedRanges: INamedRange[],diff --git a/packages/core/src/Sheets/Apply/SetRangeNote.ts b/packages/core/src/Sheets/Apply/SetRangeNote.tsindex a4cc2a1df8..00909ee299 100644--- a/packages/core/src/Sheets/Apply/SetRangeNote.ts+++ b/packages/core/src/Sheets/Apply/SetRangeNote.ts@@ -1,7 +1,8 @@import { ICellData, IRangeData } from '../../Interfaces';import { Nullable, Tools } from '../../Shared';import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';-import { CommandUnit, ISetRangeNoteActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetRangeNoteActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetRangeStyle.ts b/packages/core/src/Sheets/Apply/SetRangeStyle.tsindex 28e7f4757b..09c5ed61ce 100644--- a/packages/core/src/Sheets/Apply/SetRangeStyle.ts+++ b/packages/core/src/Sheets/Apply/SetRangeStyle.ts@@ -3,6 +3,7 @@ import { Styles } from '../Domain';import { IRangeData, ICellData, IDocumentData, ITextRun } from '../../Interfaces';import { IBorderData, IStyleData } from '../../Interfaces/IStyleData';import {+ IKeyValue,Nullable,ObjectMatrix,ObjectMatrixPrimitiveType,@@ -137,7 +138,7 @@ export function transformBorders(// 1. To modify the existing border,we need original setting to undo// 2. Newly set the border, we need null to undoif (!(k in oldBorders)) {- oldBorders[k] = null;+ (oldBorders as IKeyValue)[k] = null;}}@@ -170,7 +171,7 @@ export function mergeStyle(if (k in backupStyle && k === 'bd') {backupStyle[k] = Object.assign(backupStyle[k], newStyle[k]);} else {- backupStyle[k] = newStyle[k];+ backupStyle[k] = (newStyle as IKeyValue)[k];// overline/strikethrough/underline add colorif ('cl' in backupStyle) {diff --git a/packages/core/src/Sheets/Apply/SetRightToLeft.ts b/packages/core/src/Sheets/Apply/SetRightToLeft.tsindex d06fecaa09..c021f7df03 100644--- a/packages/core/src/Sheets/Apply/SetRightToLeft.ts+++ b/packages/core/src/Sheets/Apply/SetRightToLeft.ts@@ -1,6 +1,7 @@import { Worksheet } from '../Domain';import { BooleanNumber } from '../../Enum';-import { CommandUnit, ISetRightToLeftActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetRightToLeftActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetRowHeight.ts b/packages/core/src/Sheets/Apply/SetRowHeight.tsindex 91804ab3f8..b4e8a71c7a 100644--- a/packages/core/src/Sheets/Apply/SetRowHeight.ts+++ b/packages/core/src/Sheets/Apply/SetRowHeight.ts@@ -1,5 +1,6 @@import { RowManager } from '../Domain';-import { CommandUnit, ISetRowHeightActionData } from '../../Command';+import { CommandUnit } from '../../Command';+import { ISetRowHeightActionData } from '../Action';/***diff --git a/packages/core/src/Sheets/Apply/SetWorkSheetActivate.ts b/packages/core/src/Sheets/Apply/SetWorkSheetActivate.tsindex 59452d8f31..3749e4b247 100644--- a/packages/core/src/Sheets/Apply/SetWorkSheetActivate.ts+++ b/packages/core/src/Sheets/Apply/SetWorkSheetActivate.ts@@ -1,6 +1,6 @@-import { ISheetStatus } from '../../Command';import { Worksheet } from '../Domain/Worksheet';import { BooleanNumber } from '../../Enum';+import { ISheetStatus } from '../Action';/***