diff --git a/.eslintrc.js b/.eslintrc.js index b94604ec..6307a39f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -42,7 +42,6 @@ module.exports = { ignorePatterns: ["test", "dist", "build", "public", "/**/node_modules/*", ".eslintrc.js", "vite.config.ts", "vite-env.d.ts", "postcss.config.js", "tailwind.config.js", "vitest.config.ts", "playwright.config.ts", "e2e"], rules: { "indent": "off", - "@typescript-eslint/indent": "error", // eslint:recommended "arrow-body-style": ["error", "as-needed"], curly: ["error", "all"], @@ -122,15 +121,7 @@ module.exports = { }, ], "array-bracket-newline": ["error", "consistent"], - "array-bracket-spacing": [ - "error", - "never", - { - arraysInArrays: true, - }, - ], "array-element-newline": ["error", "consistent"], - "arrow-parens": ["error", "as-needed"], "arrow-spacing": "error", "block-spacing": ["error", "always"], "brace-style": ["error", "1tbs"], @@ -148,7 +139,6 @@ module.exports = { "eol-last": ["error", "always"], "func-call-spacing": ["error", "never"], "function-call-argument-newline": ["error", "consistent"], - "function-paren-newline": ["error", "multiline-arguments"], "jsx-quotes": ["error", "prefer-double"], "key-spacing": [ "error", @@ -164,14 +154,6 @@ module.exports = { after: true, }, ], - "line-comment-position": [ - "error", - { - position: "above", - ignorePattern: "pragma", - applyDefaultIgnorePatterns: false, - }, - ], "linebreak-style": ["error", "unix"], "lines-around-comment": [ "error", @@ -196,24 +178,10 @@ module.exports = { exceptAfterSingleLine: true, }, ], - "multiline-ternary": ["error", "always-multiline"], - "new-parens": ["error", "never"], - "newline-per-chained-call": [ - "error", - { - ignoreChainWithDepth: 2, - }, - ], "no-multi-spaces": "error", "no-multiple-empty-lines": "error", "no-trailing-spaces": "error", "no-whitespace-before-property": "error", - "object-curly-newline": [ - "error", - { - multiline: true, - }, - ], "object-curly-spacing": [ "error", "always", @@ -228,16 +196,6 @@ module.exports = { allowAllPropertiesOnSameLine: true, }, ], - "operator-linebreak": [ - "error", - "after", - { - overrides: { - "?": "before", - ":": "before", - }, - }, - ], "padded-blocks": ["error", "never"], "padding-line-between-statements": [ "error", @@ -276,7 +234,6 @@ module.exports = { ], "semi-style": ["error", "last"], "space-before-blocks": ["error", "always"], - "space-before-function-paren": ["error", "always"], "space-infix-ops": [ "error", { @@ -307,7 +264,6 @@ module.exports = { functionPrototypeMethods: true, }, ], - "wrap-regex": "error", // plugin:react/recommended "react/destructuring-assignment": [ @@ -338,23 +294,10 @@ module.exports = { "react/jsx-closing-bracket-location": "error", "react/jsx-closing-tag-location": "error", "react/jsx-curly-brace-presence": ["error", "never"], - "react/jsx-curly-newline": ["error", "consistent"], "react/jsx-equals-spacing": ["error", "never"], "react/jsx-first-prop-new-line": ["error", "multiline-multiprop"], "react/jsx-fragments": ["error", "syntax"], "react/jsx-indent-props": "off", - "react/jsx-max-props-per-line": [ - "error", - { - maximum: 1, - }, - ], - "react/jsx-newline": [ - "error", - { - prevent: false, - }, - ], // "react/jsx-no-leaked-render": ["error", { // "validStrategies": ["coerce"] // }], @@ -364,22 +307,7 @@ module.exports = { allowExpressions: true, }, ], - "react/jsx-one-expression-per-line": [ - "error", - { - allow: "literal", - }, - ], "react/jsx-props-no-multi-spaces": "error", - "react/jsx-sort-props": [ - "error", - { - callbacksLast: true, - shorthandFirst: true, - multiline: "last", - reservedFirst: true, - }, - ], "react/jsx-tag-spacing": [ "error", { diff --git a/.prettierrc b/.prettierrc index c44bef21..573d4c58 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,5 @@ { - "trailingComma": "es5", - "tabWidth": 2, + "trailingComma": "all", + "tabWidth": 4, "singleQuote": false } diff --git a/src/constants.ts b/src/constants.ts index 68fe569e..6cfaeba6 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,8 @@ // OpenSauced constants -export const OPEN_SAUCED_INSIGHTS_DOMAIN = import.meta.env.VITE_OPEN_SAUCED_INSIGHTS_DOMAIN; -export const OPEN_SAUCED_API_ENDPOINT = import.meta.env.VITE_OPEN_SAUCED_API_ENDPOINT; +export const OPEN_SAUCED_INSIGHTS_DOMAIN = import.meta.env + .VITE_OPEN_SAUCED_INSIGHTS_DOMAIN; +export const OPEN_SAUCED_API_ENDPOINT = import.meta.env + .VITE_OPEN_SAUCED_API_ENDPOINT; export const REPO_QUERY_API_ENDPOINT = "https://opensauced.tools"; export const SUPABASE_LOGIN_URL = `https://${import.meta.env.VITE_OPEN_SAUCED_SUPABASE_ID}.supabase.co/auth/v1/authorize`; @@ -14,7 +16,6 @@ export const OPEN_SAUCED_AUTH_TOKEN_KEY = "os-access-token"; export const OPEN_SAUCED_OPTED_LOG_OUT_KEY = "opted-log-out"; export const AI_PR_DESCRIPTION_CONFIG_KEY = "ai-pr-description-config"; - export const OPEN_SAUCED_USERS_ENDPOINT = `${OPEN_SAUCED_API_ENDPOINT}/users`; export const OPEN_SAUCED_REPOS_ENDPOINT = `${OPEN_SAUCED_API_ENDPOINT}/repos`; export const OPEN_SAUCED_SESSION_ENDPOINT = `${OPEN_SAUCED_API_ENDPOINT}/auth/session`; @@ -29,12 +30,17 @@ export const OPEN_SAUCED_HIGHLIGHTS_LIST_ENDPOINT = `${OPEN_SAUCED_API_ENDPOINT} export const OPEN_SAUCED_EMOJIS_ENDPOINT = `${OPEN_SAUCED_API_ENDPOINT}/emojis`; // Content-scripts selectors -export const GITHUB_PROFILE_MENU_SELECTOR = ".p-nickname.vcard-username.d-block"; -export const GITHUB_PROFILE_EDIT_MENU_CLASS = "button.js-profile-editable-edit-button"; -export const GITHUB_PR_COMMENT_HEADER_CLASS = "timeline-comment-header clearfix d-flex"; -export const GITHUB_REVIEW_SUGGESTION_CLASS = "js-suggestion-button-placeholder"; +export const GITHUB_PROFILE_MENU_SELECTOR = + ".p-nickname.vcard-username.d-block"; +export const GITHUB_PROFILE_EDIT_MENU_CLASS = + "button.js-profile-editable-edit-button"; +export const GITHUB_PR_COMMENT_HEADER_CLASS = + "timeline-comment-header clearfix d-flex"; +export const GITHUB_REVIEW_SUGGESTION_CLASS = + "js-suggestion-button-placeholder"; export const GITHUB_REPO_ACTIONS_SELECTOR = ".pagehead-actions"; -export const GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute = "[name='comment[body]']"; +export const GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute = + "[name='comment[body]']"; export const GITHUB_PR_BASE_BRANCH_CLASS = "css-truncate css-truncate-target"; export const LINKEDIN_PROJECT_FORM_SELECTOR = ".artdeco-text-input--input"; diff --git a/src/content-scripts/components/AICodeReview/AICodeReviewButton.ts b/src/content-scripts/components/AICodeReview/AICodeReviewButton.ts index 273ed1f0..dfe55caa 100644 --- a/src/content-scripts/components/AICodeReview/AICodeReviewButton.ts +++ b/src/content-scripts/components/AICodeReview/AICodeReviewButton.ts @@ -1,18 +1,18 @@ import { createHtmlElement } from "../../../utils/createHtmlElement"; import openSaucedLogoIcon from "../../../assets/opensauced-icon.svg"; -import { generateCodeExplanation, generateCodeSuggestion, generateCodeTest } from "../../../utils/ai-utils/openai"; import { - AICodeReviewMenu, - AICodeReviewMenuItem, -} from "./AICodeReviewMenu"; - + generateCodeExplanation, + generateCodeSuggestion, + generateCodeTest, +} from "../../../utils/ai-utils/openai"; +import { AICodeReviewMenu, AICodeReviewMenuItem } from "./AICodeReviewMenu"; export const AICodeReviewButton = (commentNode: HTMLElement) => { const changeSuggestorButton = createHtmlElement("a", { innerHTML: ` + openSaucedLogoIcon, + )}> `, onclick: (event: MouseEvent) => { event.stopPropagation(); @@ -45,5 +45,3 @@ export const AICodeReviewButton = (commentNode: HTMLElement) => { changeSuggestorButton.append(menu); return changeSuggestorButton; }; - - diff --git a/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts b/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts index dc5c05a2..9654b192 100644 --- a/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts +++ b/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts @@ -4,14 +4,18 @@ import { DescriptionConfig, getAIDescriptionConfig, } from "../../../utils/ai-utils/descriptionconfig"; -import { getAuthToken, isLoggedIn, optLogIn } from "../../../utils/checkAuthentication"; +import { + getAuthToken, + isLoggedIn, + optLogIn, +} from "../../../utils/checkAuthentication"; import { createHtmlElement } from "../../../utils/createHtmlElement"; import { isOutOfContextBounds } from "../../../utils/fetchGithubAPIData"; type SuggestionGenerator = ( token: string, code: string, - config: DescriptionConfig + config: DescriptionConfig, ) => Promise; export const AICodeReviewMenu = (items: HTMLLIElement[]) => { @@ -39,7 +43,7 @@ export const AICodeReviewMenu = (items: HTMLLIElement[]) => { menu.querySelector("ul")?.append(...items); - document.addEventListener("click", event => { + document.addEventListener("click", (event) => { if (event.target instanceof HTMLElement) { menu.classList.add("hidden"); } @@ -47,7 +51,12 @@ export const AICodeReviewMenu = (items: HTMLLIElement[]) => { return menu; }; -export const AICodeReviewMenuItem = (title: string, description: string, suggestionGenerator: SuggestionGenerator, commentNode: HTMLElement) => { +export const AICodeReviewMenuItem = ( + title: string, + description: string, + suggestionGenerator: SuggestionGenerator, + commentNode: HTMLElement, +) => { const menuItem = createHtmlElement("li", { className: "SelectMenu-item d-block slash-command-menu-item", role: "option", @@ -90,7 +99,7 @@ const handleSubmit = async ( ".code-review.selected-line", ); let selectedCode = Array.from(selectedLines) - .map(line => line.textContent) + .map((line) => line.textContent) .join("\n"); // find input with name="position" and get its value @@ -100,15 +109,17 @@ const handleSubmit = async ( )!; const position = positionElement.getAttribute("value")!; - const codeDiv = document.querySelector(`[data-line-number="${position}"]`) - ?.nextSibling?.nextSibling as HTMLElement; + const codeDiv = document.querySelector( + `[data-line-number="${position}"]`, + )?.nextSibling?.nextSibling as HTMLElement; selectedCode = - codeDiv.getElementsByClassName("blob-code-inner")[0].textContent!; + codeDiv.getElementsByClassName("blob-code-inner")[0] + .textContent!; } if ( isOutOfContextBounds( - [selectedCode, [] ], + [selectedCode, []], descriptionConfig.config.maxInputLength, ) ) { diff --git a/src/content-scripts/components/AddPRToHighlights/AddPRToHighlightsButton.ts b/src/content-scripts/components/AddPRToHighlights/AddPRToHighlightsButton.ts index b5acc441..d1dc67d8 100644 --- a/src/content-scripts/components/AddPRToHighlights/AddPRToHighlightsButton.ts +++ b/src/content-scripts/components/AddPRToHighlights/AddPRToHighlightsButton.ts @@ -11,8 +11,8 @@ export const AddPRToHighlightsButton = () => { )}>