Skip to content

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.

fix: fix lint errors (#1187)

Wenzhao Hu0a6a3c8c7e20
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index 589aa7f15d..46dc3f4e09 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -20,9 +20,11 @@ import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
+import { UniverFindReplacePlugin } from '@univerjs/find-replace';
import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
+import { UniverSheetsFindPlugin } from '@univerjs/sheets-find-replace';
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';
@@ -32,8 +34,6 @@ import { UniverUIPlugin } from '@univerjs/ui';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data';
import { DebuggerPlugin } from '../plugins/debugger';
import { locales } from './locales';
-import { UniverFindReplacePlugin } from '@univerjs/find-replace';
-import { UniverSheetsFindPlugin } from '@univerjs/sheets-find-replace';
const LOAD_LAZY_PLUGINS_TIMEOUT = 5_000;
// univer
diff --git a/examples/src/slides/main.ts b/examples/src/slides/main.ts
index 1ee00a7dda..83a1d89de0 100644
--- a/examples/src/slides/main.ts
+++ b/examples/src/slides/main.ts
@@ -45,6 +45,7 @@ univer.createUniverSlide(DEFAULT_SLIDE_DATA);
// use for console test
declare global {
+ // eslint-disable-next-line @typescript-eslint/naming-convention
interface Window {
univer?: Univer;
}
diff --git a/packages/core/src/common/interceptor.ts b/packages/core/src/common/interceptor.ts
index 7b7c4c523a..1c2b0ac1c9 100644
--- a/packages/core/src/common/interceptor.ts
+++ b/packages/core/src/common/interceptor.ts
@@ -90,7 +90,7 @@ export class InterceptorManager<P extends Record<string, IInterceptor<any, any>>
this._interceptorsByName.set(
key,
- interceptors.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0))
+ interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)) // from large to small
);
return () => remove(this._interceptorsByName.get(key)!, interceptor);
}
diff --git a/packages/facade/src/apis/sheet/f-range.ts b/packages/facade/src/apis/sheet/f-range.ts
index 9d2a031cb8..bb4890e8f9 100644
--- a/packages/facade/src/apis/sheet/f-range.ts
+++ b/packages/facade/src/apis/sheet/f-range.ts
@@ -15,8 +15,8 @@
*/
import type {
+ CellValue,
ICellData,
- ICellV,
IColorStyle,
IObjectMatrixPrimitiveType,
IRange,
@@ -79,7 +79,7 @@ export class FRange {
return this._range.endRow - this._range.startRow + 1;
}
- getValue(): ICellV | null {
+ getValue(): CellValue | null {
return this._worksheet.getCell(this._range.startRow, this._range.startColumn)?.v ?? null;
}
@@ -119,7 +119,7 @@ export class FRange {
* The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
* @param value
*/
- setValue(value: ICellV | ICellData): Promise<boolean> {
+ setValue(value: CellValue | ICellData): Promise<boolean> {
const realValue = covertCellValue(value);
if (!realValue) {
@@ -192,7 +192,11 @@ export class FRange {
* @param value
*/
setValues(
- value: ICellV[][] | IObjectMatrixPrimitiveType<ICellV> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>
+ value:
+ | CellValue[][]
+ | IObjectMatrixPrimitiveType<CellValue>
+ | ICellData[][]
+ | IObjectMatrixPrimitiveType<ICellData>
): Promise<boolean> {
const realValue = covertCellValues(value, this._range);
diff --git a/packages/facade/src/apis/sheet/utils.ts b/packages/facade/src/apis/sheet/utils.ts
index aeb20f5232..a250c196a1 100644
--- a/packages/facade/src/apis/sheet/utils.ts
+++ b/packages/facade/src/apis/sheet/utils.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { ICellData, ICellV, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
+import type { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
import {
HorizontalAlign,
isCellV,
@@ -85,7 +85,7 @@ export function transformCoreVerticalAlignment(value: VerticalAlign): FVerticalA
* @param value
* @returns
*/
-export function covertCellValue(value: ICellV | ICellData): ICellData {
+export function covertCellValue(value: CellValue | ICellData): ICellData {
if (isFormulaString(value)) {
return {
f: value as string,
@@ -93,7 +93,7 @@ export function covertCellValue(value: ICellV | ICellData): ICellData {
}
if (isCellV(value)) {
return {
- v: value as Nullable<ICellV>,
+ v: value as Nullable<CellValue>,
};
}
if (isICellData(value)) {
@@ -111,7 +111,11 @@ export function covertCellValue(value: ICellV | ICellData): ICellData {
* @returns
*/
export function covertCellValues(
- value: ICellV[][] | IObjectMatrixPrimitiveType<ICellV> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>,
+ value:
+ | CellValue[][]
+ | IObjectMatrixPrimitiveType<CellValue>
+ | ICellData[][]
+ | IObjectMatrixPrimitiveType<ICellData>,
range: IRange
): IObjectMatrixPrimitiveType<ICellData> {
const cellValue = new ObjectMatrix<ICellData>();
@@ -124,7 +128,7 @@ export function covertCellValues(
}
}
} else {
- const valueMatrix = new ObjectMatrix(value as IObjectMatrixPrimitiveType<ICellData | ICellV>);
+ const valueMatrix = new ObjectMatrix(value as IObjectMatrixPrimitiveType<ICellData | CellValue>);
valueMatrix.forValue((r, c, v) => {
cellValue.setValue(r, c, covertCellValue(v));
});
diff --git a/packages/find-replace/src/services/mocks/mock-find-replace.service.ts b/packages/find-replace/src/services/mocks/mock-find-replace.service.ts
deleted file mode 100644
index e32faa7f16..0000000000
--- a/packages/find-replace/src/services/mocks/mock-find-replace.service.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { FindReplaceService } from '../common/find-replace.service';
-
-export class MockFindReplaceService implements FindReplaceService {}
diff --git a/packages/find-replace/src/views/dialog/Dialog.stories.tsx b/packages/find-replace/src/views/dialog/Dialog.stories.tsx
index baad0bc2d9..edf5d526ee 100644
--- a/packages/find-replace/src/views/dialog/Dialog.stories.tsx
+++ b/packages/find-replace/src/views/dialog/Dialog.stories.tsx
@@ -20,9 +20,7 @@ import { Injector } from '@wendellhu/redi';
import { RediContext } from '@wendellhu/redi/react-bindings';
import React, { useState } from 'react';
-import { IFindReplaceDialogService } from '../../services/find-replace-dialog.service';
import { FindReplaceDialog } from './Dialog';
-import { StorybookFindReplaceDialogService } from './mock/mocks';
const meta: Meta = {
title: 'Find Replace Dialog',
@@ -39,7 +37,6 @@ function FindDialogDemo() {
const injector = new Injector();
// injector.add([IFindReplaceService]);
injector.add([LocaleService]);
- injector.add([IFindReplaceDialogService, { useClass: StorybookFindReplaceDialogService }]);
injector.get(LocaleService).load({});
@@ -64,10 +61,8 @@ function ReplaceDialogDemo() {
const injector = new Injector();
// injector.add([IFindReplaceService]);
injector.add([LocaleService]);
- injector.add([IFindReplaceDialogService, { useClass: StorybookFindReplaceDialogService }]);
injector.get(LocaleService).load({});
- (injector.get(IFindReplaceDialogService) as StorybookFindReplaceDialogService).toggleReplace();
return injector;
});
diff --git a/packages/find-replace/src/views/dialog/mock/mocks.tsx b/packages/find-replace/src/views/dialog/mock/mocks.tsx
deleted file mode 100644
index 41abe9f08f..0000000000
--- a/packages/find-replace/src/views/dialog/mock/mocks.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { Observable } from 'rxjs';
-import { BehaviorSubject } from 'rxjs';
-
-import { FindReplaceState, type IFindReplaceDialogService } from '../../../services/find-replace-dialog.service';
-
-export class StorybookFindReplaceDialogService implements IFindReplaceDialogService {
- private readonly _state = new BehaviorSubject<FindReplaceState>(FindReplaceState.FIND);
- readonly state$: Observable<FindReplaceState> = this._state.asObservable();
-
- get state(): FindReplaceState {
- return this._state.getValue();
- }
-
- toggleFind(): void {
- this._state.next(FindReplaceState.FIND);
- }
-
- toggleReplace(): void {
- this._state.next(FindReplaceState.REPLACE);
- }
-
- closePanel(): void {
- this._state.next(FindReplaceState.CLOSED);
- }
-}
diff --git a/packages/sheets-find-replace/src/controllers/find-replace.controller.ts b/packages/sheets-find-replace/src/controllers/find-replace.controller.ts
index 7d44639200..8ada975388 100644
--- a/packages/sheets-find-replace/src/controllers/find-replace.controller.ts
+++ b/packages/sheets-find-replace/src/controllers/find-replace.controller.ts
@@ -29,7 +29,7 @@ import { isBeforePositionWithRowPriority, isBehindPositionWithRowPriority, isSam
@OnLifecycle(LifecycleStages.Steady, SheetsFindReplaceController)
export class SheetsFindReplaceController extends Disposable implements IDisposable {
- private _provider: SheetsFindReplaceProvider;
+ private _provider!: SheetsFindReplaceProvider;
constructor(
@Inject(Injector) private readonly _injector: Injector,
diff --git a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts b/packages/sheets/src/commands/mutations/set-range-values.mutation.ts
index 210f0fef56..9bd7a69ab4 100644
--- a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts
+++ b/packages/sheets/src/commands/mutations/set-range-values.mutation.ts
@@ -15,9 +15,9 @@
*/
import type {
+ CellValue,
IBorderData,
ICellData,
- CellValue,
ICopyToOptionsData,
IDocumentData,
IKeyValue,