Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format files with prettier #1

Merged
merged 5 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions src/pages/background/index.ts
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 2 additions & 0 deletions src/pages/content/components/App/index.tsx
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
9 changes: 3 additions & 6 deletions src/pages/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ const Popup = () => {
<div className="flex items-center justify-between h-10 px-4">
<img src={logo} alt="Web Monetization Logo" className="h-6" />
<div className="">Web Monetization</div>
<img
src={close}
alt="Close"
className="h-8 cursor-pointer translate-x-1"
onClick={() => window.close()}
/>
<button className="p-0 border-0 translate-x-3" onClick={() => window.close()}>
<img src={close} alt="Close" className="h-8" />
</button>
</div>
<div>
{monetization ? (
Expand Down
2 changes: 2 additions & 0 deletions src/pages/popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable */
import '@pages/popup/index.css'

import Popup from '@pages/popup/Popup'
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() {
Expand Down
1 change: 1 addition & 0 deletions utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function colorLog(message: string, type?: ColorType) {
break
}

// eslint-disable-next-line no-console
console.log(color, message)
}

Expand Down
2 changes: 1 addition & 1 deletion utils/plugins/make-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions utils/reload/initReloadClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
)
Expand Down
27 changes: 15 additions & 12 deletions utils/reload/initReloadServer.js
Original file line number Diff line number Diff line change
@@ -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}`
Expand All @@ -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)
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions utils/reload/initReloadServer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chokidar from 'chokidar'
import { watch } from 'chokidar'
import { WebSocket, WebSocketServer } from 'ws'

import {
Expand All @@ -16,6 +16,7 @@ const clientsThatNeedToUpdate: Set<WebSocket> = 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 => {
Expand Down Expand Up @@ -45,15 +46,15 @@ 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(() => {
clientsThatNeedToUpdate.forEach((ws: WebSocket) => {
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
Expand Down
1 change: 1 addition & 0 deletions utils/reload/injections/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
)
Expand Down
1 change: 1 addition & 0 deletions utils/reload/injections/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
)
Expand Down
1 change: 1 addition & 0 deletions utils/reload/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import { clearTimeout } from 'timers'

export function debounce<A extends unknown[]>(callback: (...args: A) => void, delay: number) {
Expand Down
60 changes: 59 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==

[email protected]:
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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down Expand Up @@ -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==

[email protected]:
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==

[email protected]:
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"
Expand Down