lint_code
Analyze code files with ESLint to identify syntax errors, enforce style guidelines, and improve code quality in development workflows.
Instructions
Lint code files using ESLint
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"files": "<files>"
},
"name": "lint_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | File paths to lint |
Implementation Reference
- src/tools/linting.ts:93-97 (handler)Handler logic for the 'lint_code' tool. Extracts file paths from input, calls LintingUtils.lintFiles to perform ESLint linting, and formats results using Formatters.
case 'lint_code': { const files = params.files as string[]; const results = await lintingUtils.lintFiles(files); return Formatters.formatLintResults(results); } - src/tools/linting.ts:7-21 (schema)Tool definition including name, description, and input schema for 'lint_code' tool, specifying array of file paths as required input.
{ name: 'lint_code', description: 'Lint code files using ESLint', inputSchema: { type: 'object', properties: { files: { type: 'array', items: { type: 'string' }, description: 'File paths to lint', }, }, required: ['files'], }, }, - src/server.ts:18-25 (registration)Registration of lintingTools (containing lint_code) into the allTools array, which is returned in list tools response.
const allTools = [ ...codeAnalysisTools, ...codeQualityTools, ...dependencyAnalysisTools, ...lintingTools, ...webScrapingTools, ...apiDiscoveryTools, ]; - src/utils/linting-utils.ts:26-67 (helper)Core helper function that initializes ESLint, lints the given files, maps results to structured LintResult format including messages, counts, and fixes, with fallback for no config.
async lintFiles(filePaths: string[]): Promise<LintResult[]> { try { const eslint = await this.getESLint(); const results = await eslint.lintFiles(filePaths); return results.map((result: any) => ({ file: result.filePath, messages: result.messages.map((msg: any) => ({ ruleId: msg.ruleId, severity: msg.severity as 0 | 1 | 2, message: msg.message, line: msg.line, column: msg.column, endLine: msg.endLine, endColumn: msg.endColumn, fix: msg.fix ? { range: [msg.fix.range[0], msg.fix.range[1]], text: msg.fix.text, } : undefined, })), errorCount: result.errorCount, warningCount: result.warningCount, fixableErrorCount: result.fixableErrorCount, fixableWarningCount: result.fixableWarningCount, })); } catch (error) { // If ESLint is not configured, return empty results if (error instanceof Error && error.message.includes('No ESLint configuration')) { return filePaths.map((file) => ({ file, messages: [], errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0, })); } throw error; } }