Skip to content

Commit 114a8fe

Browse files
committed
fix: lint
1 parent a1fe08b commit 114a8fe

7 files changed

Lines changed: 44 additions & 29 deletions

File tree

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22
env: {
3-
globalThis: true,
43
browser: true,
54
node: true,
65
'jest/globals': true
@@ -35,7 +34,8 @@ module.exports = {
3534
yoda: 'off'
3635
},
3736
globals: {
38-
browser: true
37+
browser: true,
38+
globalThis: true
3939
},
4040
settings: {
4141
react: {

src/background/server.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ export class BackgroundServer {
204204
const useOffscreenHost = shouldUseOffscreenDictHost(id)
205205

206206
if (process.env.DEBUG) {
207-
console.log(`[dict-host] OPEN_DICT_SRC_PAGE ${id} -> ${useOffscreenHost ? 'offscreen' : 'background'}`)
207+
console.log(
208+
`[dict-host] OPEN_DICT_SRC_PAGE ${id} -> ${
209+
useOffscreenHost ? 'offscreen' : 'background'
210+
}`
211+
)
208212
}
209213

210214
const url = useOffscreenHost
@@ -235,7 +239,11 @@ export class BackgroundServer {
235239
const useOffscreenHost = shouldUseOffscreenDictHost(data.id)
236240

237241
if (process.env.DEBUG) {
238-
console.log(`[dict-host] FETCH_DICT_RESULT ${data.id} -> ${useOffscreenHost ? 'offscreen' : 'background'}`)
242+
console.log(
243+
`[dict-host] FETCH_DICT_RESULT ${data.id} -> ${
244+
useOffscreenHost ? 'offscreen' : 'background'
245+
}`
246+
)
239247
}
240248

241249
const runSearch = useOffscreenHost
@@ -281,7 +289,9 @@ export class BackgroundServer {
281289

282290
if (process.env.DEBUG) {
283291
console.log(
284-
`[dict-host] DICT_ENGINE_METHOD ${data.id}.${data.method} -> ${useOffscreenHost ? 'offscreen' : 'background'}`
292+
`[dict-host] DICT_ENGINE_METHOD ${data.id}.${data.method} -> ${
293+
useOffscreenHost ? 'offscreen' : 'background'
294+
}`
285295
)
286296
}
287297

src/background/sync-manager/services/webdav/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ export class Service extends SyncService<SyncConfig, SyncMeta> {
253253
return this.add({ force })
254254
}
255255

256-
async download({ testConfig, noCache }: DownloadConfig<SyncConfig>): Promise<void> {
256+
async download({
257+
testConfig,
258+
noCache
259+
}: DownloadConfig<SyncConfig>): Promise<void> {
257260
const config = testConfig || this.config
258261

259262
if (!config.url) {

src/background/windows-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export class QsPanelManager {
470470
),
471471
width: Math.round(panelWidth),
472472
height: Math.round(screenArea.availHeight)
473-
}
473+
}
474474
}
475475

476476
private async notifyQsPanelChanged(payload: boolean): Promise<void> {

src/components/dictionaries/googledict/engine.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ export const search: SearchFunction<GoogleDictResult> = async (
136136

137137
extractImg(bodyText).forEach(({ id, src }) => {
138138
try {
139-
const el = $obcontainer.querySelector(
140-
`#${id}, img[data-iid="${id}"]`
141-
)
139+
const el = $obcontainer.querySelector(`#${id}, img[data-iid="${id}"]`)
142140
if (el) {
143141
el.setAttribute('src', src)
144142
el.setAttribute('data-deferred', '2')
@@ -205,8 +203,7 @@ function extractImg(text: string): Array<{ id: string; src: string }> {
205203
}
206204
}
207205

208-
const setImageMatcher =
209-
/\(function\(\)\{var s='((?:\\.|[^'\\])*)';var ii=\[([^\]]*)\];_setImagesSrc\(ii,s\);\}\)\(\);/g
206+
const setImageMatcher = /\(function\(\)\{var s='((?:\\.|[^'\\])*)';var ii=\[([^\]]*)\];_setImagesSrc\(ii,s\);\}\)\(\);/g
210207
let setImageMatch: RegExpExecArray | null | undefined
211208
while ((setImageMatch = setImageMatcher.exec(text))) {
212209
const src = normalizeImgSrc(decodeJSString(setImageMatch[1]))
@@ -226,15 +223,17 @@ function decodeHex(m: string, code: string): string {
226223
}
227224

228225
function decodeJSString(text: string): string {
229-
return text
230-
// escape \x
231-
.replace(/\\x([\da-f]{2})/gi, decodeHex)
232-
// escape \u
233-
.replace(/\\u([\da-f]{4})/gi, decodeHex)
234-
.replace(/\\([\\/"'])/g, '$1')
235-
.replace(/\\n/g, '\n')
236-
.replace(/\\r/g, '\r')
237-
.replace(/\\t/g, '\t')
226+
return (
227+
text
228+
// escape \x
229+
.replace(/\\x([\da-f]{2})/gi, decodeHex)
230+
// escape \u
231+
.replace(/\\u([\da-f]{4})/gi, decodeHex)
232+
.replace(/\\([\\/"'])/g, '$1')
233+
.replace(/\\n/g, '\n')
234+
.replace(/\\r/g, '\r')
235+
.replace(/\\t/g, '\t')
236+
)
238237
}
239238

240239
function normalizeImgSrc(src: string): string {

src/components/dictionaries/zdic/engine.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export const search: SearchFunction<ZdicResult> = (
3333
const isAudio = profile.dicts.all.zdic.options.audio
3434
const ensureAudioReferer = isAudio
3535
? ensureZdicAudioReferer().catch(error => {
36-
console.error('Failed to enable Zdic audio referer compatibility.', error)
36+
console.error(
37+
'Failed to enable Zdic audio referer compatibility.',
38+
error
39+
)
3740
})
3841
: Promise.resolve()
3942

src/options/helpers/use-check-dict-auth.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { useContext } from 'react'
2-
import { message } from 'antd'
3-
import { objectKeys } from '@/typings/helpers'
4-
import { updateConfig } from '@/_helpers/config-manager'
5-
import { useTranslate } from '@/_helpers/i18n'
6-
import { useStore } from '@/content/redux'
7-
import { ChangeEntryContext } from './change-entry'
1+
// import { useContext } from 'react'
2+
// import { message } from 'antd'
3+
// import { objectKeys } from '@/typings/helpers'
4+
// import { updateConfig } from '@/_helpers/config-manager'
5+
// import { useTranslate } from '@/_helpers/i18n'
6+
// import { useStore } from '@/content/redux'
7+
// import { ChangeEntryContext } from './change-entry'
88

99
export const useCheckDictAuth = () => {
1010
// const { t } = useTranslate('options')

0 commit comments

Comments
 (0)