From 4d3fcb51ecd02990698bae4abf03ec21656210db Mon Sep 17 00:00:00 2001 From: nimratcoderabbit Date: Tue, 15 Jul 2025 12:55:00 -0400 Subject: [PATCH 1/3] Language tool files --- languageTool.test.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++ sample.txt | 10 +++++++++ 2 files changed, 62 insertions(+) create mode 100644 languageTool.test.ts create mode 100644 sample.txt diff --git a/languageTool.test.ts b/languageTool.test.ts new file mode 100644 index 0000000..695d191 --- /dev/null +++ b/languageTool.test.ts @@ -0,0 +1,52 @@ +import { runLanguageTool } from "./languageTool" +import fs from "fs" +import { env } from "../../utils/env" + +const fileContent = fs.readFileSync("sample.txt", "utf-8") + +const mockParams = { + logger: { + child: () => ({ + debug: console.log, + error: console.error, + }), + }, + settings: { + configSettings: { + reviews: { + profile: "chill", // or "assertive" + tools: { + languagetool: { + enabled: true, + disabled_categories: [], + disabled_rules: [], + enabled_categories: [], + enabled_rules: [], + enabled_only: false, + level: "default", + }, + }, + }, + language: "en-US", + }, + }, + fileHunks: [ + { + repoFile: { + filename: "sample.txt", + }, + fileContent, + hunks: [], + toolOutputs: {}, + }, + ], +} as any + +// Fake credentials for testing (you should replace these with valid test creds or mock the API) +env.LANGUAGETOOL_USERNAME = "fakeUser" +env.LANGUAGETOOL_API_KEY = "fakeKey" + +runLanguageTool(mockParams).then(() => { + console.log("Test complete. Tool outputs:", mockParams.fileHunks[0].toolOutputs) +}) + diff --git a/sample.txt b/sample.txt new file mode 100644 index 0000000..99e5bd9 --- /dev/null +++ b/sample.txt @@ -0,0 +1,10 @@ +This is a test file with some intentional errors. + +Their going to the park later, maybe I'll join to. +This sentence have a agreement error. +The list are long and detailed. +He don't know what he doing. +Here is a mispeling. + +It is an very good idea to try this tool, isn't it. + From e19bfc33c707c5dd5ddb29dcc8897c362100714f Mon Sep 17 00:00:00 2001 From: nimratcoderabbit Date: Tue, 15 Jul 2025 13:20:34 -0400 Subject: [PATCH 2/3] Ast-grep files --- main.ts | 14 ++++++++++++++ sgconfig.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 main.ts create mode 100644 sgconfig.yml diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..d2b902e --- /dev/null +++ b/main.ts @@ -0,0 +1,14 @@ +var foo = 123 + +function logStuff(input: any) { + console.log("Input is:", input) + debugger +} + +function doNothing() {} + +const process = (value: any) => { + var temp = value + console.log("Processing:", temp) +} + diff --git a/sgconfig.yml b/sgconfig.yml new file mode 100644 index 0000000..c8c540a --- /dev/null +++ b/sgconfig.yml @@ -0,0 +1,33 @@ +rules: + - id: no-console-log + message: Avoid using console.log + severity: warning + language: ts + pattern: console.log($$$) + + - id: no-any-type + message: Avoid using `any` type + severity: warning + language: ts + pattern: ($VAR:identifier): any + + - id: no-var + message: Use `let` or `const` instead of `var` + severity: warning + language: ts + pattern: var $VAR = $$$ + + - id: no-debugger + message: Remove `debugger` statement + severity: warning + language: ts + pattern: debugger + + - id: no-empty-function + message: Avoid using empty functions + severity: warning + language: ts + pattern: | + function $NAME($$$) { + } + From d484248f12f78adbaace0221ee055cd1f8f09b6e Mon Sep 17 00:00:00 2001 From: nimratcoderabbit Date: Tue, 15 Jul 2025 13:21:27 -0400 Subject: [PATCH 3/3] Deleted files --- languageTool.test.ts | 52 -------------------------------------------- sample.txt | 10 --------- 2 files changed, 62 deletions(-) delete mode 100644 languageTool.test.ts delete mode 100644 sample.txt diff --git a/languageTool.test.ts b/languageTool.test.ts deleted file mode 100644 index 695d191..0000000 --- a/languageTool.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { runLanguageTool } from "./languageTool" -import fs from "fs" -import { env } from "../../utils/env" - -const fileContent = fs.readFileSync("sample.txt", "utf-8") - -const mockParams = { - logger: { - child: () => ({ - debug: console.log, - error: console.error, - }), - }, - settings: { - configSettings: { - reviews: { - profile: "chill", // or "assertive" - tools: { - languagetool: { - enabled: true, - disabled_categories: [], - disabled_rules: [], - enabled_categories: [], - enabled_rules: [], - enabled_only: false, - level: "default", - }, - }, - }, - language: "en-US", - }, - }, - fileHunks: [ - { - repoFile: { - filename: "sample.txt", - }, - fileContent, - hunks: [], - toolOutputs: {}, - }, - ], -} as any - -// Fake credentials for testing (you should replace these with valid test creds or mock the API) -env.LANGUAGETOOL_USERNAME = "fakeUser" -env.LANGUAGETOOL_API_KEY = "fakeKey" - -runLanguageTool(mockParams).then(() => { - console.log("Test complete. Tool outputs:", mockParams.fileHunks[0].toolOutputs) -}) - diff --git a/sample.txt b/sample.txt deleted file mode 100644 index 99e5bd9..0000000 --- a/sample.txt +++ /dev/null @@ -1,10 +0,0 @@ -This is a test file with some intentional errors. - -Their going to the park later, maybe I'll join to. -This sentence have a agreement error. -The list are long and detailed. -He don't know what he doing. -Here is a mispeling. - -It is an very good idea to try this tool, isn't it. -