Skip to content

Commit 211cd30

Browse files
committed
rm unused code, fix linter errors'
1 parent 739fef6 commit 211cd30

12 files changed

+751
-5660
lines changed

package-lock.json

Lines changed: 731 additions & 5582 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,13 @@
99
"author": "Zuby Javed",
1010
"license": "ISC",
1111
"devDependencies": {
12-
"@babel/core": "^7.21.8",
13-
"@babel/preset-env": "^7.21.5",
14-
"@types/chrome": "^0.0.234",
15-
"@types/lodash": "^4.14.194",
16-
"@types/lodash-es": "^4.17.7",
1712
"@typescript-eslint/eslint-plugin": "^5.59.6",
1813
"@typescript-eslint/parser": "^5.59.6",
19-
"babel-loader": "^9.1.2",
2014
"eslint": "^8.41.0",
21-
"eslint-config-google": "^0.14.0",
22-
"eslint-config-standard-with-typescript": "^34.0.1",
23-
"eslint-plugin-import": "^2.27.5",
24-
"eslint-plugin-n": "^15.7.0",
25-
"eslint-plugin-promise": "^6.1.1",
26-
"typescript": "^5.0.4",
27-
"webextension-polyfill": "^0.10.0",
28-
"webpack": "^5.83.1",
29-
"webpack-cli": "^5.1.1"
15+
"eslint-config-google": "^0.14.0"
3016
},
3117
"dependencies": {
32-
"eventsource-parser": "^1.0.0",
33-
"lodash-es": "^4.17.21"
18+
"@types/chrome": "^0.0.313",
19+
"typescript": "^5.8.2"
3420
}
3521
}

src/background/background.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ chrome.runtime.onMessage.addListener((request) => {
6868
}
6969
});
7070

