lint_code
Analyze codebase for syntax errors, style issues, and potential bugs using custom lint commands. Specify a directory to ensure consistent coding standards and improve code quality in development workflows.
Instructions
Run linting on the codebase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | No | Lint command to run (e.g., "npm run lint", "eslint .") | npm run lint |
| directory | No | Directory to run linting in (default: current directory) |
Implementation Reference
- src/index.ts:274-307 (handler)The handler function that executes the linting command using child_process.execSync. It runs the specified lint command in the given directory and handles both successful linting and cases with issues by returning appropriate output.private async lintCode(args: any) { const command = args?.command || 'npm run lint'; const directory = args?.directory || process.cwd(); try { const output = execSync(command, { cwd: directory, encoding: 'utf8', timeout: 300000 // 5 minutes }); return { content: [ { type: 'text', text: `Linting completed!\nCommand: ${command}\nDirectory: ${directory}\nOutput:\n${output}` } ] }; } catch (error: any) { // Linting might fail but still provide useful output const output = error.stdout || ''; const stderr = error.stderr || ''; return { content: [ { type: 'text', text: `Linting completed with issues:\nCommand: ${command}\nDirectory: ${directory}\nOutput:\n${output}\nErrors:\n${stderr}` } ] }; } }
- src/index.ts:113-130 (registration)Registration of the 'lint_code' tool in the ListToolsRequestSchema handler, defining its name, description, and input schema.{ name: 'lint_code', description: 'Run linting on the codebase', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Lint command to run (e.g., "npm run lint", "eslint .")', default: 'npm run lint' }, directory: { type: 'string', description: 'Directory to run linting in (default: current directory)' } } } }
- src/index.ts:116-129 (schema)Input schema definition for the lint_code tool, specifying parameters for command and directory.inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Lint command to run (e.g., "npm run lint", "eslint .")', default: 'npm run lint' }, directory: { type: 'string', description: 'Directory to run linting in (default: current directory)' } } }
- src/index.ts:147-148 (handler)Dispatcher case in CallToolRequestSchema handler that routes 'lint_code' calls to the lintCode method.case 'lint_code': return await this.lintCode(args);