feat: 创建项目配置=内置配置(三语注释)+ 设置面板帮助图标 + 快速开始三步文案重写 + 图标更新
This commit is contained in:
+3
-53
@@ -7,57 +7,7 @@ import ts from 'typescript-eslint';
|
||||
import type { LinterAdapter, AdapterResult, LinterDiagnostic } from './adapter';
|
||||
import { getEslintConfigPath } from '../config';
|
||||
import { t } from '../i18n/messages';
|
||||
|
||||
const extraRules: Record<string, 'error' | 'warn'> = {
|
||||
'eqeqeq': 'error',
|
||||
'no-eq-null': 'error',
|
||||
'no-self-compare': 'error',
|
||||
'no-promise-executor-return': 'error',
|
||||
'no-shadow': 'error',
|
||||
'no-unassigned-vars': 'error',
|
||||
'no-useless-assignment': 'error',
|
||||
'block-scoped-var': 'error',
|
||||
'default-case': 'error',
|
||||
'default-case-last': 'error',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unreachable-loop': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-var': 'error',
|
||||
'no-await-in-loop': 'warn',
|
||||
'prefer-template': 'warn',
|
||||
'prefer-object-spread': 'warn',
|
||||
'prefer-rest-params': 'warn',
|
||||
'prefer-spread': 'warn',
|
||||
'prefer-object-has-own': 'warn',
|
||||
'no-useless-concat': 'warn',
|
||||
'no-useless-return': 'warn',
|
||||
'no-useless-computed-key': 'warn',
|
||||
'no-useless-rename': 'warn',
|
||||
'no-param-reassign': 'warn',
|
||||
'no-return-assign': 'error',
|
||||
'no-throw-literal': 'error',
|
||||
'camelcase': 'warn',
|
||||
'new-cap': 'warn',
|
||||
'no-array-constructor': 'error',
|
||||
};
|
||||
|
||||
const extraTsRules: Record<string, 'error' | 'warn' | 'off'> = {
|
||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
||||
'@typescript-eslint/no-dynamic-delete': 'error',
|
||||
'@typescript-eslint/no-useless-empty-export': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': 'error',
|
||||
'@typescript-eslint/unified-signatures': 'error',
|
||||
'@typescript-eslint/no-extraneous-class': 'warn',
|
||||
'@typescript-eslint/no-useless-constructor': 'warn',
|
||||
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
|
||||
'@typescript-eslint/no-invalid-void-type': 'warn',
|
||||
'@typescript-eslint/prefer-literal-enum-member': 'warn',
|
||||
'@typescript-eslint/prefer-enum-initializers': 'warn',
|
||||
'no-shadow': 'off',
|
||||
'@typescript-eslint/no-shadow': 'error',
|
||||
'no-array-constructor': 'off',
|
||||
};
|
||||
import { eslintExtraRules, eslintExtraTsRules } from '../rules/builtin-rules';
|
||||
|
||||
const TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
|
||||
|
||||
@@ -126,8 +76,8 @@ export class ESLintAdapter implements LinterAdapter {
|
||||
ESLintAdapter.defaultConfig = [
|
||||
js.configs.recommended,
|
||||
...ts.configs.recommended,
|
||||
{ rules: extraRules },
|
||||
{ files: TS_FILES, rules: extraTsRules },
|
||||
{ rules: eslintExtraRules },
|
||||
{ files: TS_FILES, rules: eslintExtraTsRules },
|
||||
];
|
||||
}
|
||||
return ESLintAdapter.defaultConfig;
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { LinterAdapter, AdapterResult, LinterDiagnostic, Severity } from '.
|
||||
import { getSqlFluffConfigFile, getSqlFluffDialect } from '../config';
|
||||
import { t } from '../i18n/messages';
|
||||
import staticRules from '../rules/static-rules.json';
|
||||
import { BUILTIN_SQLFLUFF_RULES, buildBuiltinSqlfluffConfig } from '../rules/builtin-rules';
|
||||
|
||||
const DIALECT_MAP: Record<string, string> = {
|
||||
sql: 'oracle',
|
||||
@@ -20,19 +21,6 @@ const SUPPORTED_DIALECTS = [
|
||||
'soql', 'sparksql', 'sqlite', 'starrocks', 'teradata', 'trino', 'tsql', 'vertica',
|
||||
];
|
||||
|
||||
const BUILTIN_SQLFLUFF_RULES =
|
||||
'core,AM03,AM05,AM08,CV01,CV02,CV06,CV08,CV12,LT13,LT14,LT15,ST01,ST02,ST04,ST05,ST06,ST07,ST09,ST10,ST11,ST12,RF02,RF04,RF05,RF06';
|
||||
|
||||
function buildBuiltinConfig(dialect: string): string {
|
||||
return `[sqlfluff]
|
||||
rules = ${BUILTIN_SQLFLUFF_RULES}
|
||||
dialect = ${dialect}
|
||||
max_line_length = 80
|
||||
indent_unit = space
|
||||
tab_space_size = 4
|
||||
`;
|
||||
}
|
||||
|
||||
interface RuleEntry { id: string; description: string; tier?: string; }
|
||||
|
||||
const tierMap = new Map<string, string>();
|
||||
@@ -156,7 +144,7 @@ export class SqlFluffAdapter implements LinterAdapter {
|
||||
} else if (hasProjectSqlfluffConfig(workingDir)) {
|
||||
} else {
|
||||
tempConfigPath = path.join(os.tmpdir(), `vscode-code-reviewer-sqlfluff-${Date.now()}.cfg`);
|
||||
fs.writeFileSync(tempConfigPath, buildBuiltinConfig(cliDialect ?? fallbackDialect), 'utf-8');
|
||||
fs.writeFileSync(tempConfigPath, buildBuiltinSqlfluffConfig(cliDialect ?? fallbackDialect), 'utf-8');
|
||||
configPath = tempConfigPath;
|
||||
}
|
||||
|
||||
|
||||
+14
-44
@@ -3,7 +3,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import type { LinterAdapter, AdapterResult, LinterDiagnostic, Severity } from './adapter';
|
||||
import { getStylelintConfigPath } from '../config';
|
||||
import recommendedConfig from 'stylelint-config-recommended';
|
||||
import { stylelintExtraRules } from '../rules/builtin-rules';
|
||||
|
||||
const CONFIG_FILE_NAMES = [
|
||||
'.stylelintrc',
|
||||
@@ -16,48 +16,18 @@ const CONFIG_FILE_NAMES = [
|
||||
'stylelint.config.cjs',
|
||||
];
|
||||
|
||||
const extraRules: Record<string, unknown> = {
|
||||
'color-no-invalid-hex': true,
|
||||
'function-linear-gradient-no-nonstandard-direction': true,
|
||||
'function-no-unknown': true,
|
||||
'unit-no-unknown': true,
|
||||
'no-unknown-animations': true,
|
||||
'no-unknown-custom-media': true,
|
||||
'no-unknown-custom-properties': true,
|
||||
|
||||
'at-rule-no-vendor-prefix': true,
|
||||
'media-feature-name-no-vendor-prefix': true,
|
||||
'property-no-vendor-prefix': true,
|
||||
'selector-no-vendor-prefix': true,
|
||||
'value-no-vendor-prefix': true,
|
||||
|
||||
'color-hex-length': 'short',
|
||||
'color-function-notation': 'modern',
|
||||
'length-zero-no-unit': true,
|
||||
'selector-pseudo-element-colon-notation': 'double',
|
||||
'import-notation': 'string',
|
||||
'alpha-value-notation': 'number',
|
||||
'hue-degree-notation': 'angle',
|
||||
'keyframe-selector-notation': 'percentage',
|
||||
|
||||
'declaration-block-no-redundant-longhand-properties': true,
|
||||
'shorthand-property-no-redundant-values': true,
|
||||
'block-no-redundant-nested-style-rules': true,
|
||||
|
||||
'color-named': 'never',
|
||||
'font-family-name-quotes': 'always-where-required',
|
||||
|
||||
'number-max-precision': 4,
|
||||
'comment-whitespace-inside': 'always',
|
||||
};
|
||||
|
||||
const DEFAULT_CONFIG: Record<string, unknown> = {
|
||||
...(recommendedConfig as Record<string, unknown>),
|
||||
rules: {
|
||||
...((recommendedConfig as Record<string, unknown>).rules as Record<string, unknown>),
|
||||
...extraRules,
|
||||
},
|
||||
};
|
||||
async function getDefaultConfig(): Promise<Record<string, unknown>> {
|
||||
const mod = await import('stylelint-config-recommended');
|
||||
const recommendedConfig = (mod.default ?? mod) as Record<string, unknown>;
|
||||
const recommendedRules = (recommendedConfig.rules ?? {}) as Record<string, unknown>;
|
||||
return {
|
||||
...recommendedConfig,
|
||||
rules: {
|
||||
...recommendedRules,
|
||||
...stylelintExtraRules,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
interface LinterOptions {
|
||||
code?: string;
|
||||
@@ -121,7 +91,7 @@ export class StylelintAdapter implements LinterAdapter {
|
||||
if (globalPath && globalPath.trim() !== '') {
|
||||
lintOptions.configFile = globalPath;
|
||||
} else if (!hasExternalConfig(workingDir)) {
|
||||
lintOptions.config = DEFAULT_CONFIG;
|
||||
lintOptions.config = await getDefaultConfig();
|
||||
}
|
||||
|
||||
const result = await stylelint.lint(lintOptions);
|
||||
|
||||
+36
-31
@@ -193,29 +193,29 @@ const messages: Record<string, Record<Language, string>> = {
|
||||
ja: 'クイックスタート',
|
||||
},
|
||||
'setup.gettingStarted': {
|
||||
'zh-CN': '三步启用代码审核',
|
||||
en: '3 Steps to Enable Code Review',
|
||||
ja: '3ステップでコードレビューを有効化',
|
||||
'zh-CN': '三步开始使用',
|
||||
en: '3 Steps to Get Started',
|
||||
ja: '3ステップで使い始める',
|
||||
},
|
||||
'setup.step1': {
|
||||
'zh-CN': '安装插件后,<b>配置 AI 模型</b>及 API Key,激活智能审核能力',
|
||||
en: 'After installing, <b>configure AI model</b> and API Key to activate intelligent review',
|
||||
ja: 'インストール後、<b>AIモデル</b>とAPIキーを設定してインテリジェントレビューを有効化',
|
||||
'zh-CN': '插件已内置 <b>Linter 静态分析</b>,开箱即用,也可在共通规则中配置项目/全局规则',
|
||||
en: 'The extension includes <b>built-in Linter static analysis</b>, ready to use out of the box, and you can also configure project/global rules in Common Rules',
|
||||
ja: '拡張機能には<b>Linter静的解析</b>が組み込まれており、そのまま利用できるほか、共通ルールでプロジェクト/グローバルルールも設定できます',
|
||||
},
|
||||
'setup.step2': {
|
||||
'zh-CN': '启用 <b>自定义规则</b>,补充团队特有的编码规范',
|
||||
en: 'Enable <b>custom rules</b> to add team-specific coding standards',
|
||||
ja: '<b>カスタムルール</b>を有効にしてチーム固有のコーディング規約を追加',
|
||||
'zh-CN': '在 <b>自定义规则</b> 标签页导入团队编码规范,增强审查(可选)',
|
||||
en: 'Import team coding standards in the <b>Custom Rules</b> tab to enhance reviews (optional)',
|
||||
ja: '<b>カスタムルール</b>タブでチームのコーディング規約をインポート(任意)',
|
||||
},
|
||||
'setup.step3': {
|
||||
'zh-CN': '<b>保存并测试连接</b>,验证配置无误后即可触发审核',
|
||||
en: '<b>Save and test connection</b>, verify config then trigger review',
|
||||
ja: '<b>保存して接続テスト</b>、設定を確認してレビューを開始',
|
||||
'zh-CN': '配置 <b>AI 模型与 API Key</b> 并<b>保存并测试连接</b>,启用 AI 深度审查',
|
||||
en: 'Configure <b>AI model & API Key</b> and <b>save & test the connection</b> to enable deep AI review',
|
||||
ja: '<b>AIモデルとAPIキー</b>を設定し<b>保存して接続テスト</b>、AI詳細レビューを有効化',
|
||||
},
|
||||
'setup.step3Hint': {
|
||||
'zh-CN': '按 <b>Ctrl + Shift + R</b> 快捷键触发审核,结果实时显示在 <b>审核结果报告</b>页面中',
|
||||
en: 'Press <b>Ctrl + Shift + R</b> to trigger review, results appear in the <b>Review Report</b> panel',
|
||||
ja: '<b>Ctrl + Shift + R</b> でレビューを実行、結果は<b>レビューレポート</b>に表示',
|
||||
'zh-CN': '按 <b>Ctrl + Shift + R</b> 触发完整审核,结果实时显示在<b>审核结果报告</b>页面',
|
||||
en: 'Press <b>Ctrl + Shift + R</b> to run a full review, results appear in the <b>Review Report</b> panel',
|
||||
ja: '<b>Ctrl + Shift + R</b> で完全なレビューを実行、結果は<b>レビューレポート</b>に表示',
|
||||
},
|
||||
'setup.aiConnectionConfig': {
|
||||
'zh-CN': 'AI 连接配置',
|
||||
@@ -407,6 +407,11 @@ const messages: Record<string, Record<Language, string>> = {
|
||||
en: 'Auto-selects config by priority: Built-in < Global < Project',
|
||||
ja: '優先順位に従って自動選択: 組み込み < グローバル < プロジェクト',
|
||||
},
|
||||
'setup.adapter.modeLegendHelp': {
|
||||
'zh-CN': '三种配置来源的含义:\n· 内置规则:插件自带的规则集,开箱即用,无需配置\n· 全局配置:在 VS Code 设置中指定的文件路径,对所有项目生效\n· 项目配置:项目根目录下的配置文件,仅对当前项目生效\n\n优先级:内置 < 全局 < 项目,插件自动选择优先级最高的可用配置',
|
||||
en: 'What the three config sources mean:\n· Built-in rules: bundled with the extension, work out of the box\n· Global config: a file path set in VS Code settings, applies to all projects\n· Project config: a config file in the project root, applies to the current project only\n\nPriority: Built-in < Global < Project; the highest-priority available source is used',
|
||||
ja: '3つの設定ソースの意味:\n· 組み込みルール:拡張機能に同梱のルール、設定不要ですぐに使用可\n· グローバル設定:VS Code設定で指定したファイルパス、全プロジェクトに適用\n· プロジェクト設定:プロジェクト直下の設定ファイル、現在のプロジェクトのみに適用\n\n優先度:組み込み < グローバル < プロジェクト、利用可能な中で最優先のものを自動選択',
|
||||
},
|
||||
'setup.adapter.configYes': {
|
||||
'zh-CN': '已配置',
|
||||
en: 'Configured',
|
||||
@@ -507,40 +512,40 @@ const messages: Record<string, Record<Language, string>> = {
|
||||
en: 'Java (including Java code in JSP, e.g. <% ... %>)',
|
||||
ja: 'Java(JSP内のJavaコードを含む、例: <% ... %>)',
|
||||
},
|
||||
'setup.adapter.pmdGuide': {
|
||||
'zh-CN': '需要 Java 运行环境;项目根目录创建 ruleset.xml 或在设置中配置 pmd.rulesetPath',
|
||||
en: 'Requires Java runtime; create ruleset.xml in project root or set pmd.rulesetPath in settings',
|
||||
ja: 'Java実行環境が必要。プロジェクトルートにruleset.xmlを作成するか、設定でpmd.rulesetPathを設定してください',
|
||||
'setup.adapter.pmdHelp': {
|
||||
'zh-CN': 'PMD 由 Java 编写,需先安装 Java 运行环境(JDK 8+),否则无法执行。\n\n插件已内置一套 PMD 规则集(7 类 274 条),安装 Java 后即可开箱使用,无需额外配置。\n点击「创建项目配置」,会在项目根目录生成 ruleset.xml,内容与插件内置规则集完全一致(含每类规则的说明注释),方便查看与调整审查范围。\n保存文件即自动生效,无需重启。\n\n若多个项目共用同一份规则,可点「修改全局设置」,在 pmd.rulesetPath 中填写该文件路径',
|
||||
en: 'PMD is written in Java, so a Java runtime (JDK 8+) must be installed first.\n\nThe extension ships a built-in PMD ruleset (7 categories, 274 rules), usable right after installing Java.\nClick "Create Project Config" to generate ruleset.xml in the project root, identical to the built-in ruleset (including per-category comment descriptions) for review and adjustment.\nChanges take effect on save, no restart needed.\n\nTo share one ruleset across projects, click "Modify Global Settings" and set pmd.rulesetPath',
|
||||
ja: 'PMDはJava製のため、まずJava実行環境(JDK 8+)のインストールが必要です。\n\n拡張機能にはPMDルールセット(7カテゴリ・274ルール)が同梱されており、Java導入後すぐに利用できます。\n「プロジェクト設定を作成」をクリックすると、プロジェクト直下にruleset.xmlが生成されます。内容は組み込みルールセットと完全一致し(カテゴリごとの説明コメント付き)、確認・調整が可能です。\n保存後すぐに反映され、再起動は不要です。\n\n複数プロジェクトで同じルールを共有する場合、「グローバル設定を変更」でpmd.rulesetPathを設定してください',
|
||||
},
|
||||
'setup.adapter.sqlLanguages': {
|
||||
'zh-CN': 'SQL',
|
||||
en: 'SQL',
|
||||
ja: 'SQL',
|
||||
},
|
||||
'setup.adapter.sqlGuide': {
|
||||
'zh-CN': '需要 Python 环境和 sqlfluff;运行 pip install sqlfluff,项目根目录创建 .sqlfluff',
|
||||
en: 'Requires Python and sqlfluff; run pip install sqlfluff, create .sqlfluff in project root',
|
||||
ja: 'Python環境とsqlfluffが必要。pip install sqlfluff を実行し、プロジェクトルートに.sqlfluffを作成してください',
|
||||
'setup.adapter.sqlHelp': {
|
||||
'zh-CN': 'SQLFluff 是 Python 命令,需先安装 Python 环境与 sqlfluff(pip install sqlfluff),否则无法执行。\n\n插件已内置一套 SQLFluff 精选规则(26 项),安装后即可开箱使用,无需额外配置。\n点击「创建项目配置」,会在项目根目录生成 .sqlfluff,内容与插件内置配置一致(含每条规则的说明注释,以及 rules = all 的启用提示),方便查看与调整。\n保存文件即自动生效,无需重启。\n\n若多个项目共用同一份配置,可点「修改全局设置」填写全局路径',
|
||||
en: 'SQLFluff is a Python command; install Python and sqlfluff (pip install sqlfluff) first.\n\nThe extension ships built-in SQLFluff curated rules (26 items), usable right after install.\nClick "Create Project Config" to generate .sqlfluff in the project root, identical to the built-in config (including per-rule comment descriptions and a rules = all hint) for review and adjustment.\nChanges take effect on save, no restart needed.\n\nTo share one config across projects, click "Modify Global Settings" and set the global path',
|
||||
ja: 'SQLFluffはPython製コマンドのため、まずPython環境とsqlfluff(pip install sqlfluff)が必要です。\n\n拡張機能にはSQLFluff精選ルール(26項目)が同梱されており、インストール後すぐに利用できます。\n「プロジェクト設定を作成」をクリックすると、プロジェクト直下に.sqlfluffが生成されます。内容は組み込み設定と一致し(ルールごとの説明コメントとrules = allのヒント付き)、確認・調整が可能です。\n保存後すぐに反映され、再起動は不要です。\n\n複数プロジェクトで同じ設定を共有する場合、「グローバル設定を変更」でパスを設定してください',
|
||||
},
|
||||
'setup.adapter.eslintLanguages': {
|
||||
'zh-CN': 'JS, TS, JSX, TSX(含 JSP 中的 JavaScript 代码,例如<script>)',
|
||||
en: 'JS, TS, JSX, TSX (including JavaScript in JSP, e.g. <script>)',
|
||||
ja: 'JS, TS, JSX, TSX(JSP内のJavaScriptコードを含む、例: <script>)',
|
||||
},
|
||||
'setup.adapter.eslintGuide': {
|
||||
'zh-CN': '项目根目录创建 eslint.config.js 或在 VS Code 设置中配置 eslintConfigPath',
|
||||
en: 'Create eslint.config.js in project root or set eslintConfigPath in VS Code settings',
|
||||
ja: 'プロジェクトルートにeslint.config.jsを作成するか、VS Code設定でeslintConfigPathを設定してください',
|
||||
'setup.adapter.eslintHelp': {
|
||||
'zh-CN': 'ESLint 需项目先安装 eslint(npm install eslint),否则无法解析规则文件。\n\n插件已内置一套 ESLint 规则(基于 recommended),开箱即用,无需额外配置。\n点击「创建项目配置」,会在项目根目录生成 eslint.config.js,内容与插件内置规则一致(92 条 JS 规则,含逐条说明注释),零依赖即可运行。\n注意:生成文件仅包含 JS 内置规则;TS 项目如需 TS 专项规则,请自行安装 typescript-eslint 并按文件头注释示例追加。\n若多个项目共用同一份规则,可点「修改全局设置」,在 eslintConfigPath 中填写该文件路径',
|
||||
en: 'ESLint must be installed in the project first (npm install eslint).\n\nThe extension ships built-in ESLint rules (based on recommended), usable out of the box.\nClick "Create Project Config" to generate eslint.config.js in the project root, identical to the built-in rules (92 JS rules with per-rule comment descriptions), running with zero extra dependencies.\nNote: the generated file only contains JS built-in rules; for TypeScript-specific rules, install typescript-eslint and follow the example in the file header comment.\nTo share one config across projects, click "Modify Global Settings" and set eslintConfigPath',
|
||||
ja: 'プロジェクトで先にeslintをインストール(npm install eslint)しておく必要があります。\n\n拡張機能にはESLintルール(recommendedベース)が同梱されており、設定不要で利用できます。\n「プロジェクト設定を作成」をクリックすると、プロジェクト直下にeslint.config.jsが生成されます。内容は組み込みルールと一致し(JSルール92件・各ルールに説明コメント付き)、追加依存なしで動作します。\n注: 生成ファイルにはJS組み込みルールのみ含まれます。TS専用ルールが必要な場合は、typescript-eslintをインストールし、ファイル先頭のコメント例に従って追記してください。\n複数プロジェクトで同じルールを共有する場合、「グローバル設定を変更」でeslintConfigPathを設定してください',
|
||||
},
|
||||
'setup.adapter.stylelintLanguages': {
|
||||
'zh-CN': 'CSS, SCSS, Less(含 JSP 中的 CSS 代码,例如<style>)',
|
||||
en: 'CSS, SCSS, Less (including CSS in JSP, e.g. <style>)',
|
||||
ja: 'CSS, SCSS, Less(JSP内のCSSコードを含む、例: <style>)',
|
||||
},
|
||||
'setup.adapter.stylelintGuide': {
|
||||
'zh-CN': '项目根目录创建 .stylelintrc 或在 VS Code 设置中配置 stylelintConfigPath',
|
||||
en: 'Create .stylelintrc in project root or set stylelintConfigPath in VS Code settings',
|
||||
ja: 'プロジェクトルートに.stylelintrcを作成するか、VS Code設定でstylelintConfigPathを設定してください',
|
||||
'setup.adapter.stylelintHelp': {
|
||||
'zh-CN': 'Stylelint 需项目先安装 stylelint(npm install stylelint),否则无法解析规则文件。\n\n插件已内置一套 Stylelint 规则(基于 recommended),开箱即用,无需额外配置。\n点击「创建项目配置」,会在项目根目录生成 .stylelintrc.js,内容与插件内置规则一致(68 条,含逐条说明注释),零依赖即可运行。\n若多个项目共用同一份规则,可点「修改全局设置」,在 stylelintConfigPath 中填写该文件路径',
|
||||
en: 'Stylelint must be installed in the project first (npm install stylelint).\n\nThe extension ships built-in Stylelint rules (based on recommended), usable out of the box.\nClick "Create Project Config" to generate .stylelintrc.js in the project root, identical to the built-in rules (68 rules with per-rule comment descriptions), running with zero extra dependencies.\nTo share one config across projects, click "Modify Global Settings" and set stylelintConfigPath',
|
||||
ja: 'プロジェクトで先にstylelintをインストール(npm install stylelint)しておく必要があります。\n\n拡張機能にはStylelintルール(recommendedベース)が同梱されており、設定不要で利用できます。\n「プロジェクト設定を作成」をクリックすると、プロジェクト直下に.stylelintrc.jsが生成されます。内容は組み込みルールと一致し(68件・各ルールに説明コメント付き)、追加依存なしで動作します。\n複数プロジェクトで同じルールを共有する場合、「グローバル設定を変更」でstylelintConfigPathを設定してください',
|
||||
},
|
||||
'setup.aiReviewStatusCapability': {
|
||||
'zh-CN': '审查能力',
|
||||
|
||||
@@ -0,0 +1,371 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import js from '@eslint/js';
|
||||
import staticRules from './static-rules.json';
|
||||
import type { Language } from '../i18n/messages';
|
||||
|
||||
export const eslintExtraRules: Record<string, 'error' | 'warn'> = {
|
||||
'eqeqeq': 'error',
|
||||
'no-eq-null': 'error',
|
||||
'no-self-compare': 'error',
|
||||
'no-promise-executor-return': 'error',
|
||||
'no-shadow': 'error',
|
||||
'no-unassigned-vars': 'error',
|
||||
'no-useless-assignment': 'error',
|
||||
'block-scoped-var': 'error',
|
||||
'default-case': 'error',
|
||||
'default-case-last': 'error',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unreachable-loop': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-var': 'error',
|
||||
'no-await-in-loop': 'warn',
|
||||
'prefer-template': 'warn',
|
||||
'prefer-object-spread': 'warn',
|
||||
'prefer-rest-params': 'warn',
|
||||
'prefer-spread': 'warn',
|
||||
'prefer-object-has-own': 'warn',
|
||||
'no-useless-concat': 'warn',
|
||||
'no-useless-return': 'warn',
|
||||
'no-useless-computed-key': 'warn',
|
||||
'no-useless-rename': 'warn',
|
||||
'no-param-reassign': 'warn',
|
||||
'no-return-assign': 'error',
|
||||
'no-throw-literal': 'error',
|
||||
'camelcase': 'warn',
|
||||
'new-cap': 'warn',
|
||||
'no-array-constructor': 'error',
|
||||
};
|
||||
|
||||
export const eslintExtraTsRules: Record<string, 'error' | 'warn' | 'off'> = {
|
||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
||||
'@typescript-eslint/no-dynamic-delete': 'error',
|
||||
'@typescript-eslint/no-useless-empty-export': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': 'error',
|
||||
'@typescript-eslint/unified-signatures': 'error',
|
||||
'@typescript-eslint/no-extraneous-class': 'warn',
|
||||
'@typescript-eslint/no-useless-constructor': 'warn',
|
||||
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
|
||||
'@typescript-eslint/no-invalid-void-type': 'warn',
|
||||
'@typescript-eslint/prefer-literal-enum-member': 'warn',
|
||||
'@typescript-eslint/prefer-enum-initializers': 'warn',
|
||||
'no-shadow': 'off',
|
||||
'@typescript-eslint/no-shadow': 'error',
|
||||
'no-array-constructor': 'off',
|
||||
};
|
||||
|
||||
export const stylelintExtraRules: Record<string, unknown> = {
|
||||
'color-no-invalid-hex': true,
|
||||
'function-linear-gradient-no-nonstandard-direction': true,
|
||||
'function-no-unknown': true,
|
||||
'unit-no-unknown': true,
|
||||
'no-unknown-animations': true,
|
||||
'no-unknown-custom-media': true,
|
||||
'no-unknown-custom-properties': true,
|
||||
|
||||
'at-rule-no-vendor-prefix': true,
|
||||
'media-feature-name-no-vendor-prefix': true,
|
||||
'property-no-vendor-prefix': true,
|
||||
'selector-no-vendor-prefix': true,
|
||||
'value-no-vendor-prefix': true,
|
||||
|
||||
'color-hex-length': 'short',
|
||||
'color-function-notation': 'modern',
|
||||
'length-zero-no-unit': true,
|
||||
'selector-pseudo-element-colon-notation': 'double',
|
||||
'import-notation': 'string',
|
||||
'alpha-value-notation': 'number',
|
||||
'hue-degree-notation': 'angle',
|
||||
'keyframe-selector-notation': 'percentage',
|
||||
|
||||
'declaration-block-no-redundant-longhand-properties': true,
|
||||
'shorthand-property-no-redundant-values': true,
|
||||
'block-no-redundant-nested-style-rules': true,
|
||||
|
||||
'color-named': 'never',
|
||||
'font-family-name-quotes': 'always-where-required',
|
||||
|
||||
'number-max-precision': 4,
|
||||
'comment-whitespace-inside': 'always',
|
||||
};
|
||||
|
||||
export const BUILTIN_SQLFLUFF_RULES =
|
||||
'core,AM03,AM05,AM08,CV01,CV02,CV06,CV08,CV12,LT13,LT14,LT15,ST01,ST02,ST04,ST05,ST06,ST07,ST09,ST10,ST11,ST12,RF02,RF04,RF05,RF06';
|
||||
|
||||
export function buildBuiltinSqlfluffConfig(dialect: string): string {
|
||||
return `[sqlfluff]
|
||||
rules = ${BUILTIN_SQLFLUFF_RULES}
|
||||
dialect = ${dialect}
|
||||
max_line_length = 80
|
||||
indent_unit = space
|
||||
tab_space_size = 4
|
||||
`;
|
||||
}
|
||||
|
||||
interface StaticRuleEntry {
|
||||
id: string;
|
||||
description?: string;
|
||||
descriptionZh?: string;
|
||||
descriptionJa?: string;
|
||||
}
|
||||
|
||||
export function getRuleDescription(linter: string, ruleId: string, lang: Language): string | undefined {
|
||||
const section = staticRules.rules[linter as keyof typeof staticRules.rules] as StaticRuleEntry[] | undefined;
|
||||
if (!section) { return undefined; }
|
||||
const entry = section.find(r => r.id === `${linter}/${ruleId}`);
|
||||
if (!entry) { return undefined; }
|
||||
if (lang === 'zh-CN') { return entry.descriptionZh ?? entry.description; }
|
||||
if (lang === 'ja') { return entry.descriptionJa ?? entry.description; }
|
||||
return entry.description;
|
||||
}
|
||||
|
||||
const ESLINT_RULES_URL = 'https://eslint.org/docs/latest/rules/';
|
||||
const STYLELINT_RULES_URL = 'https://stylelint.io/user-guide/rules/';
|
||||
const SQLFLUFF_RULES_URL = 'https://docs.sqlfluff.com/en/stable/reference/rules.html';
|
||||
|
||||
interface HeaderLabels {
|
||||
projectConfig: (name: string) => string;
|
||||
howToAdd: string;
|
||||
addExample: string;
|
||||
addExampleStyle: string;
|
||||
allRules: string;
|
||||
dialect: string;
|
||||
enableAll: string;
|
||||
ruleList: string;
|
||||
excludePrefix: string;
|
||||
}
|
||||
|
||||
const HEADER: Record<Language, HeaderLabels> = {
|
||||
'zh-CN': {
|
||||
projectConfig: name => `项目配置 — 与插件内置 ${name} 规则一致(由插件生成)`,
|
||||
howToAdd: '如何添加规则:在 rules 中新增一行',
|
||||
addExample: "如 'rule-name': 'warn' 或 'rule-name': ['error', 'always']",
|
||||
addExampleStyle: "如 'indentation': 2 或 'rule-name': true",
|
||||
allRules: '全部可用规则:',
|
||||
dialect: '数据库方言:postgres / mysql / bigquery / snowflake 等',
|
||||
enableAll: '想启用全部规则时改为 → rules = all',
|
||||
ruleList: '内置精选规则清单:',
|
||||
excludePrefix: '排除:',
|
||||
},
|
||||
en: {
|
||||
projectConfig: name => `Project config — matches the extension's built-in ${name} rules (generated by the extension)`,
|
||||
howToAdd: 'To add a rule: add a line in rules',
|
||||
addExample: "e.g. 'rule-name': 'warn' or 'rule-name': ['error', 'always']",
|
||||
addExampleStyle: "e.g. 'indentation': 2 or 'rule-name': true",
|
||||
allRules: 'All available rules:',
|
||||
dialect: 'Database dialect: postgres / mysql / bigquery / snowflake etc.',
|
||||
enableAll: 'Change to rules = all to enable all rules',
|
||||
ruleList: 'Built-in curated rule list:',
|
||||
excludePrefix: 'Excluded: ',
|
||||
},
|
||||
ja: {
|
||||
projectConfig: name => `プロジェクト設定 — 拡張機能の組み込み${name}ルールと一致(拡張機能が生成)`,
|
||||
howToAdd: 'ルールを追加するには: rulesに1行追加します',
|
||||
addExample: "例: 'rule-name': 'warn' または 'rule-name': ['error', 'always']",
|
||||
addExampleStyle: "例: 'indentation': 2 または 'rule-name': true",
|
||||
allRules: '利用可能な全ルール: ',
|
||||
dialect: 'データベース方言: postgres / mysql / bigquery / snowflake など',
|
||||
enableAll: '全ルールを有効にする場合は rules = all に変更',
|
||||
ruleList: '組み込みの精選ルール一覧:',
|
||||
excludePrefix: '除外:',
|
||||
},
|
||||
};
|
||||
|
||||
const TS_NOTE: Record<Language, string[]> = {
|
||||
'zh-CN': [
|
||||
'注意:本文件仅包含 JS 内置规则;TS 项目如需 TS 专项规则,',
|
||||
' 请安装 typescript-eslint 后自行追加,例如:',
|
||||
" const ts = require('typescript-eslint');",
|
||||
' module.exports = [ ...本文件配置, ...ts.configs.recommended ];',
|
||||
],
|
||||
en: [
|
||||
'Note: this file only contains JS built-in rules. For TypeScript-specific rules,',
|
||||
' install typescript-eslint and extend, e.g.:',
|
||||
" const ts = require('typescript-eslint');",
|
||||
' module.exports = [ ...this config, ...ts.configs.recommended ];',
|
||||
],
|
||||
ja: [
|
||||
'注: このファイルはJS組み込みルールのみです。TS専用ルールが必要な場合は、',
|
||||
' typescript-eslintをインストールして追記してください。例:',
|
||||
" const ts = require('typescript-eslint');",
|
||||
' module.exports = [ ...本設定, ...ts.configs.recommended ];',
|
||||
],
|
||||
};
|
||||
|
||||
const PMD_CATEGORY_COMMENTS: Record<string, Record<Language, string>> = {
|
||||
bestpractices: {
|
||||
'zh-CN': '最佳实践类(避免空 catch、关闭流等)',
|
||||
en: 'Best practices (avoid empty catch, close streams, etc.)',
|
||||
ja: 'ベストプラクティス(空のcatch回避、ストリームクローズ等)',
|
||||
},
|
||||
codestyle: {
|
||||
'zh-CN': '代码风格类(命名规范、花括号位置等)',
|
||||
en: 'Code style (naming conventions, brace placement, etc.)',
|
||||
ja: 'コードスタイル(命名規則、ブレース位置等)',
|
||||
},
|
||||
design: {
|
||||
'zh-CN': '设计类(过度耦合、复杂度、设计缺陷等)',
|
||||
en: 'Design (over-coupling, complexity, design flaws, etc.)',
|
||||
ja: '設計(過度な結合、複雑度、設計上の欠陥等)',
|
||||
},
|
||||
errorprone: {
|
||||
'zh-CN': '易错类(空 catch、错误处理遗漏等)',
|
||||
en: 'Error-prone (empty catch, missed error handling, etc.)',
|
||||
ja: 'エラーを起こしやすい(空のcatch、エラー処理の見落とし等)',
|
||||
},
|
||||
multithreading: {
|
||||
'zh-CN': '多线程类(线程使用、并发问题等)',
|
||||
en: 'Multithreading (thread usage, concurrency issues, etc.)',
|
||||
ja: 'マルチスレッド(スレッド使用、並行性の問題等)',
|
||||
},
|
||||
performance: {
|
||||
'zh-CN': '性能类(重复对象创建、低效操作等)',
|
||||
en: 'Performance (repeated object creation, inefficient operations, etc.)',
|
||||
ja: 'パフォーマンス(オブジェクトの再生成、非効率な操作等)',
|
||||
},
|
||||
security: {
|
||||
'zh-CN': '安全类(不安全的编码实践等)',
|
||||
en: 'Security (unsafe coding practices, etc.)',
|
||||
ja: 'セキュリティ(安全でないコーディング慣行等)',
|
||||
},
|
||||
};
|
||||
|
||||
function extractPmdVersion(): string {
|
||||
const v = staticRules.linterVersion.pmd as string | undefined;
|
||||
const m = v?.match(/(\d+\.\d+\.\d+)/);
|
||||
return m ? m[1] : 'latest';
|
||||
}
|
||||
|
||||
function resolvePmdRulesetPath(): string {
|
||||
const candidates: string[] = [];
|
||||
try {
|
||||
const ext = vscode.extensions.getExtension?.('vscode-code-reviewer');
|
||||
if (ext?.extensionPath) {
|
||||
candidates.push(path.join(ext.extensionPath, 'jars', 'pmd', 'pmd-java-ruleset.xml'));
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
let dir = __dirname;
|
||||
for (let i = 0; i < 5; i++) {
|
||||
candidates.push(path.join(dir, 'jars', 'pmd', 'pmd-java-ruleset.xml'));
|
||||
dir = path.dirname(dir);
|
||||
}
|
||||
const found = candidates.find(p => fs.existsSync(p));
|
||||
if (found) { return found; }
|
||||
throw new Error(`PMD bundled ruleset not found: ${candidates.join(', ')}`);
|
||||
}
|
||||
|
||||
export function buildEslintProjectConfigText(lang: Language): string {
|
||||
const l = HEADER[lang];
|
||||
const jsRules = js.configs.recommended.rules as Record<string, unknown>;
|
||||
const rules: Array<[string, unknown]> = [...Object.entries(jsRules), ...Object.entries(eslintExtraRules)];
|
||||
const body = rules.map(([id, sev]) => {
|
||||
const desc = getRuleDescription('eslint', id, lang);
|
||||
return ` '${id}': ${JSON.stringify(sev)},${desc ? ` // ${desc}` : ''}`;
|
||||
});
|
||||
const lines = [
|
||||
'/* global module */',
|
||||
'// ============================================================',
|
||||
`// ${l.projectConfig('ESLint')}`,
|
||||
`// ${l.howToAdd}`,
|
||||
`// ${l.addExample}`,
|
||||
`// ${l.allRules}${ESLINT_RULES_URL}`,
|
||||
...TS_NOTE[lang].map(n => `// ${n}`),
|
||||
'// ============================================================',
|
||||
'module.exports = [',
|
||||
' {',
|
||||
' rules: {',
|
||||
...body,
|
||||
' },',
|
||||
' },',
|
||||
'];',
|
||||
'',
|
||||
];
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export async function buildStylelintProjectConfigText(lang: Language): Promise<string> {
|
||||
const l = HEADER[lang];
|
||||
const rec = (await import('stylelint-config-recommended')).default;
|
||||
const rules: Record<string, unknown> = { ...rec.rules, ...stylelintExtraRules };
|
||||
const body = Object.entries(rules).map(([id, val]) => {
|
||||
const desc = getRuleDescription('stylelint', id, lang);
|
||||
return ` '${id}': ${JSON.stringify(val)},${desc ? ` // ${desc}` : ''}`;
|
||||
});
|
||||
const lines = [
|
||||
'/* global module */',
|
||||
'// ============================================================',
|
||||
`// ${l.projectConfig('Stylelint')}`,
|
||||
`// ${l.howToAdd}`,
|
||||
`// ${l.addExampleStyle}`,
|
||||
`// ${l.allRules}${STYLELINT_RULES_URL}`,
|
||||
'// ============================================================',
|
||||
'module.exports = {',
|
||||
' rules: {',
|
||||
...body,
|
||||
' },',
|
||||
'};',
|
||||
'',
|
||||
];
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function buildSqlfluffProjectConfigText(dialect: string, lang: Language): string {
|
||||
const l = HEADER[lang];
|
||||
const ruleIds = BUILTIN_SQLFLUFF_RULES.split(',');
|
||||
const ruleComments = ruleIds.map(id => {
|
||||
const desc = getRuleDescription('sqlfluff', id, lang);
|
||||
return `# ${id} ${desc ?? ''}`;
|
||||
});
|
||||
const lines = [
|
||||
'[sqlfluff]',
|
||||
`# ${l.dialect}`,
|
||||
`dialect = ${dialect}`,
|
||||
`# ${l.enableAll}`,
|
||||
`# ${l.ruleList}`,
|
||||
...ruleComments,
|
||||
`# ${l.allRules}${SQLFLUFF_RULES_URL}`,
|
||||
`rules = ${BUILTIN_SQLFLUFF_RULES}`,
|
||||
'max_line_length = 80',
|
||||
'indent_unit = space',
|
||||
'tab_space_size = 4',
|
||||
'',
|
||||
];
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export async function buildPmdProjectRulesetText(lang: Language): Promise<string> {
|
||||
const l = HEADER[lang];
|
||||
const rulesetPath = resolvePmdRulesetPath();
|
||||
const content = await fs.promises.readFile(rulesetPath, 'utf-8');
|
||||
const allRulesUrl = `https://docs.pmd-code.org/pmd-doc-${extractPmdVersion()}/pmd_rules_java.html`;
|
||||
const out: string[] = [];
|
||||
for (const line of content.split('\n')) {
|
||||
if (/<description>/.test(line)) {
|
||||
out.push(line);
|
||||
out.push(` <!-- ${l.allRules}${allRulesUrl} -->`);
|
||||
continue;
|
||||
}
|
||||
const ruleRefMatch = line.match(/<rule ref="category\/java\/(\w+)\.xml"/);
|
||||
if (ruleRefMatch) {
|
||||
const cat = ruleRefMatch[1];
|
||||
const comment = PMD_CATEGORY_COMMENTS[cat]?.[lang] ?? cat;
|
||||
out.push(` <!-- ${comment} -->`);
|
||||
out.push(line);
|
||||
continue;
|
||||
}
|
||||
const excludeMatch = line.match(/<exclude name="([A-Za-z0-9_]+)"\/>/);
|
||||
if (excludeMatch) {
|
||||
const name = excludeMatch[1];
|
||||
const desc = getRuleDescription('pmd', name, lang);
|
||||
if (desc) {
|
||||
out.push(` <!-- ${l.excludePrefix}${desc} -->`);
|
||||
}
|
||||
out.push(line);
|
||||
continue;
|
||||
}
|
||||
out.push(line);
|
||||
}
|
||||
return out.join('\n');
|
||||
}
|
||||
@@ -984,6 +984,210 @@
|
||||
"description": "Require or disallow whitespace inside comments",
|
||||
"descriptionZh": "要求或禁止注释内部空白",
|
||||
"descriptionJa": "コメント内の空白を要求または禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/annotation-no-unknown",
|
||||
"description": "Disallow unknown annotations",
|
||||
"descriptionZh": "禁止未知注解",
|
||||
"descriptionJa": "未知の注釈を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/at-rule-descriptor-no-unknown",
|
||||
"description": "Disallow unknown descriptors within at-rules",
|
||||
"descriptionZh": "禁止 @ 规则中的未知描述符",
|
||||
"descriptionJa": "@規則内の未知のディスクリプタを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/at-rule-descriptor-value-no-unknown",
|
||||
"description": "Disallow unknown values for at-rule descriptors",
|
||||
"descriptionZh": "禁止 @ 规则描述符的未知值",
|
||||
"descriptionJa": "@規則のディスクリプタの未知の値を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/at-rule-no-deprecated",
|
||||
"description": "Disallow deprecated at-rules",
|
||||
"descriptionZh": "禁止已弃用的 @ 规则",
|
||||
"descriptionJa": "非推奨の@規則を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/at-rule-no-unknown",
|
||||
"description": "Disallow unknown at-rules",
|
||||
"descriptionZh": "禁止未知的 @ 规则",
|
||||
"descriptionJa": "未知の@規則を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/at-rule-prelude-no-invalid",
|
||||
"description": "Disallow invalid at-rule preludes",
|
||||
"descriptionZh": "禁止无效的 @ 规则前奏",
|
||||
"descriptionJa": "無効な@規則のプレリュードを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/comment-no-empty",
|
||||
"description": "Disallow empty comments",
|
||||
"descriptionZh": "禁止空注释",
|
||||
"descriptionJa": "空のコメントを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/custom-property-no-missing-var-function",
|
||||
"description": "Disallow custom properties that do not use the var() function",
|
||||
"descriptionZh": "禁止未使用 var() 函数的自定义属性",
|
||||
"descriptionJa": "var()関数を使用しないカスタムプロパティを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/declaration-block-no-duplicate-custom-properties",
|
||||
"description": "Disallow duplicate custom properties within declaration blocks",
|
||||
"descriptionZh": "禁止声明块中的重复自定义属性",
|
||||
"descriptionJa": "宣言ブロック内の重複したカスタムプロパティを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/declaration-block-no-shorthand-property-overrides",
|
||||
"description": "Disallow shorthand properties that override related longhand properties",
|
||||
"descriptionZh": "禁止覆盖相关长写属性的简写属性",
|
||||
"descriptionJa": "関連するロングハンドプロパティを上書きするショートハンドを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/declaration-property-value-keyword-no-deprecated",
|
||||
"description": "Disallow deprecated keyword values within declarations",
|
||||
"descriptionZh": "禁止声明中的已弃用关键字值",
|
||||
"descriptionJa": "宣言内の非推奨のキーワード値を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/declaration-property-value-no-unknown",
|
||||
"description": "Disallow unknown values for properties within declarations",
|
||||
"descriptionZh": "禁止声明中属性的未知值",
|
||||
"descriptionJa": "宣言内のプロパティの未知の値を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/font-family-no-duplicate-names",
|
||||
"description": "Disallow duplicate font family names",
|
||||
"descriptionZh": "禁止重复的字体族名称",
|
||||
"descriptionJa": "重複したフォントファミリ名を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/function-calc-no-unspaced-operator",
|
||||
"description": "Disallow unspaced operators within calc functions",
|
||||
"descriptionZh": "禁止 calc 函数中运算符两侧无空格",
|
||||
"descriptionJa": "calc関数内で演算子の前後にスペースがないことを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/keyframe-block-no-duplicate-selectors",
|
||||
"description": "Disallow duplicate selectors within keyframe blocks",
|
||||
"descriptionZh": "禁止关键帧块中的重复选择器",
|
||||
"descriptionJa": "キーフレームブロック内の重複セレクタを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/keyframe-declaration-no-important",
|
||||
"description": "Disallow !important within keyframe declarations",
|
||||
"descriptionZh": "禁止关键帧声明中的 !important",
|
||||
"descriptionJa": "キーフレーム宣言内の!importantを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/media-feature-name-no-unknown",
|
||||
"description": "Disallow unknown media feature names",
|
||||
"descriptionZh": "禁止未知的媒体特性名称",
|
||||
"descriptionJa": "未知のメディア特性名を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/media-feature-name-value-no-unknown",
|
||||
"description": "Disallow unknown values for media features",
|
||||
"descriptionZh": "禁止媒体特性的未知值",
|
||||
"descriptionJa": "メディア特性の未知の値を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/media-query-no-invalid",
|
||||
"description": "Disallow invalid media queries",
|
||||
"descriptionZh": "禁止无效的媒体查询",
|
||||
"descriptionJa": "無効なメディアクエリを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/media-type-no-deprecated",
|
||||
"description": "Disallow deprecated media types",
|
||||
"descriptionZh": "禁止已弃用的媒体类型",
|
||||
"descriptionJa": "非推奨のメディアタイプを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/named-grid-areas-no-invalid",
|
||||
"description": "Disallow invalid named grid areas",
|
||||
"descriptionZh": "禁止无效的命名网格区域",
|
||||
"descriptionJa": "無効な名前付きグリッドエリアを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/nesting-selector-no-missing-scoping-root",
|
||||
"description": "Disallow nesting selectors without a scoping root",
|
||||
"descriptionZh": "禁止无作用域根的嵌套选择器",
|
||||
"descriptionJa": "スコープルートのないネストセレクタを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/no-duplicate-at-import-rules",
|
||||
"description": "Disallow duplicate @import rules",
|
||||
"descriptionZh": "禁止重复的 @import 规则",
|
||||
"descriptionJa": "重複した@import規則を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/no-duplicate-selectors",
|
||||
"description": "Disallow duplicate selectors within a stylesheet",
|
||||
"descriptionZh": "禁止样式表中重复的选择器",
|
||||
"descriptionJa": "スタイルシート内の重複セレクタを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/no-empty-source",
|
||||
"description": "Disallow empty sources",
|
||||
"descriptionZh": "禁止空样式源",
|
||||
"descriptionJa": "空のスタイルシートを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/no-invalid-double-slash-comments",
|
||||
"description": "Disallow invalid double-slash comments",
|
||||
"descriptionZh": "禁止无效的双斜杠注释",
|
||||
"descriptionJa": "無効なダブルスラッシュコメントを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/no-invalid-position-at-import-rule",
|
||||
"description": "Disallow invalid positions of @import rules",
|
||||
"descriptionZh": "禁止 @import 规则位于无效位置",
|
||||
"descriptionJa": "@import規則の無効な位置を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/no-invalid-position-declaration",
|
||||
"description": "Disallow invalid positions of declarations",
|
||||
"descriptionZh": "禁止声明位于无效位置",
|
||||
"descriptionJa": "宣言の無効な位置を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/no-irregular-whitespace",
|
||||
"description": "Disallow irregular whitespace",
|
||||
"descriptionZh": "禁止不规则空白",
|
||||
"descriptionJa": "不規則な空白を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/property-no-deprecated",
|
||||
"description": "Disallow deprecated properties",
|
||||
"descriptionZh": "禁止已弃用的属性",
|
||||
"descriptionJa": "非推奨のプロパティを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/selector-anb-no-unmatchable",
|
||||
"description": "Disallow unmatchable An+B selectors",
|
||||
"descriptionZh": "禁止无法匹配的 An+B 选择器",
|
||||
"descriptionJa": "マッチしないAn+Bセレクタを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/selector-type-no-unknown",
|
||||
"description": "Disallow unknown type selectors",
|
||||
"descriptionZh": "禁止未知的类型选择器",
|
||||
"descriptionJa": "未知のタイプセレクタを禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/string-no-newline",
|
||||
"description": "Disallow newlines within strings",
|
||||
"descriptionZh": "禁止字符串中的换行",
|
||||
"descriptionJa": "文字列内の改行を禁止する"
|
||||
},
|
||||
{
|
||||
"id": "stylelint/syntax-string-no-invalid",
|
||||
"description": "Disallow invalid strings",
|
||||
"descriptionZh": "禁止无效字符串",
|
||||
"descriptionJa": "無効な文字列を禁止する"
|
||||
}
|
||||
],
|
||||
"pmd": [
|
||||
@@ -2624,6 +2828,138 @@
|
||||
"description": "Don't hard code initialization vectors",
|
||||
"descriptionZh": "不要硬编码初始化向量",
|
||||
"descriptionJa": "初期化ベクタをハードコードしない"
|
||||
},
|
||||
{
|
||||
"id": "pmd/DefaultLabelNotLastInSwitchStmt",
|
||||
"description": "Allow the default case to appear at any position in a switch statement",
|
||||
"descriptionZh": "允许 default 分支出现在 switch 语句中的任意位置",
|
||||
"descriptionJa": "default ケースが switch 文内の任意の位置にあることを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/JUnit4TestShouldUseAfterAnnotation",
|
||||
"description": "Allow @After annotation instead of tearDown()",
|
||||
"descriptionZh": "允许使用 @After 注解替代 tearDown()",
|
||||
"descriptionJa": "@After アノテーションの使用を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/JUnit4TestShouldUseBeforeAnnotation",
|
||||
"description": "Allow @Before annotation instead of setUp()",
|
||||
"descriptionZh": "允许使用 @Before 注解替代 setUp()",
|
||||
"descriptionJa": "@Before アノテーションの使用を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/JUnit4TestShouldUseTestAnnotation",
|
||||
"description": "Allow JUnit 3 test methods instead of @Test annotation",
|
||||
"descriptionZh": "允许 JUnit3 风格测试方法替代 @Test 注解",
|
||||
"descriptionJa": "@Test アノテーションの代わりに JUnit3 スタイルのテストメソッドを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/JUnit5TestShouldBePackagePrivate",
|
||||
"description": "Allow public JUnit 5 test methods",
|
||||
"descriptionZh": "允许 public 的 JUnit5 测试方法",
|
||||
"descriptionJa": "public な JUnit5 テストメソッドを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/JUnitAssertionsShouldIncludeMessage",
|
||||
"description": "Allow assertions without a message",
|
||||
"descriptionZh": "允许不带消息的断言",
|
||||
"descriptionJa": "メッセージなしのアサーションを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/JUnitTestContainsTooManyAsserts",
|
||||
"description": "Allow many assertions in a single test method",
|
||||
"descriptionZh": "允许单个测试方法中包含多个断言",
|
||||
"descriptionJa": "単一テストメソッド内の複数アサーションを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/JUnitTestsShouldIncludeAssert",
|
||||
"description": "Allow test methods without assertions",
|
||||
"descriptionZh": "允许不含断言的测试方法",
|
||||
"descriptionJa": "アサーションを含まないテストメソッドを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/SwitchStmtsShouldHaveDefault",
|
||||
"description": "Allow switch statements without a default case",
|
||||
"descriptionZh": "允许不带 default 分支的 switch 语句",
|
||||
"descriptionJa": "default ケースのない switch 文を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/GenericsNaming",
|
||||
"description": "Allow non-canonical generic type naming",
|
||||
"descriptionZh": "允许非规范的泛型类型命名",
|
||||
"descriptionJa": "非標準的なジェネリクス型命名を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/UnnecessaryLocalBeforeReturn",
|
||||
"description": "Allow local variables that are returned immediately",
|
||||
"descriptionZh": "允许先赋值后立即返回的局部变量",
|
||||
"descriptionJa": "即座に返すだけのローカル変数を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/ShortVariable",
|
||||
"description": "Allow short variable names",
|
||||
"descriptionZh": "允许短变量名",
|
||||
"descriptionJa": "短い変数名を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/ShortMethodName",
|
||||
"description": "Allow short method names",
|
||||
"descriptionZh": "允许短方法名",
|
||||
"descriptionJa": "短いメソッド名を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/ShortClassName",
|
||||
"description": "Allow short class names",
|
||||
"descriptionZh": "允许短类名",
|
||||
"descriptionJa": "短いクラス名を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/UseObjectForClearerAPI",
|
||||
"description": "Allow multiple primitive parameters in public methods",
|
||||
"descriptionZh": "允许公共方法中使用多个原始类型参数",
|
||||
"descriptionJa": "公開メソッドでの複数のプリミティブ引数を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/AvoidCatchingNPE",
|
||||
"description": "Allow catching NullPointerException",
|
||||
"descriptionZh": "允许捕获 NullPointerException",
|
||||
"descriptionJa": "NullPointerException の捕捉を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/AvoidCatchingThrowable",
|
||||
"description": "Allow catching Throwable",
|
||||
"descriptionZh": "允许捕获 Throwable",
|
||||
"descriptionJa": "Throwable の捕捉を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/AvoidLosingExceptionInformation",
|
||||
"description": "Allow catching exceptions without preserving information",
|
||||
"descriptionZh": "允许丢失异常信息的异常捕获",
|
||||
"descriptionJa": "例外情報を失う捕捉を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/DontImportSun",
|
||||
"description": "Allow imports from the sun package",
|
||||
"descriptionZh": "允许导入 sun 包",
|
||||
"descriptionJa": "sun パッケージのインポートを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/NonCaseLabelInSwitchStatement",
|
||||
"description": "Allow non-case labels in switch statements",
|
||||
"descriptionZh": "允许 switch 语句中的非 case 标签",
|
||||
"descriptionJa": "switch 文内の case 以外のラベルを許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/UselessOperationOnImmutable",
|
||||
"description": "Allow operations on immutable objects",
|
||||
"descriptionZh": "允许对不可变对象执行操作",
|
||||
"descriptionJa": "不変オブジェクトへの操作を許可"
|
||||
},
|
||||
{
|
||||
"id": "pmd/TooFewBranchesForASwitchStatement",
|
||||
"description": "Allow switch statements with only one branch",
|
||||
"descriptionZh": "允许仅有一个分支的 switch 语句",
|
||||
"descriptionJa": "1つの分岐のみの switch 文を許可"
|
||||
}
|
||||
],
|
||||
"pmd-jsp": [
|
||||
@@ -3213,6 +3549,12 @@
|
||||
"tier": "P2",
|
||||
"descriptionZh": "移除空批次",
|
||||
"descriptionJa": "空のバッチを削除する"
|
||||
},
|
||||
{
|
||||
"id": "sqlfluff/core",
|
||||
"description": "Core rule group (stable, cross-dialect, syntax-related foundational rules)",
|
||||
"descriptionZh": "核心规则组(稳定、跨方言的语法类基础规则)",
|
||||
"descriptionJa": "コアルールグループ(安定、方言横断的な構文系の基本ルール)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+19
-3
@@ -90,6 +90,10 @@
|
||||
return d.innerHTML;
|
||||
}
|
||||
|
||||
function escapeAttr(text) {
|
||||
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function populateModelOptions(providerId, currentModel) {
|
||||
var input = document.getElementById('modelInput');
|
||||
if (!input) { return; }
|
||||
@@ -186,7 +190,7 @@
|
||||
ruleList.innerHTML = '<div style="font-size:12px;color:#484f58;padding:8px 0;text-align:center;">' + msg.i18n.noRuleFiles + '</div>';
|
||||
}
|
||||
|
||||
_step1Done = c.provider && c.model && c.apiKeyConfigured && c.baseUrlConfigured;
|
||||
_step1Done = msg.adapterStatus && msg.adapterStatus.some(function (a) { return a.enabled; });
|
||||
_step2Done = msg.ruleFiles && msg.ruleFiles.length > 0;
|
||||
updateSteps(msg.connectionTested && msg.connectionSuccess);
|
||||
|
||||
@@ -256,10 +260,23 @@
|
||||
var toggleTooltip = a.enabled
|
||||
? i18n.toggleDisable.replace('{0}', a.name)
|
||||
: i18n.toggleEnable.replace('{0}', a.name);
|
||||
var helpMap = {
|
||||
pmd: i18n.pmdHelp,
|
||||
sqlfluff: i18n.sqlHelp,
|
||||
eslint: i18n.eslintHelp,
|
||||
stylelint: i18n.stylelintHelp,
|
||||
};
|
||||
var helpText = helpMap[a.id] || '';
|
||||
var helpIcon = helpText
|
||||
? '<span class="help-icon" data-help="' + escapeAttr(helpText) + '">?</span>'
|
||||
: '';
|
||||
|
||||
return '<div class="adapter-card' + (a.enabled ? '' : ' disabled') + '">' +
|
||||
'<div class="adapter-card-header">' +
|
||||
'<span class="adapter-card-name">' + a.name + '</span>' +
|
||||
'<span class="adapter-card-name-wrap">' +
|
||||
'<span class="adapter-card-name">' + a.name + '</span>' +
|
||||
helpIcon +
|
||||
'</span>' +
|
||||
'<div class="adapter-toggle' + (a.enabled ? '' : ' off') + '" data-adapter-id="' + a.id + '" data-tooltip="' + toggleTooltip + '"></div>' +
|
||||
'</div>' +
|
||||
'<div class="adapter-badges">' +
|
||||
@@ -268,7 +285,6 @@
|
||||
configBadge +
|
||||
'</div>' +
|
||||
'<div class="adapter-languages"><span class="adapter-lang-label">' + i18n.langLabel + '</span>' + escapeHtml(a.languages) + '</div>' +
|
||||
'<div class="adapter-guide">' + a.guideText + '</div>' +
|
||||
'<div class="adapter-actions">' +
|
||||
'<button class="adapter-btn" data-action="openAdapterConfig" data-adapter-id="' + a.id + '" data-tooltip="' + i18n.tooltipCreate.replace('{0}', a.projectConfigFileName) + '">' + i18n.btnCreateConfig + '</button>' +
|
||||
'<button class="adapter-btn" data-action="openSettings" data-settings-target="' + a.settingsTarget + '" data-tooltip="' + i18n.tooltipEdit + '">' + i18n.btnEditGlobal + '</button>' +
|
||||
|
||||
+63
-56
@@ -15,8 +15,14 @@ import { TxtConverter } from '../rules/converters/txt-converter';
|
||||
import { ExcelConverter } from '../rules/converters/excel-converter';
|
||||
import { DocxConverter } from '../rules/converters/docx-converter';
|
||||
import { PptxConverter } from '../rules/converters/pptx-converter';
|
||||
import { t, onLanguageChange } from '../i18n/messages';
|
||||
import { t, getLanguage, onLanguageChange } from '../i18n/messages';
|
||||
import { getEslintConfigPath, getStylelintConfigPath, getPMDRulesetPath, getSqlFluffConfigFile, isAdapterEnabled, setAdapterEnabled } from '../config/linter';
|
||||
import {
|
||||
buildEslintProjectConfigText,
|
||||
buildStylelintProjectConfigText,
|
||||
buildSqlfluffProjectConfigText,
|
||||
buildPmdProjectRulesetText,
|
||||
} from '../rules/builtin-rules';
|
||||
|
||||
type ConfigMode = 'builtin' | 'project' | 'global';
|
||||
|
||||
@@ -30,55 +36,12 @@ interface AdapterConfigStatus {
|
||||
dependencyStatus: DependencyStatus;
|
||||
dependencyLabel?: string;
|
||||
configured: boolean;
|
||||
guideText: string;
|
||||
languages: string;
|
||||
projectConfigFileName: string;
|
||||
settingsTarget: string;
|
||||
}
|
||||
|
||||
function getPmdRulesetTemplate(): string {
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||
<description>Custom PMD Ruleset</description>
|
||||
<!-- ${t('setup.template.pmdBestPractices')} -->
|
||||
<rule ref="category/java/bestpractices.xml" />
|
||||
<!-- ${t('setup.template.pmdCodeStyle')} -->
|
||||
<rule ref="category/java/codestyle.xml" />
|
||||
</ruleset>`;
|
||||
}
|
||||
|
||||
function getSqlfluffTemplate(): string {
|
||||
return `[sqlfluff]
|
||||
# ${t('setup.template.sqlfluffDialect')}
|
||||
dialect = mysql
|
||||
# ${t('setup.template.sqlfluffRules')}
|
||||
rules = all`;
|
||||
}
|
||||
|
||||
function getEslintTemplate(): string {
|
||||
return `module.exports = [
|
||||
{
|
||||
languageOptions: { ecmaVersion: 2022, sourceType: 'module' },
|
||||
rules: {
|
||||
'no-unused-vars': 'warn', // ${t('setup.template.eslintComment1')}
|
||||
'no-console': 'off', // ${t('setup.template.eslintComment2')}
|
||||
'semi': ['error', 'always'], // ${t('setup.template.eslintComment3')}
|
||||
},
|
||||
},
|
||||
];`;
|
||||
}
|
||||
|
||||
function getStylelintTemplate(): string {
|
||||
return `module.exports = {
|
||||
extends: 'stylelint-config-standard',
|
||||
rules: {
|
||||
'indentation': 2, // ${t('setup.template.stylelintComment1')}
|
||||
'no-empty': true, // ${t('setup.template.stylelintComment2')}
|
||||
},
|
||||
};`;
|
||||
}
|
||||
const SQLFLUFF_CONFIG_DIALECT = 'mysql';
|
||||
|
||||
const ADAPTER_METADATA: Record<string, {
|
||||
name: string;
|
||||
@@ -86,7 +49,7 @@ const ADAPTER_METADATA: Record<string, {
|
||||
settingsTarget: string;
|
||||
hasExternalDependency: boolean;
|
||||
dependencyLabel?: string;
|
||||
configFileTemplate: () => string;
|
||||
configFileTemplate: () => string | Promise<string>;
|
||||
i18nKey: string;
|
||||
}> = {
|
||||
pmd: {
|
||||
@@ -95,7 +58,7 @@ const ADAPTER_METADATA: Record<string, {
|
||||
settingsTarget: 'vscode-code-reviewer.pmd',
|
||||
hasExternalDependency: true,
|
||||
dependencyLabel: 'Java',
|
||||
configFileTemplate: getPmdRulesetTemplate,
|
||||
configFileTemplate: () => buildPmdProjectRulesetText(getLanguage()),
|
||||
i18nKey: 'pmd',
|
||||
},
|
||||
'sqlfluff': {
|
||||
@@ -104,7 +67,7 @@ const ADAPTER_METADATA: Record<string, {
|
||||
settingsTarget: 'vscode-code-reviewer.sqlfluff',
|
||||
hasExternalDependency: true,
|
||||
dependencyLabel: 'Python + sqlfluff',
|
||||
configFileTemplate: getSqlfluffTemplate,
|
||||
configFileTemplate: () => buildSqlfluffProjectConfigText(SQLFLUFF_CONFIG_DIALECT, getLanguage()),
|
||||
i18nKey: 'sql',
|
||||
},
|
||||
eslint: {
|
||||
@@ -112,7 +75,7 @@ const ADAPTER_METADATA: Record<string, {
|
||||
projectConfigFileName: 'eslint.config.js',
|
||||
settingsTarget: 'vscode-code-reviewer.linters',
|
||||
hasExternalDependency: false,
|
||||
configFileTemplate: getEslintTemplate,
|
||||
configFileTemplate: () => buildEslintProjectConfigText(getLanguage()),
|
||||
i18nKey: 'eslint',
|
||||
},
|
||||
stylelint: {
|
||||
@@ -120,7 +83,7 @@ const ADAPTER_METADATA: Record<string, {
|
||||
projectConfigFileName: '.stylelintrc.js',
|
||||
settingsTarget: 'vscode-code-reviewer.linters',
|
||||
hasExternalDependency: false,
|
||||
configFileTemplate: getStylelintTemplate,
|
||||
configFileTemplate: () => buildStylelintProjectConfigText(getLanguage()),
|
||||
i18nKey: 'stylelint',
|
||||
},
|
||||
};
|
||||
@@ -377,6 +340,10 @@ export class SetupViewProvider implements vscode.WebviewViewProvider {
|
||||
tooltipEdit: t('setup.adapter.tooltipEdit'),
|
||||
toggleEnable: t('setup.adapter.toggleEnable'),
|
||||
toggleDisable: t('setup.adapter.toggleDisable'),
|
||||
pmdHelp: t('setup.adapter.pmdHelp'),
|
||||
sqlHelp: t('setup.adapter.sqlHelp'),
|
||||
eslintHelp: t('setup.adapter.eslintHelp'),
|
||||
stylelintHelp: t('setup.adapter.stylelintHelp'),
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -780,9 +747,10 @@ input::placeholder { color: var(--vscode-input-placeholderForeground, var(--vsco
|
||||
.adapter-card.disabled { opacity: 0.45; }
|
||||
.adapter-card-header {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
margin-bottom: 6px;
|
||||
margin-bottom: 6px; position: relative;
|
||||
}
|
||||
.adapter-card-name { font-size: 12px; font-weight: 600; color: var(--vscode-foreground); }
|
||||
.adapter-card-name-wrap { display: inline-flex; align-items: center; min-width: 0; }
|
||||
.adapter-toggle {
|
||||
width: 30px; height: 16px; border-radius: 8px;
|
||||
background: #3fb950; position: relative; cursor: pointer;
|
||||
@@ -807,7 +775,6 @@ input::placeholder { color: var(--vscode-input-placeholderForeground, var(--vsco
|
||||
.adapter-badge-error { background: rgba(248,81,73,0.15); color: #f48771; }
|
||||
.adapter-languages { font-size: 10px; color: var(--vscode-descriptionForeground); margin-bottom: 4px; }
|
||||
.adapter-lang-label { color: var(--vscode-descriptionForeground); }
|
||||
.adapter-guide { font-size: 10px; color: var(--vscode-descriptionForeground); line-height: 1.4; margin-bottom: 7px; }
|
||||
.adapter-actions { display: flex; gap: 5px; }
|
||||
.adapter-btn {
|
||||
padding: 2px 8px; border-radius: 3px; font-size: 10px;
|
||||
@@ -890,10 +857,47 @@ input::placeholder { color: var(--vscode-input-placeholderForeground, var(--vsco
|
||||
background: var(--vscode-sideBar-background, var(--vscode-editor-background));
|
||||
border: 1px solid var(--vscode-panel-border); border-radius: 6px;
|
||||
font-size: 10px; color: var(--vscode-descriptionForeground);
|
||||
position: relative;
|
||||
}
|
||||
.mode-legend-item { display: inline-flex; align-items: center; gap: 4px; }
|
||||
.mode-legend-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
|
||||
.mode-legend-desc { width: 100%; font-size: 10px; opacity: 0.75; }
|
||||
.mode-legend-desc-row {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
gap: 4px; width: 100%;
|
||||
}
|
||||
.mode-legend-desc { font-size: 10px; opacity: 0.75; }
|
||||
|
||||
/* Help icon & tooltip */
|
||||
.help-icon {
|
||||
position: relative;
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
width: 14px; height: 14px; margin-left: 4px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid var(--vscode-descriptionForeground);
|
||||
color: var(--vscode-descriptionForeground);
|
||||
font-size: 9px; font-weight: 700; line-height: 1;
|
||||
cursor: help; user-select: none; flex-shrink: 0;
|
||||
}
|
||||
.help-icon:hover { color: #8b5cf6; border-color: #8b5cf6; }
|
||||
.help-icon:hover::after {
|
||||
content: attr(data-help);
|
||||
position: absolute;
|
||||
top: calc(100% + 6px); left: 0;
|
||||
z-index: 200;
|
||||
width: max-content; max-width: 280px;
|
||||
background: var(--vscode-editorWidget-background, var(--vscode-editor-background));
|
||||
color: var(--vscode-foreground);
|
||||
border: 1px solid var(--vscode-widget-border, var(--vscode-panel-border));
|
||||
border-radius: 4px;
|
||||
padding: 8px 10px;
|
||||
font-size: 11px; font-weight: 400; line-height: 1.6;
|
||||
white-space: pre-line;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.4);
|
||||
}
|
||||
.mode-legend .help-icon:hover::after {
|
||||
top: calc(100% + 8px); right: 0; left: auto;
|
||||
max-width: 300px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -1030,7 +1034,10 @@ input::placeholder { color: var(--vscode-input-placeholderForeground, var(--vsco
|
||||
<span class="mode-legend-item"><span class="mode-legend-dot" style="background:#8b5cf6;"></span>${t('setup.adapter.modeBuiltin')}</span>
|
||||
<span class="mode-legend-item"><span class="mode-legend-dot" style="background:#3fb950;"></span>${t('setup.adapter.modeProject')}</span>
|
||||
<span class="mode-legend-item"><span class="mode-legend-dot" style="background:#d29922;"></span>${t('setup.adapter.modeGlobal')}</span>
|
||||
<span class="mode-legend-desc">${t('setup.adapter.modeLegend')}</span>
|
||||
<span class="mode-legend-desc-row">
|
||||
<span class="mode-legend-desc">${t('setup.adapter.modeLegend')}</span>
|
||||
<span class="help-icon" data-help="${t('setup.adapter.modeLegendHelp')}">?</span>
|
||||
</span>
|
||||
</div>
|
||||
<div id="adapter-list"></div>
|
||||
</div>
|
||||
@@ -1176,7 +1183,6 @@ input::placeholder { color: var(--vscode-input-placeholderForeground, var(--vsco
|
||||
dependencyStatus,
|
||||
dependencyLabel: meta.dependencyLabel,
|
||||
configured,
|
||||
guideText: t(`setup.adapter.${meta.i18nKey}Guide`),
|
||||
languages: t(`setup.adapter.${meta.i18nKey}Languages`),
|
||||
projectConfigFileName: meta.projectConfigFileName,
|
||||
settingsTarget: meta.settingsTarget,
|
||||
@@ -1200,7 +1206,8 @@ input::placeholder { color: var(--vscode-input-placeholderForeground, var(--vsco
|
||||
const filePath = path.join(rootPath, meta.projectConfigFileName);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
fs.writeFileSync(filePath, meta.configFileTemplate(), 'utf-8');
|
||||
const content = await meta.configFileTemplate();
|
||||
fs.writeFileSync(filePath, content, 'utf-8');
|
||||
vscode.window.showInformationMessage(`配置文件已创建: ${meta.projectConfigFileName}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user