71-
chrome.runtime.onMessage.addListener((request: any) => {
72-
if (request.type === 'OPEN_LOGIN_PAGE') {
73-
chrome.tabs.create({ url: 'https://chat.openai.com' });
74-
}
75-
});
76-
7771
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
7872
if (changeInfo.status === 'complete' && tab.url) {
7973
const url = tab.url;

src/background/openrouter/openrouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export class OpenRouterProvider implements AIProvider {
1+
export class OpenRouterProvider {
22
private readonly apiUrl: string;
33
private readonly model: string;
44

@@ -89,7 +89,7 @@ export class OpenRouterProvider implements AIProvider {
8989
console.error('Backend API error:', error);
9090
params.onEvent({
9191
type: 'error',
92-
data: { text: error.message }
92+
data: { text: (error as Error).message }
9393
});
9494
throw error;
9595
}

src/content-script/get-gpt-access-token.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/content-script/get-user-code.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function getConsoleData() {
2323

2424
// Get output and expected output
2525
const containers = document.querySelectorAll('div.flex.h-full.w-full.flex-col.space-y-2');
26-
for (const container of containers) {
26+
Array.from(containers).forEach(container => {
2727
const label = container.querySelector('div.flex.text-xs.font-medium');
2828
const valueDiv = container.querySelector('div.font-menlo.relative.mx-3.whitespace-pre-wrap');
2929
const value = valueDiv?.textContent?.trim() || '';
@@ -33,7 +33,7 @@ function getConsoleData() {
3333
} else if (label?.textContent?.includes('Expected') && value) {
3434
results.push(`Expected Output: ${value}`);
3535
}
36-
}
36+
});
3737

3838
// Check for multiple test cases
3939
const testCaseButtons = document.querySelectorAll('[data-e2e-locator="console-testcase-button"]');
@@ -51,20 +51,20 @@ function getProblem() {
5151
const examples = document.getElementsByClassName('elfjS')[0];
5252
if (examples && examples.children) {
5353
collectedData.push('\nHeres the description, examples, and constraints for the problem\n');
54-
for (const child of examples.children) {
54+
Array.from(examples.children).forEach(child => {
5555
let text = child.textContent;
5656
if (text) collectedData.push(text);
57-
}
57+
});
5858
}
5959

6060
// Get the function definition and users code from the code editor
6161
const codeEditor = document.getElementsByClassName('view-line');
6262
if (codeEditor) {
6363
collectedData.push("\n--- Function Definition and Current Code ---\n");
64-
for (const viewLine of codeEditor) {
64+
Array.from(codeEditor).forEach(viewLine => {
6565
let text = viewLine.textContent;
6666
if (text) collectedData.push(text);
67-
}
67+
});
6868
}
6969

7070
// Get test cases, output, and expected output

src/content-script/update-description-tab.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ function showExamples() {
66
if (!examples) return;
77
let preTags = examples.getElementsByTagName('pre');
88
if (preTags) {
9-
for (let tag of preTags) {
9+
Array.from(preTags).forEach(tag => {
1010
tag.style.display = showExamples ? 'block' : 'none';
11-
}
11+
});
1212
}
1313
});
1414
}

src/popup/popup.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ a:hover {
9090
margin-bottom: 0;
9191
}
9292

93-
/* GPT Buttons */
9493
.button-container {
9594
display: flex;
9695
flex-direction: row;
@@ -129,7 +128,6 @@ a:hover {
129128
color: var(--color);
130129
}
131130

132-
/* GPT Response */
133131
.response-container {
134132
min-height: 150px;
135133
max-width: 400px;

src/popup/popup.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ <h2 class="title">
2020
</h2>
2121

2222

23-
<!-- GPT Buttons -->
2423
<div class="button-container">
2524
<button id="fix-code-btn" class="material-button button">
2625
<image src="../assets/images/solution-icon.png" class="button-icon" alt="Fix" />
@@ -34,9 +33,7 @@ <h2 class="title">
3433
<p id="info-message">
3534
Open a <a href="https://leetcode.com/problems/two-sum/" target="_blank">Leetcode problem </a>to get started
3635
</p>
37-
<!-- ChatGPT Login Button -->
38-
<button id="login-btn" class="material-button hidden">Open ChatGPT website</button>
39-
<!-- GPT Response -->
36+
<!-- AI Response -->
4037
<code class="language-text" id="analyze-code-response" class="response-container hidden">
4138
</code>
4239
<pre class="response-container hidden" id="fix-code-container">

src/popup/popup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Contains the logic behind the popup window that appears when the extension icon is clicked.
3-
Creates the GPT buttons, sets the prompts, and displays the responses.
3+
Creates the AI buttons, sets the prompts, and displays the responses.
44
The user can also copy the code to their clipboard, clear the code, and open the settings page.
55
*/
66

@@ -11,7 +11,8 @@ import { OpenRouterProvider } from '../background/openrouter/openrouter.js';
1111
interface AIProvider {
1212
generateAnswer(params: {
1313
prompt: string,
14-
onEvent: (arg: { type: string, data?: { text: string } }) => void
14+
onEvent: (arg: { type: string, data?: { text: string } }) => void,
15+
action: 'analyze' | 'fix'
1516
}): Promise<void>;
1617
}
1718

@@ -27,7 +28,6 @@ const selectors: { [key: string]: string } = {
2728
copyCodeBtn: 'copy-code-btn',
2829
clearCodeBtn: 'clear-code-btn',
2930
openSettingsBtn: 'open-settings-btn',
30-
loginBtn: 'login-btn',
3131

3232
};
3333

@@ -70,7 +70,7 @@ function clearResponse(): void {
7070
chrome.storage.local.set({ 'analyzeCodeResponse': '' });
7171
}
7272

73-
function initActionButton(buttonId: string, action: string, aiProvider: AIProvider): void {
73+
function initActionButton(buttonId: string, action: 'analyze' | 'fix', aiProvider: AIProvider): void {
7474
const actionButton = document.getElementById(buttonId);
7575
if (!actionButton) return;
7676
actionButton.onclick = async () => {

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
1010
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1111
/* Language and Environment */
12-
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
12+
"target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13+
"lib": ["es2017", "dom", "es2015.iterable"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
1414
// "jsx": "preserve", /* Specify what JSX code is generated. */
1515
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
1616
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */

webpack.config.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)