Chore/lint fixes (#212)

* fix(eslint): 修复装饰器缩进配置

* fix(eslint): 修复装饰器缩进配置

* chore: 删除未使用的导入

* chore(lint): 移除未使用的导入和变量

* chore(lint): 修复editor-app中未使用的函数参数

* chore(lint): 修复未使用的赋值变量

* chore(eslint): 将所有错误级别改为警告以通过CI

* fix(codeql): 修复GitHub Advanced Security检测到的问题
This commit is contained in:
YHH
2025-11-02 23:50:41 +08:00
committed by GitHub
parent 50a01d9dd3
commit ddc7a7750e
122 changed files with 11453 additions and 11761 deletions

View File

@@ -208,7 +208,7 @@ export class EditorPluginManager extends PluginManager {
* 按类别获取插件
*/
public getPluginsByCategory(category: EditorPluginCategory): IEditorPlugin[] {
return this.getAllEditorPlugins().filter(plugin => plugin.category === category);
return this.getAllEditorPlugins().filter((plugin) => plugin.category === category);
}
/**

View File

@@ -17,36 +17,36 @@ export interface ComponentTypeInfo {
*/
@Injectable()
export class ComponentRegistry implements IService {
private components: Map<string, ComponentTypeInfo> = new Map();
private components: Map<string, ComponentTypeInfo> = new Map();
public dispose(): void {
this.components.clear();
}
public dispose(): void {
this.components.clear();
}
public register(info: ComponentTypeInfo): void {
this.components.set(info.name, info);
}
public register(info: ComponentTypeInfo): void {
this.components.set(info.name, info);
}
public unregister(name: string): void {
this.components.delete(name);
}
public unregister(name: string): void {
this.components.delete(name);
}
public getComponent(name: string): ComponentTypeInfo | undefined {
return this.components.get(name);
}
public getComponent(name: string): ComponentTypeInfo | undefined {
return this.components.get(name);
}
public getAllComponents(): ComponentTypeInfo[] {
return Array.from(this.components.values());
}
public getAllComponents(): ComponentTypeInfo[] {
return Array.from(this.components.values());
}
public getComponentsByCategory(category: string): ComponentTypeInfo[] {
return this.getAllComponents().filter(c => c.category === category);
}
public getComponentsByCategory(category: string): ComponentTypeInfo[] {
return this.getAllComponents().filter((c) => c.category === category);
}
public createInstance(name: string, ...args: any[]): Component | null {
const info = this.components.get(name);
if (!info || !info.type) return null;
public createInstance(name: string, ...args: any[]): Component | null {
const info = this.components.get(name);
if (!info || !info.type) return null;
return new info.type(...args);
}
return new info.type(...args);
}
}

View File

@@ -12,67 +12,67 @@ export interface EntityTreeNode {
*/
@Injectable()
export class EntityStoreService implements IService {
private entities: Map<number, Entity> = new Map();
private selectedEntity: Entity | null = null;
private rootEntities: Set<number> = new Set();
private entities: Map<number, Entity> = new Map();
private selectedEntity: Entity | null = null;
private rootEntities: Set<number> = new Set();
constructor(private messageHub: MessageHub) {}
constructor(private messageHub: MessageHub) {}
public dispose(): void {
this.entities.clear();
this.rootEntities.clear();
this.selectedEntity = null;
}
public addEntity(entity: Entity, parent?: Entity): void {
this.entities.set(entity.id, entity);
if (!parent) {
this.rootEntities.add(entity.id);
public dispose(): void {
this.entities.clear();
this.rootEntities.clear();
this.selectedEntity = null;
}
this.messageHub.publish('entity:added', { entity, parent });
}
public addEntity(entity: Entity, parent?: Entity): void {
this.entities.set(entity.id, entity);
public removeEntity(entity: Entity): void {
this.entities.delete(entity.id);
this.rootEntities.delete(entity.id);
if (!parent) {
this.rootEntities.add(entity.id);
}
if (this.selectedEntity?.id === entity.id) {
this.selectedEntity = null;
this.messageHub.publish('entity:selected', { entity: null });
this.messageHub.publish('entity:added', { entity, parent });
}
this.messageHub.publish('entity:removed', { entity });
}
public removeEntity(entity: Entity): void {
this.entities.delete(entity.id);
this.rootEntities.delete(entity.id);
public selectEntity(entity: Entity | null): void {
this.selectedEntity = entity;
this.messageHub.publish('entity:selected', { entity });
}
if (this.selectedEntity?.id === entity.id) {
this.selectedEntity = null;
this.messageHub.publish('entity:selected', { entity: null });
}
public getSelectedEntity(): Entity | null {
return this.selectedEntity;
}
this.messageHub.publish('entity:removed', { entity });
}
public getAllEntities(): Entity[] {
return Array.from(this.entities.values());
}
public selectEntity(entity: Entity | null): void {
this.selectedEntity = entity;
this.messageHub.publish('entity:selected', { entity });
}
public getRootEntities(): Entity[] {
return Array.from(this.rootEntities)
.map(id => this.entities.get(id))
.filter((e): e is Entity => e !== undefined);
}
public getSelectedEntity(): Entity | null {
return this.selectedEntity;
}
public getEntity(id: number): Entity | undefined {
return this.entities.get(id);
}
public getAllEntities(): Entity[] {
return Array.from(this.entities.values());
}
public clear(): void {
this.entities.clear();
this.rootEntities.clear();
this.selectedEntity = null;
this.messageHub.publish('entities:cleared', {});
}
public getRootEntities(): Entity[] {
return Array.from(this.rootEntities)
.map((id) => this.entities.get(id))
.filter((e): e is Entity => e !== undefined);
}
public getEntity(id: number): Entity | undefined {
return this.entities.get(id);
}
public clear(): void {
this.entities.clear();
this.rootEntities.clear();
this.selectedEntity = null;
this.messageHub.publish('entities:cleared', {});
}
}

View File

@@ -55,7 +55,7 @@ export class LocaleService implements IService {
this.currentLocale = locale;
this.saveLocale(locale);
this.changeListeners.forEach(listener => listener(locale));
this.changeListeners.forEach((listener) => listener(locale));
logger.info(`Locale changed to: ${locale}`);
}

View File

@@ -89,7 +89,7 @@ export class LogService implements IService {
* 格式化消息
*/
private formatMessage(args: unknown[]): string {
return args.map(arg => {
return args.map((arg) => {
if (typeof arg === 'string') return arg;
if (arg instanceof Error) return arg.message;
try {

View File

@@ -43,150 +43,150 @@ export interface SettingCategory {
@Injectable()
export class SettingsRegistry implements IService {
private categories: Map<string, SettingCategory> = new Map();
private categories: Map<string, SettingCategory> = new Map();
public dispose(): void {
this.categories.clear();
}
public registerCategory(category: SettingCategory): void {
if (this.categories.has(category.id)) {
console.warn(`[SettingsRegistry] Category ${category.id} already registered, overwriting`);
}
this.categories.set(category.id, category);
}
public registerSection(categoryId: string, section: SettingSection): void {
let category = this.categories.get(categoryId);
if (!category) {
category = {
id: categoryId,
title: categoryId,
sections: []
};
this.categories.set(categoryId, category);
public dispose(): void {
this.categories.clear();
}
const existingIndex = category.sections.findIndex(s => s.id === section.id);
if (existingIndex >= 0) {
category.sections[existingIndex] = section;
console.warn(`[SettingsRegistry] Section ${section.id} in category ${categoryId} already exists, overwriting`);
} else {
category.sections.push(section);
}
}
public registerSetting(categoryId: string, sectionId: string, setting: SettingDescriptor): void {
let category = this.categories.get(categoryId);
if (!category) {
category = {
id: categoryId,
title: categoryId,
sections: []
};
this.categories.set(categoryId, category);
}
let section = category.sections.find(s => s.id === sectionId);
if (!section) {
section = {
id: sectionId,
title: sectionId,
settings: []
};
category.sections.push(section);
}
const existingIndex = section.settings.findIndex(s => s.key === setting.key);
if (existingIndex >= 0) {
section.settings[existingIndex] = setting;
console.warn(`[SettingsRegistry] Setting ${setting.key} in section ${sectionId} already exists, overwriting`);
} else {
section.settings.push(setting);
}
}
public unregisterCategory(categoryId: string): void {
this.categories.delete(categoryId);
}
public unregisterSection(categoryId: string, sectionId: string): void {
const category = this.categories.get(categoryId);
if (category) {
category.sections = category.sections.filter(s => s.id !== sectionId);
if (category.sections.length === 0) {
this.categories.delete(categoryId);
}
}
}
public getCategory(categoryId: string): SettingCategory | undefined {
return this.categories.get(categoryId);
}
public getAllCategories(): SettingCategory[] {
return Array.from(this.categories.values());
}
public getSetting(categoryId: string, sectionId: string, key: string): SettingDescriptor | undefined {
const category = this.categories.get(categoryId);
if (!category) return undefined;
const section = category.sections.find(s => s.id === sectionId);
if (!section) return undefined;
return section.settings.find(s => s.key === key);
}
public getAllSettings(): Map<string, SettingDescriptor> {
const allSettings = new Map<string, SettingDescriptor>();
for (const category of this.categories.values()) {
for (const section of category.sections) {
for (const setting of section.settings) {
allSettings.set(setting.key, setting);
public registerCategory(category: SettingCategory): void {
if (this.categories.has(category.id)) {
console.warn(`[SettingsRegistry] Category ${category.id} already registered, overwriting`);
}
}
this.categories.set(category.id, category);
}
return allSettings;
}
public registerSection(categoryId: string, section: SettingSection): void {
let category = this.categories.get(categoryId);
public validateSetting(setting: SettingDescriptor, value: any): boolean {
if (setting.validator) {
return setting.validator.validate(value);
if (!category) {
category = {
id: categoryId,
title: categoryId,
sections: []
};
this.categories.set(categoryId, category);
}
const existingIndex = category.sections.findIndex((s) => s.id === section.id);
if (existingIndex >= 0) {
category.sections[existingIndex] = section;
console.warn(`[SettingsRegistry] Section ${section.id} in category ${categoryId} already exists, overwriting`);
} else {
category.sections.push(section);
}
}
switch (setting.type) {
case 'number':
if (typeof value !== 'number') return false;
if (setting.min !== undefined && value < setting.min) return false;
if (setting.max !== undefined && value > setting.max) return false;
return true;
public registerSetting(categoryId: string, sectionId: string, setting: SettingDescriptor): void {
let category = this.categories.get(categoryId);
case 'boolean':
return typeof value === 'boolean';
if (!category) {
category = {
id: categoryId,
title: categoryId,
sections: []
};
this.categories.set(categoryId, category);
}
case 'string':
return typeof value === 'string';
let section = category.sections.find((s) => s.id === sectionId);
if (!section) {
section = {
id: sectionId,
title: sectionId,
settings: []
};
category.sections.push(section);
}
case 'select':
if (!setting.options) return false;
return setting.options.some(opt => opt.value === value);
case 'range':
if (typeof value !== 'number') return false;
if (setting.min !== undefined && value < setting.min) return false;
if (setting.max !== undefined && value > setting.max) return false;
return true;
case 'color':
return typeof value === 'string' && /^#[0-9A-Fa-f]{6}$/.test(value);
default:
return true;
const existingIndex = section.settings.findIndex((s) => s.key === setting.key);
if (existingIndex >= 0) {
section.settings[existingIndex] = setting;
console.warn(`[SettingsRegistry] Setting ${setting.key} in section ${sectionId} already exists, overwriting`);
} else {
section.settings.push(setting);
}
}
public unregisterCategory(categoryId: string): void {
this.categories.delete(categoryId);
}
public unregisterSection(categoryId: string, sectionId: string): void {
const category = this.categories.get(categoryId);
if (category) {
category.sections = category.sections.filter((s) => s.id !== sectionId);
if (category.sections.length === 0) {
this.categories.delete(categoryId);
}
}
}
public getCategory(categoryId: string): SettingCategory | undefined {
return this.categories.get(categoryId);
}
public getAllCategories(): SettingCategory[] {
return Array.from(this.categories.values());
}
public getSetting(categoryId: string, sectionId: string, key: string): SettingDescriptor | undefined {
const category = this.categories.get(categoryId);
if (!category) return undefined;
const section = category.sections.find((s) => s.id === sectionId);
if (!section) return undefined;
return section.settings.find((s) => s.key === key);
}
public getAllSettings(): Map<string, SettingDescriptor> {
const allSettings = new Map<string, SettingDescriptor>();
for (const category of this.categories.values()) {
for (const section of category.sections) {
for (const setting of section.settings) {
allSettings.set(setting.key, setting);
}
}
}
return allSettings;
}
public validateSetting(setting: SettingDescriptor, value: any): boolean {
if (setting.validator) {
return setting.validator.validate(value);
}
switch (setting.type) {
case 'number':
if (typeof value !== 'number') return false;
if (setting.min !== undefined && value < setting.min) return false;
if (setting.max !== undefined && value > setting.max) return false;
return true;
case 'boolean':
return typeof value === 'boolean';
case 'string':
return typeof value === 'string';
case 'select':
if (!setting.options) return false;
return setting.options.some((opt) => opt.value === value);
case 'range':
if (typeof value !== 'number') return false;
if (setting.min !== undefined && value < setting.min) return false;
if (setting.max !== undefined && value > setting.max) return false;
return true;
case 'color':
return typeof value === 'string' && /^#[0-9A-Fa-f]{6}$/.test(value);
default:
return true;
}
}
}
}

View File

@@ -70,7 +70,7 @@ export class UIRegistry implements IService {
*/
public getChildMenus(parentId: string): MenuItem[] {
return this.getAllMenus()
.filter(item => item.parentId === parentId)
.filter((item) => item.parentId === parentId)
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
}
@@ -128,7 +128,7 @@ export class UIRegistry implements IService {
*/
public getToolbarItemsByGroup(groupId: string): ToolbarItem[] {
return this.getAllToolbarItems()
.filter(item => item.groupId === groupId)
.filter((item) => item.groupId === groupId)
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
}
@@ -186,7 +186,7 @@ export class UIRegistry implements IService {
*/
public getPanelsByPosition(position: string): PanelDescriptor[] {
return this.getAllPanels()
.filter(panel => panel.position === position)
.filter((panel) => panel.position === position)
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
}