eslint-detector
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePurpose
用途
Detect ESLint presence and available commands in a repository, returning structured JSON data specifically formatted for the quality-gates-linter agent to consume.
检测代码仓库中ESLint的存在情况及可用命令,返回专为quality-gates-linter Agent设计的结构化JSON数据。
When to Use
使用场景
Invoke this skill during Phase 0 (Environment Detection) of the quality-gates-linter agent workflow to:
- Verify ESLint is configured in the repository
- Identify available ESLint commands (check and fix)
- Locate command sources for the agent to read directly
This skill should NOT be invoked for general code review or linting tasks - only for environment detection.
在quality-gates-linter Agent工作流的第0阶段(环境检测)调用此技能,以:
- 验证代码仓库中是否配置了ESLint
- 识别可用的ESLint命令(检查和修复)
- 定位命令来源,供Agent直接读取
此技能不应用于常规代码审查或linting任务,仅用于环境检测。
Detection Process
检测流程
Step 1: Check for ESLint Configuration
步骤1:检查ESLint配置
Search for ESLint configuration files using Glob tool:
.eslintrc.js.eslintrc.json.eslintrc.yml.eslintrc.yaml- (flat config)
eslint.config.js - (check for
package.jsonfield)eslintConfig
If NO configuration files found:
- Set
eslintDetected: false - Return early with minimal JSON structure
If configuration files found:
- Set
eslintDetected: true - Record all found config files with paths and types
- Proceed to Step 2
使用Glob工具搜索ESLint配置文件:
.eslintrc.js.eslintrc.json.eslintrc.yml.eslintrc.yaml- (扁平配置)
eslint.config.js - (检查是否存在
package.json字段)eslintConfig
如果未找到配置文件:
- 设置
eslintDetected: false - 提前返回最简JSON结构
如果找到配置文件:
- 设置
eslintDetected: true - 记录所有找到的配置文件的路径和类型
- 进入步骤2
Step 2: Detect ESLint Commands
步骤2:检测ESLint命令
Search for ESLint commands in priority order:
按优先级顺序搜索ESLint命令:
2a. Check CLAUDE.md (Highest Priority)
2a. 检查CLAUDE.md(最高优先级)
If exists:
CLAUDE.md- Read the file
- Search for sections: "Linting", "Development Commands", "Code Quality", "Common Commands"
- Look for command patterns:
- Check commands: ,
eslint,lint,make lintnpm run lint - Fix commands: ,
eslint --fix,lint-fix,make lint-fixnpm run lint:fix
- Check commands:
- Extract exact commands mentioned
- Record CLAUDE.md as source if commands found
如果存在:
CLAUDE.md- 读取该文件
- 搜索以下章节:"Linting"、"Development Commands"、"Code Quality"、"Common Commands"
- 查找命令模式:
- 检查命令:、
eslint、lint、make lintnpm run lint - 修复命令:、
eslint --fix、lint-fix、make lint-fixnpm run lint:fix
- 检查命令:
- 提取提及的准确命令
- 如果找到命令,记录CLAUDE.md为来源
2b. Check package.json Scripts
2b. 检查package.json脚本
Read and examine the section:
package.jsonscriptsLint check commands (look for these script names):
"lint""eslint""lint:check"- Extract as:
npm run <script-name>
Lint fix commands (look for these script names):
"lint:fix""lint-fix""fix""eslint:fix"- Extract as:
npm run <script-name>
Record package.json as source if commands found.
读取并检查章节:
package.jsonscriptsLint检查命令(查找以下脚本名称):
"lint""eslint""lint:check"- 提取格式:
npm run <script-name>
Lint修复命令(查找以下脚本名称):
"lint:fix""lint-fix""fix""eslint:fix"- 提取格式:
npm run <script-name>
如果找到命令,记录package.json为来源。
2c. Check Makefile
2c. 检查Makefile
If exists:
Makefile- Read the file
- Search for targets containing or
eslintlint - Common target patterns:
- Check: ,
lint,eslintcheck - Fix: ,
lint-fix,fixformat
- Check:
- Extract as:
make <target-name> - Record Makefile as source if commands found
如果存在:
Makefile- 读取该文件
- 搜索包含或
eslint的目标lint - 常见目标模式:
- 检查:、
lint、eslintcheck - 修复:、
lint-fix、fixformat
- 检查:
- 提取格式:
make <target-name> - 如果找到命令,记录Makefile为来源
2d. Fallback Commands
2d. 备用命令
If no commands found in any source:
- Use fallback commands:
- Check:
npx eslint . - Fix:
npx eslint --fix .
- Check:
- Record source as:
"fallback"
如果在所有来源中都未找到命令:
- 使用备用命令:
- 检查:
npx eslint . - 修复:
npx eslint --fix .
- 检查:
- 记录来源为:
"fallback"
Step 3: Build JSON Response
步骤3:构建JSON响应
Construct JSON object with this exact structure:
json
{
"eslintDetected": true,
"configFiles": [
{
"path": ".eslintrc.json",
"type": "eslintrc"
},
{
"path": "package.json",
"type": "package-config"
}
],
"commands": {
"check": {
"command": "npm run lint",
"source": "package.json"
},
"fix": {
"command": "npm run lint:fix",
"source": "package.json"
}
},
"commandSources": [
"package.json"
]
}Field Specifications:
- (boolean):
eslintDetectedif config found,trueotherwisefalse - (array): List of all ESLint config files found
configFiles- (string): Relative path to config file
path - (string): Config type (
type,"eslintrc","eslint-config-js")"package-config"
- (object): Contains check and fix commands
commands- (object): Lint check command
check- (string): Exact command to run
command - (string): Where command was found
source
- (object): Lint fix command
fix- (string): Exact command to run
command - (string): Where command was found
source
- (array): Ordered list of sources where commands were found
commandSources
按以下精确结构构建JSON对象:
json
{
"eslintDetected": true,
"configFiles": [
{
"path": ".eslintrc.json",
"type": "eslintrc"
},
{
"path": "package.json",
"type": "package-config"
}
],
"commands": {
"check": {
"command": "npm run lint",
"source": "package.json"
},
"fix": {
"command": "npm run lint:fix",
"source": "package.json"
}
},
"commandSources": [
"package.json"
]
}字段说明:
- (布尔值):找到配置则为
eslintDetected,否则为truefalse - (数组):所有找到的ESLint配置文件列表
configFiles- (字符串):配置文件的相对路径
path - (字符串):配置类型(
type、"eslintrc"、"eslint-config-js")"package-config"
- (对象):包含检查和修复命令
commands- (对象):Lint检查命令
check- (字符串):要执行的精确命令
command - (字符串):命令的来源
source
- (对象):Lint修复命令
fix- (字符串):要执行的精确命令
command - (字符串):命令的来源
source
- (数组):命令来源的有序列表
commandSources
Step 4: Return JSON
步骤4:返回JSON
Output the JSON structure in a code block with clear formatting:
markdown
undefined在代码块中输出格式化清晰的JSON结构:
markdown
undefinedESLint Detection Results
ESLint检测结果
json
{
"eslintDetected": true,
"configFiles": [...],
"commands": {...},
"commandSources": [...]
}Summary:
- ESLint detected: Yes/No
- Config files: <count>
- Commands source: <primary source>
undefinedjson
{
"eslintDetected": true,
"configFiles": [...],
"commands": {...},
"commandSources": [...]
}摘要:
- ESLint已检测到:是/否
- 配置文件数量:<数量>
- 命令来源:<主要来源>
undefinedPriority Rules
优先级规则
- Command Priority: CLAUDE.md > package.json > Makefile > fallback
- Use First Match: For each command type (check/fix), use the first match found
- Source Transparency: Always record where commands were found
- Config Completeness: List ALL config files found, not just the first one
- 命令优先级:CLAUDE.md > package.json > Makefile > 备用命令
- 使用首个匹配项:对于每种命令类型(检查/修复),使用找到的首个匹配项
- 来源透明:始终记录命令的来源
- 配置完整性:列出所有找到的配置文件,而非仅首个
Edge Cases
边缘情况
Multiple config files found:
- List all in array
configFiles - No impact on command detection
Command found in multiple sources:
- Use highest priority source (CLAUDE.md wins)
- Record only the used source in
commandSources
Only check OR only fix command found:
- Return the found command
- For missing command, use fallback for that specific type
No ESLint config found:
json
{
"eslintDetected": false,
"configFiles": [],
"commands": {},
"commandSources": []
}ESLint config found but no commands:
json
{
"eslintDetected": true,
"configFiles": [{...}],
"commands": {
"check": {
"command": "npx eslint .",
"source": "fallback"
},
"fix": {
"command": "npx eslint --fix .",
"source": "fallback"
}
},
"commandSources": ["fallback"]
}找到多个配置文件:
- 在数组中列出所有文件
configFiles - 不影响命令检测
在多个来源中找到命令:
- 使用优先级最高的来源(CLAUDE.md优先)
- 在中仅记录使用的来源
commandSources
仅找到检查命令或仅找到修复命令:
- 返回找到的命令
- 对于缺失的命令类型,使用对应类型的备用命令
未找到ESLint配置:
json
{
"eslintDetected": false,
"configFiles": [],
"commands": {},
"commandSources": []
}找到ESLint配置但未找到命令:
json
{
"eslintDetected": true,
"configFiles": [{...}],
"commands": {
"check": {
"command": "npx eslint .",
"source": "fallback"
},
"fix": {
"command": "npx eslint --fix .",
"source": "fallback"
}
},
"commandSources": ["fallback"]
}Integration with quality-gates-linter
与quality-gates-linter的集成
The quality-gates-linter agent will:
- Invoke this skill during Phase 0
- Parse the returned JSON structure
- Use to decide whether to proceed or exit
eslintDetected - Use for verification runs
commands.check.command - Use for auto-fix attempts
commands.fix.command - Read files listed in if needed for additional context
commandSources
The JSON structure is designed to provide everything the linter agent needs without requiring additional file reads for command detection.
quality-gates-linter Agent将:
- 在第0阶段调用此技能
- 解析返回的JSON结构
- 根据决定继续执行或退出
eslintDetected - 使用进行验证运行
commands.check.command - 使用尝试自动修复
commands.fix.command - 如有需要,读取中列出的文件以获取额外上下文
commandSources
该JSON结构的设计目的是为linter Agent提供所需的全部信息,无需为命令检测进行额外的文件读取。