style: apply Prettier formatting to TS/JS/JSON/MD files

Add Prettier as a dev dependency with .prettierrc.json config and
.prettierignore. Hook added via mirrors-prettier in pre-commit config.
All TypeScript, JSON, Markdown, and YAML files auto-formatted.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-03-29 13:05:50 +01:00
parent c44bd9205d
commit 7d50fa1d4c
82 changed files with 18314 additions and 17317 deletions

View File

@@ -2,21 +2,21 @@
* Logger for KiCAD MCP server
*/
import { existsSync, mkdirSync, appendFileSync } from 'fs';
import { join } from 'path';
import * as os from 'os';
import { existsSync, mkdirSync, appendFileSync } from "fs";
import { join } from "path";
import * as os from "os";
// Log levels
type LogLevel = 'error' | 'warn' | 'info' | 'debug';
type LogLevel = "error" | "warn" | "info" | "debug";
// Default log directory
const DEFAULT_LOG_DIR = join(os.homedir(), '.kicad-mcp', 'logs');
const DEFAULT_LOG_DIR = join(os.homedir(), ".kicad-mcp", "logs");
/**
* Logger class for KiCAD MCP server
*/
class Logger {
private logLevel: LogLevel = 'info';
private logLevel: LogLevel = "info";
private logDir: string = DEFAULT_LOG_DIR;
/**
@@ -45,7 +45,7 @@ class Logger {
* @param message Message to log
*/
error(message: string): void {
this.log('error', message);
this.log("error", message);
}
/**
@@ -53,8 +53,8 @@ class Logger {
* @param message Message to log
*/
warn(message: string): void {
if (['error', 'warn', 'info', 'debug'].includes(this.logLevel)) {
this.log('warn', message);
if (["error", "warn", "info", "debug"].includes(this.logLevel)) {
this.log("warn", message);
}
}
@@ -63,8 +63,8 @@ class Logger {
* @param message Message to log
*/
info(message: string): void {
if (['info', 'debug'].includes(this.logLevel)) {
this.log('info', message);
if (["info", "debug"].includes(this.logLevel)) {
this.log("info", message);
}
}
@@ -73,8 +73,8 @@ class Logger {
* @param message Message to log
*/
debug(message: string): void {
if (this.logLevel === 'debug') {
this.log('debug', message);
if (this.logLevel === "debug") {
this.log("debug", message);
}
}
@@ -85,8 +85,9 @@ class Logger {
*/
private log(level: LogLevel, message: string): void {
const now = new Date();
const pad = (n: number, w = 2) => String(n).padStart(w, '0');
const timestamp = `${now.getFullYear()}-${pad(now.getMonth()+1)}-${pad(now.getDate())} ` +
const pad = (n: number, w = 2) => String(n).padStart(w, "0");
const timestamp =
`${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ` +
`${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())},${pad(now.getMilliseconds(), 3)}`;
const formattedMessage = `[${timestamp}] [${level.toUpperCase()}] ${message}`;
@@ -101,8 +102,8 @@ class Logger {
mkdirSync(this.logDir, { recursive: true });
}
const logFile = join(this.logDir, `kicad-mcp-${new Date().toISOString().split('T')[0]}.log`);
appendFileSync(logFile, formattedMessage + '\n');
const logFile = join(this.logDir, `kicad-mcp-${new Date().toISOString().split("T")[0]}.log`);
appendFileSync(logFile, formattedMessage + "\n");
} catch (error) {
console.error(`Failed to write to log file: ${error}`);
}