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.

chore: add no reassign param lint (#2876)

Wenzhao Hu6b79da621c2a
diff --git a/common/shared/eslint/index.js b/common/shared/eslint/index.js
index 4455d00c05..efec48115e 100644
--- a/common/shared/eslint/index.js
+++ b/common/shared/eslint/index.js
@@ -1,5 +1,6 @@
exports.baseRules = {
curly: ['error', 'multi-line'],
+ 'no-param-reassign': ['warn'],
'eol-last': ['error', 'always'],
'import/no-self-import': 'error',
'ts/no-explicit-any': 'warn',
diff --git a/packages/slides/src/views/render/canvas-view.ts b/packages/slides/src/views/render/canvas-view.ts
index 3f5cc92262..59beaa5729 100644
--- a/packages/slides/src/views/render/canvas-view.ts
+++ b/packages/slides/src/views/render/canvas-view.ts
@@ -65,7 +65,8 @@ export class CanvasView extends RxDisposable {
});
}
- activePage(pageId?: string) {
+ activePage(_pageId?: string) {
+ let pageId = _pageId;
const model = this._univerInstanceService.getCurrentUnitForType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE)!;
let page: Nullable<ISlidePage>;
if (pageId) {
diff --git a/packages/ui/src/services/before-close/before-close.service.ts b/packages/ui/src/services/before-close/before-close.service.ts
index e29f6e3e90..4b0f08065c 100644
--- a/packages/ui/src/services/before-close/before-close.service.ts
+++ b/packages/ui/src/services/before-close/before-close.service.ts
@@ -66,7 +66,8 @@ export class DesktopBeforeCloseService implements IBeforeCloseService {
}
private _init(): void {
- window.addEventListener('beforeunload', (event: BeforeUnloadEvent) => {
+ window.addEventListener('beforeunload', (_event: BeforeUnloadEvent) => {
+ let event = _event;
const message = this._beforeUnloadCallbacks
.map((callback) => callback())
.filter((m) => !!m)
diff --git a/packages/ui/src/services/editor/editor.service.ts b/packages/ui/src/services/editor/editor.service.ts
index debf58b6f2..bc6c385e05 100644
--- a/packages/ui/src/services/editor/editor.service.ts
+++ b/packages/ui/src/services/editor/editor.service.ts
@@ -482,14 +482,9 @@ export class EditorService extends Disposable implements IEditorService, IDispos
this._blur$.next(null);
}
- focus(editorUnitId?: string) {
+ focus(editorUnitId: string | undefined = this._univerInstanceService.getCurrentUniverDocInstance()?.getUnitId()) {
if (editorUnitId == null) {
- const documentDataModel = this._univerInstanceService.getCurrentUniverDocInstance();
- if (!documentDataModel) {
- return;
- }
-
- editorUnitId = documentDataModel.getUnitId();
+ return;
}
const editor = this.getEditor(editorUnitId);
@@ -509,20 +504,12 @@ export class EditorService extends Disposable implements IEditorService, IDispos
});
}
- setFormula(formulaString: string, editorUnitId?: string) {
- if (editorUnitId == null) {
- editorUnitId = this._getCurrentEditorUnitId();
- }
+ setFormula(formulaString: string, editorUnitId = this._getCurrentEditorUnitId()) {
this._inputFormula$.next({ formulaString, editorUnitId });
}
- setValue(val: string, editorUnitId?: string) {
- if (editorUnitId == null) {
- editorUnitId = this._getCurrentEditorUnitId();
- }
-
+ setValue(val: string, editorUnitId: string = this._getCurrentEditorUnitId()) {
this.setValueNoRefresh(val, editorUnitId);
-
this._refreshValueChange(editorUnitId);
}
@@ -545,13 +532,8 @@ export class EditorService extends Disposable implements IEditorService, IDispos
return editor.getValue();
}
- setRichValue(body: IDocumentBody, editorUnitId?: string) {
- if (editorUnitId == null) {
- editorUnitId = this._getCurrentEditorUnitId();
- }
-
+ setRichValue(body: IDocumentBody, editorUnitId: string = this._getCurrentEditorUnitId()) {
this._setValue$.next({ body, editorUnitId });
-
this._refreshValueChange(editorUnitId);
}
@@ -569,10 +551,7 @@ export class EditorService extends Disposable implements IEditorService, IDispos
super.dispose();
}
- getEditor(id?: string): Readonly<Nullable<Editor>> {
- if (id == null) {
- id = this._getCurrentEditorUnitId();
- }
+ getEditor(id: string = this._getCurrentEditorUnitId()): Readonly<Nullable<Editor>> {
return this._editors.get(id);
}
diff --git a/packages/ui/src/utils/cell.ts b/packages/ui/src/utils/cell.ts
index 42e1229e16..a92dc52c43 100644
--- a/packages/ui/src/utils/cell.ts
+++ b/packages/ui/src/utils/cell.ts
@@ -156,9 +156,8 @@ export function handleStringToStyle($dom?: HTMLElement, cssStyle: string = '') {
l: '',
};
- cssTextArray.forEach((s) => {
- const originStr = s;
- s = s.toLowerCase();
+ cssTextArray.forEach((originStr) => {
+ const s = originStr.toLowerCase();
const key = textTrim(s.substr(0, s.indexOf(':')));
const value = textTrim(s.substr(s.indexOf(':') + 1));