From 65f0b4e0b761903eff5cc2353db36b8729df4467 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 30 Apr 2025 01:29:18 -0600 Subject: [PATCH] custom lint rule for no logfile calls initial package setup --- cli/TerminalLayout.ts | 4 ---- deno.json | 15 ++++++++++++++- no-log.ts | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 no-log.ts diff --git a/cli/TerminalLayout.ts b/cli/TerminalLayout.ts index c44bfa5..59addaf 100644 --- a/cli/TerminalLayout.ts +++ b/cli/TerminalLayout.ts @@ -1,4 +1,3 @@ -import { log } from "util/logfile.ts"; import { Cursor } from "./cursor.ts"; export class TerminalLayout { @@ -80,7 +79,6 @@ export class TerminalLayout { } clearAll() { - log("clearAll"); Deno.stdout.writeSync( new TextEncoder().encode( TerminalLayout.ALT_BUFFER_DISABLE, @@ -93,7 +91,6 @@ export class TerminalLayout { } clear() { - log("clear " + this.height); for (let i = 0; i < this.height; i++) { Deno.stdout.writeSync(new TextEncoder().encode("\x1b[2K\x1b[1E")); } @@ -220,7 +217,6 @@ export class TerminalBlock { } clear() { - log(this.renderedLineCount); if (this.renderedLineCount === 0) return; const moveCursor = `\x1b[${this.lastRenderRow};1H`; Deno.stdout.writeSync(new TextEncoder().encode(moveCursor)); diff --git a/deno.json b/deno.json index 4dbb894..b87cf86 100644 --- a/deno.json +++ b/deno.json @@ -1,5 +1,6 @@ { "name": "@bearmetal/pdf-tools", + "version": "0.0.1", "tasks": { "dev": "deno run -A --env-file=.env --watch main.ts", "compile": "deno compile -o compare-form-fields.exe --target x86_64-pc-windows-msvc -R ./main.ts", @@ -11,5 +12,17 @@ "pdf-lib": "npm:pdf-lib@^1.17.1", "util/": "./util/" }, - "exports": {} + "exports": { + ".": "./main.ts" + }, + "lint": { + "rules": { + "exclude": [ + "no-explicit-any" + ] + }, + "plugins": [ + "./no-log.ts" + ] + } } \ No newline at end of file diff --git a/no-log.ts b/no-log.ts new file mode 100644 index 0000000..637919a --- /dev/null +++ b/no-log.ts @@ -0,0 +1,26 @@ +const plugin: Deno.lint.Plugin = { + name: "no-log", + rules: { + "no-log": { + create(context) { + return { + // Identifier(node) { + // if (node.name === "log") { + // context.report({ + // node, + // message: "Do not use log", + // }); + // } + // }, + 'ExpressionStatement > CallExpression[callee.name="log"]'(node) { + context.report({ + node, + message: "Clean up log statements", + }); + }, + }; + }, + }, + }, +}; +export default plugin;