refactor: 品牌重命名 + maxTokens 支持 + 设置面板简化
- CodeGuard → Code Purifier / 净码特工(displayName、命令、配置标题) - 新增 ai.maxTokens 配置项,所有 Provider 及 fixer 传入 maxTokens - AI 引擎增强:repairJsonEscapes + JSON 解析 fallback + 详细错误信息 - 设置面板规则管理改为文件级(list/delete .yaml),addRule 改为 AI 从 Markdown 生成 YAML - yaml-parser 简化:移除 config.yaml 的 enable/disable 过滤逻辑 - 审查报告面板:errorBanner 优先显示具体错误、lint 诊断显示 suggestion、移除 translatedDiagnostics 独立渲染 - merger 中 translatedDiagnostics 覆盖原始 lint 诊断 message/suggestion - HTML linter 配置项、测试用例重写、typescript-eslint 移入 dependencies
This commit is contained in:
+22
-2
@@ -1,20 +1,40 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { ESLint } from 'eslint';
|
||||
import js from '@eslint/js';
|
||||
import ts from 'typescript-eslint';
|
||||
import type { LinterAdapter, AdapterResult, LinterDiagnostic } from './adapter';
|
||||
|
||||
export class ESLintAdapter implements LinterAdapter {
|
||||
id = 'eslint';
|
||||
supportedLanguages = ['javascript', 'typescript'];
|
||||
|
||||
private static defaultConfig: any[] | null = null;
|
||||
|
||||
private static getDefaultConfig(): any[] {
|
||||
if (!ESLintAdapter.defaultConfig) {
|
||||
ESLintAdapter.defaultConfig = [
|
||||
js.configs.recommended,
|
||||
...ts.configs.recommended,
|
||||
];
|
||||
}
|
||||
return ESLintAdapter.defaultConfig;
|
||||
}
|
||||
|
||||
isAvailable(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async check(document: vscode.TextDocument, workingDir: string): Promise<AdapterResult> {
|
||||
try {
|
||||
const engine = new ESLint({ cwd: workingDir });
|
||||
const engine = new ESLint({
|
||||
cwd: workingDir,
|
||||
overrideConfigFile: true,
|
||||
overrideConfig: ESLintAdapter.getDefaultConfig(),
|
||||
});
|
||||
const ext = document.languageId === 'typescript' ? 'ts' : 'js';
|
||||
const isVirtual = document.uri.scheme === 'untitled';
|
||||
const results = await engine.lintText(document.getText(), {
|
||||
filePath: document.fileName || 'untitled.ts',
|
||||
filePath: isVirtual ? `untitled.${ext}` : document.fileName,
|
||||
});
|
||||
|
||||
const diagnostics: LinterDiagnostic[] = [];
|
||||
|
||||
Reference in New Issue
Block a user