diff --git a/.eslintrc.json b/.eslintrc.json index 41808e2d..5c72b853 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -35,9 +35,15 @@ "simple-import-sort", "@funboxteam/no-only-tests" ], + "settings": { + "import/resolver": { + "typescript": {} + } + }, "rules": { "semi": "off", "prettier/prettier": "error", + "maxWarnings": "off", "react/self-closing-comp": [ "error", { diff --git a/package.json b/package.json index e0cc8320..f1a6e74f 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "autoprefixer": "^10.4.14", "babel-jest": "^29.6.1", "chokidar": "^3.5.3", + "chrome": "^0.1.0", "cross-env": "^7.0.3", "css-loader": "^6.8.1", "eslint": "^8.15.0", diff --git a/src/global.d.ts b/src/global.d.ts index 41768a38..2ce6ba78 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -5,12 +5,12 @@ declare namespace chrome { } declare module 'virtual:reload-on-update-in-background-script' { - export const reloadOnUpdate: (watchPath: string) => void + export const reloadOnUpdate: () => void export default reloadOnUpdate } declare module 'virtual:reload-on-update-in-view' { - const refreshOnUpdate: (watchPath: string) => void + const refreshOnUpdate: () => void export default refreshOnUpdate } diff --git a/src/pages/background/index.ts b/src/pages/background/index.ts index ed43a41a..17bb0171 100644 --- a/src/pages/background/index.ts +++ b/src/pages/background/index.ts @@ -1,4 +1,7 @@ +/* eslint-disable */ import reloadOnUpdate from 'virtual:reload-on-update-in-background-script' +// @ts-ignore reloadOnUpdate('pages/background') +// @ts-ignore reloadOnUpdate('pages/content/style.scss') diff --git a/src/pages/content/components/App/index.tsx b/src/pages/content/components/App/index.tsx index f401c1f6..95271f08 100644 --- a/src/pages/content/components/App/index.tsx +++ b/src/pages/content/components/App/index.tsx @@ -1,8 +1,10 @@ +/* eslint-disable */ import { initListeners } from '@lib/listeners' import App from '@src/pages/content/components/App/App' import { createRoot } from 'react-dom/client' import refreshOnUpdate from 'virtual:reload-on-update-in-view' +// @ts-ignore refreshOnUpdate('pages/content') const root = document.createElement('div') diff --git a/src/pages/popup/Popup.tsx b/src/pages/popup/Popup.tsx index fb4d5ab6..e88eeeb9 100644 --- a/src/pages/popup/Popup.tsx +++ b/src/pages/popup/Popup.tsx @@ -22,12 +22,9 @@ const Popup = () => {
Web Monetization Logo
Web Monetization
- Close window.close()} - /> +
{monetization ? ( diff --git a/src/pages/popup/index.tsx b/src/pages/popup/index.tsx index e193642c..3270599d 100644 --- a/src/pages/popup/index.tsx +++ b/src/pages/popup/index.tsx @@ -1,3 +1,4 @@ +/* eslint-disable */ import '@pages/popup/index.css' import Popup from '@pages/popup/Popup' @@ -5,6 +6,7 @@ import React from 'react' import { createRoot } from 'react-dom/client' import refreshOnUpdate from 'virtual:reload-on-update-in-view' +// @ts-ignore refreshOnUpdate('pages/popup') function init() { diff --git a/utils/log.ts b/utils/log.ts index 22372ab0..796c7ea1 100644 --- a/utils/log.ts +++ b/utils/log.ts @@ -21,6 +21,7 @@ export default function colorLog(message: string, type?: ColorType) { break } + // eslint-disable-next-line no-console console.log(color, message) } diff --git a/utils/plugins/make-manifest.ts b/utils/plugins/make-manifest.ts index f407e290..96a3e991 100644 --- a/utils/plugins/make-manifest.ts +++ b/utils/plugins/make-manifest.ts @@ -10,7 +10,7 @@ const { resolve } = path const distDir = resolve(__dirname, '..', '..', 'dist') const publicDir = resolve(__dirname, '..', '..', 'public') -export default function makeManifest( +export default function createManifest( manifest: chrome.runtime.ManifestV3, config: { isDev: boolean; contentScriptCssKey?: string }, ): PluginOption { diff --git a/utils/reload/initReloadClient.ts b/utils/reload/initReloadClient.ts index 1df9c555..c0015fcd 100644 --- a/utils/reload/initReloadClient.ts +++ b/utils/reload/initReloadClient.ts @@ -43,6 +43,7 @@ export default function initReloadClient({ }) socket.onclose = () => { + // eslint-disable-next-line no-console console.warn( `Reload server disconnected.\nPlease check if the WebSocket server is running properly on ${LOCAL_RELOAD_SOCKET_URL}. This feature detects changes in the code and helps the browser to reload the extension or refresh the current tab.`, ) diff --git a/utils/reload/initReloadServer.js b/utils/reload/initReloadServer.js index d04bfa3c..fbf8e19c 100644 --- a/utils/reload/initReloadServer.js +++ b/utils/reload/initReloadServer.js @@ -1,14 +1,7 @@ -import { WebSocketServer } from 'ws' -import chokidar from 'chokidar' +/* eslint-disable */ +import { watch } from 'chokidar' import { clearTimeout } from 'timers' - -function debounce(callback, delay) { - let timer - return function (...args) { - clearTimeout(timer) - timer = setTimeout(() => callback(...args), delay) - } -} +import { WebSocketServer } from 'ws' const LOCAL_RELOAD_SOCKET_PORT = 8081 const LOCAL_RELOAD_SOCKET_URL = `ws://localhost:${LOCAL_RELOAD_SOCKET_PORT}` @@ -27,9 +20,19 @@ class MessageInterpreter { } } +/* eslint-disable */ +function debounce(callback, delay) { + let timer + return function (...args) { + clearTimeout(timer) + timer = setTimeout(() => callback(...args), delay) + } +} + const clientsThatNeedToUpdate = new Set() function initReloadServer() { const wss = new WebSocketServer({ port: LOCAL_RELOAD_SOCKET_PORT }) + // eslint-disable-next-line no-console wss.on('listening', () => console.log(`[HRS] Server listening at ${LOCAL_RELOAD_SOCKET_URL}`)) wss.on('connection', ws => { clientsThatNeedToUpdate.add(ws) @@ -56,14 +59,14 @@ const debounceSrc = debounce(function (path) { ) // Delay waiting for public assets to be copied }, 400) -chokidar.watch('src').on('all', (event, path) => debounceSrc(path)) +watch('src').on('all', (event, path) => debounceSrc(path)) /** CHECK:: build was completed **/ const debounceDist = debounce(() => { clientsThatNeedToUpdate.forEach(ws => { ws.send(MessageInterpreter.send({ type: UPDATE_REQUEST_MESSAGE })) }) }, 100) -chokidar.watch('dist').on('all', event => { +watch('dist').on('all', event => { // Ignore unlink, unlinkDir and change events // that happen in beginning of build:watch and // that will cause ws.send() if it takes more than 400ms diff --git a/utils/reload/initReloadServer.ts b/utils/reload/initReloadServer.ts index 8f05fd99..ef7db7e5 100644 --- a/utils/reload/initReloadServer.ts +++ b/utils/reload/initReloadServer.ts @@ -1,4 +1,4 @@ -import chokidar from 'chokidar' +import { watch } from 'chokidar' import { WebSocket, WebSocketServer } from 'ws' import { @@ -16,6 +16,7 @@ const clientsThatNeedToUpdate: Set = new Set() function initReloadServer() { const wss = new WebSocketServer({ port: LOCAL_RELOAD_SOCKET_PORT }) + // eslint-disable-next-line no-console wss.on('listening', () => console.log(`[HRS] Server listening at ${LOCAL_RELOAD_SOCKET_URL}`)) wss.on('connection', ws => { @@ -45,7 +46,7 @@ const debounceSrc = debounce(function (path: string) { ) // Delay waiting for public assets to be copied }, 400) -chokidar.watch('src').on('all', (event, path) => debounceSrc(path)) +watch('src').on('all', (event, path) => debounceSrc(path)) /** CHECK:: build was completed **/ const debounceDist = debounce(() => { @@ -53,7 +54,7 @@ const debounceDist = debounce(() => { ws.send(MessageInterpreter.send({ type: UPDATE_REQUEST_MESSAGE })) }) }, 100) -chokidar.watch('dist').on('all', event => { +watch('dist').on('all', event => { // Ignore unlink, unlinkDir and change events // that happen in beginning of build:watch and // that will cause ws.send() if it takes more than 400ms diff --git a/utils/reload/injections/script.js b/utils/reload/injections/script.js index a3df2004..fb5ff160 100644 --- a/utils/reload/injections/script.js +++ b/utils/reload/injections/script.js @@ -41,6 +41,7 @@ function initReloadClient({ watchPath, onUpdate }) { } }) socket.onclose = () => { + // eslint-disable-next-line no-console console.warn( `Reload server disconnected.\nPlease check if the WebSocket server is running properly on ${LOCAL_RELOAD_SOCKET_URL}. This feature detects changes in the code and helps the browser to reload the extension or refresh the current tab.`, ) diff --git a/utils/reload/injections/view.js b/utils/reload/injections/view.js index a0bd529e..28f98d7f 100644 --- a/utils/reload/injections/view.js +++ b/utils/reload/injections/view.js @@ -41,6 +41,7 @@ function initReloadClient({ watchPath, onUpdate }) { } }) socket.onclose = () => { + // eslint-disable-next-line no-console console.warn( `Reload server disconnected.\nPlease check if the WebSocket server is running properly on ${LOCAL_RELOAD_SOCKET_URL}. This feature detects changes in the code and helps the browser to reload the extension or refresh the current tab.`, ) diff --git a/utils/reload/utils.ts b/utils/reload/utils.ts index 0fc4faa5..0c998e9f 100644 --- a/utils/reload/utils.ts +++ b/utils/reload/utils.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ import { clearTimeout } from 'timers' export function debounce(callback: (...args: A) => void, delay: number) { diff --git a/yarn.lock b/yarn.lock index 0f14e91e..1f4f53dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2535,11 +2535,21 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base64-js@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978" + integrity sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw== + binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== +bluebird@^3.0.3: + version "3.7.2" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" + integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -2694,6 +2704,14 @@ chardet@^0.7.0: optionalDependencies: fsevents "~2.3.2" +chrome@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/chrome/-/chrome-0.1.0.tgz#f61d9b792fefe8c194c7056ddc102c726a864329" + integrity sha512-6KYl20U4Taj6YipylsWr2etUvp9AElJKfGNSBmyGTymYmancnOb041ZNadolEZi2nboLXH7jMSqUmm4kpuTzfg== + dependencies: + exeq "^2.2.0" + plist "^1.1.0" + ci-info@^3.2.0: version "3.3.2" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.2.tgz#6d2967ffa407466481c6c90b6e16b3098f080128" @@ -3829,6 +3847,14 @@ execa@^5.0.0: signal-exit "^3.0.3" strip-final-newline "^2.0.0" +exeq@^2.2.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/exeq/-/exeq-2.4.0.tgz#4ddf2a684648c427ad799349cf33bd75358f884a" + integrity sha512-B648qbDS00nQZv9UQGLT5RbZm/5dNBX10F8oWeXcgpFHSLm1249u95t/3sn2wXdQjLhlF+edAECdshFtSr1K0Q== + dependencies: + bluebird "^3.0.3" + native-or-bluebird "^1.2.0" + exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -5384,6 +5410,11 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== +lodash@^3.5.0: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + integrity sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ== + lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" @@ -5551,6 +5582,11 @@ nanoid@^3.3.6: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== +native-or-bluebird@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz#39c47bfd7825d1fb9ffad32210ae25daadf101c9" + integrity sha512-0SH8UubxDfe382eYiwmd12qxAbiWGzlGZv6CkMA+DPojWa/Y0oH4hE0lRtFfFgJmPQFyKXeB8XxPbZz6TvvKaQ== + natural-compare-lite@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" @@ -5973,6 +6009,16 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" +plist@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/plist/-/plist-1.2.0.tgz#084b5093ddc92506e259f874b8d9b1afb8c79593" + integrity sha512-dL9Xc2Aj3YyBnwvCNuHmFl2LWvQacm/HEAsoVwLiuu0POboMChETt5wexpU1P6F6MnibIucXlVsMFFgNUT2IyA== + dependencies: + base64-js "0.0.8" + util-deprecate "1.0.2" + xmlbuilder "4.0.0" + xmldom "0.1.x" + postcss-import@^15.1.0: version "15.1.0" resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-15.1.0.tgz#41c64ed8cc0e23735a9698b3249ffdbf704adc70" @@ -7132,7 +7178,7 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -util-deprecate@^1.0.1, util-deprecate@^1.0.2: +util-deprecate@1.0.2, util-deprecate@^1.0.1, util-deprecate@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== @@ -7310,11 +7356,23 @@ xml-name-validator@^4.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835" integrity sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw== +xmlbuilder@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-4.0.0.tgz#98b8f651ca30aa624036f127d11cc66dc7b907a3" + integrity sha512-wrG9gc6hCFDd5STt+6fsjP2aGSkjkNSewH+1K6s0KVOd94vXAUyTwlxWVnMFVtLdMf+q0QRZN1z9hTOKgoEdMg== + dependencies: + lodash "^3.5.0" + xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== +xmldom@0.1.x: + version "0.1.31" + resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.31.tgz#b76c9a1bd9f0a9737e5a72dc37231cf38375e2ff" + integrity sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ== + y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"