diff --git a/.eslintignore b/.eslintignore index 9714669e5..bd4bc312a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -31,6 +31,7 @@ packages/app-cli/tests/tmp packages/app-clipper/content_scripts/JSDOMParser.js packages/app-clipper/content_scripts/Readability-readerable.js packages/app-clipper/content_scripts/Readability.js +packages/app-clipper/content_scripts/clipperUtils.js packages/app-clipper/dist packages/app-clipper/icons packages/app-clipper/popup/build diff --git a/.eslintrc.js b/.eslintrc.js index 7e4a0632c..2f8f2c9de 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -87,6 +87,7 @@ module.exports = { allowEmptyReject: true, }], 'no-throw-literal': ['error'], + 'no-unused-expressions': ['error'], // This rule should not be enabled since it matters in what order // imports are done, in particular in relation to the shim.setReact diff --git a/packages/app-desktop/gui/NoteContentPropertiesDialog.tsx b/packages/app-desktop/gui/NoteContentPropertiesDialog.tsx index 296583360..71aaf27b1 100644 --- a/packages/app-desktop/gui/NoteContentPropertiesDialog.tsx +++ b/packages/app-desktop/gui/NoteContentPropertiesDialog.tsx @@ -38,7 +38,7 @@ function countElements(text: string, wordSetter: Function, characterSetter: Func characterSetter(counter.all); characterNoSpaceSetter(counter.characters); }); - text === '' ? lineSetter(0) : lineSetter(text.split('\n').length); + lineSetter(text === '' ? 0 : text.split('\n').length); } function formatReadTime(readTimeMinutes: number) { diff --git a/packages/app-mobile/services/voiceTyping/vosk.android.ts b/packages/app-mobile/services/voiceTyping/vosk.android.ts index 157249ab5..cd23d6e27 100644 --- a/packages/app-mobile/services/voiceTyping/vosk.android.ts +++ b/packages/app-mobile/services/voiceTyping/vosk.android.ts @@ -117,7 +117,7 @@ export const startRecording = (vosk: Vosk, options: StartOptions): VoiceTypingSe eventHandler.remove(); } - vosk.cleanup(), + vosk.cleanup(); state_ = State.Idle; diff --git a/packages/app-mobile/web/serviceWorker.ts b/packages/app-mobile/web/serviceWorker.ts index 40c1f8525..f5ee4bea2 100644 --- a/packages/app-mobile/web/serviceWorker.ts +++ b/packages/app-mobile/web/serviceWorker.ts @@ -207,6 +207,16 @@ if (typeof window === 'undefined') { quiet: false, }; + const consoleLog = (...args: unknown[]) => { + if (coi.quiet) return; + console.log(...args); + }; + + const consoleError = (...args: unknown[]) => { + if (coi.quiet) return; + console.error(...args); + }; + const n = navigator; const controlling = n.serviceWorker && n.serviceWorker.controller; @@ -228,7 +238,7 @@ if (typeof window === 'undefined') { : coi.coepCredentialless(), }); if (reloadToDegrade) { - !coi.quiet && console.log('Reloading page to degrade COEP.'); + consoleLog('Reloading page to degrade COEP.'); window.sessionStorage.setItem('coiReloadedBySelf', 'coepDegrade'); coi.doReload(); } @@ -245,28 +255,28 @@ if (typeof window === 'undefined') { // if (window.crossOriginIsolated !== false || !coi.shouldRegister()) return; if (!window.isSecureContext) { - !coi.quiet && console.log('COOP/COEP Service Worker not registered, a secure context is required.'); + consoleLog('COOP/COEP Service Worker not registered, a secure context is required.'); return; } // In some environments (e.g. Firefox private mode) this won't be available if (!n.serviceWorker) { - !coi.quiet && console.error('COOP/COEP Service Worker not registered, perhaps due to private mode.'); + consoleError('COOP/COEP Service Worker not registered, perhaps due to private mode.'); return; } const registration = await n.serviceWorker.register(window.document.currentScript.getAttribute('src')); - !coi.quiet && console.log('COOP/COEP Service Worker registered', registration.scope); + consoleLog('COOP/COEP Service Worker registered', registration.scope); registration.addEventListener('updatefound', () => { - !coi.quiet && console.log('Reloading page to make use of updated COOP/COEP Service Worker.'); + consoleLog('Reloading page to make use of updated COOP/COEP Service Worker.'); window.sessionStorage.setItem('coiReloadedBySelf', 'updatefound'); coi.doReload(); }); // If the registration is active, but it's not controlling the page if (registration.active && !n.serviceWorker.controller) { - !coi.quiet && console.log('Reloading page to make use of COOP/COEP Service Worker.'); + consoleLog('Reloading page to make use of COOP/COEP Service Worker.'); window.sessionStorage.setItem('coiReloadedBySelf', 'notControlling'); coi.doReload(); } diff --git a/packages/default-plugins/build.ts b/packages/default-plugins/build.ts index 2660116ba..8978ee71e 100644 --- a/packages/default-plugins/build.ts +++ b/packages/default-plugins/build.ts @@ -4,6 +4,7 @@ const yargs = require('yargs'); const build = () => { + // eslint-disable-next-line no-unused-expressions -- Old code before rule was applied yargs .usage('$0 [args]') // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied diff --git a/packages/lib/SyncTargetOneDrive.ts b/packages/lib/SyncTargetOneDrive.ts index e434127e4..7ffe5841b 100644 --- a/packages/lib/SyncTargetOneDrive.ts +++ b/packages/lib/SyncTargetOneDrive.ts @@ -108,7 +108,11 @@ export default class SyncTargetOneDrive extends BaseSyncTarget { if (!accountProperties) { accountProperties = await api.execAccountPropertiesRequest(); - context ? context.accountProperties = accountProperties : context = { accountProperties: accountProperties }; + if (context) { + context.accountProperties = accountProperties; + } else { + context = { accountProperties: accountProperties }; + } Setting.setValue(`sync.${this.syncTargetId()}.context`, JSON.stringify(context)); } api.setAccountProperties(accountProperties); diff --git a/packages/lib/clipperUtils.ts b/packages/lib/clipperUtils.ts index 327a04548..351fb3e5c 100644 --- a/packages/lib/clipperUtils.ts +++ b/packages/lib/clipperUtils.ts @@ -139,4 +139,5 @@ export function getStyleSheets(doc: Document) { // Required to run in Firefox with tabs.executeScript. See // https://stackoverflow.com/a/44774834 +// eslint-disable-next-line no-unused-expressions -- Old code before rule was applied undefined; diff --git a/packages/lib/services/e2ee/cryptoTestUtils.ts b/packages/lib/services/e2ee/cryptoTestUtils.ts index 0c56f9311..795762e37 100644 --- a/packages/lib/services/e2ee/cryptoTestUtils.ts +++ b/packages/lib/services/e2ee/cryptoTestUtils.ts @@ -113,6 +113,7 @@ export async function testStringPerformance(method: EncryptionMethod, dataSize: const deserialized = await Note.unserialize(serialized); const decryptedNote = await Note.decrypt(deserialized); const tick3 = performance.now(); + // eslint-disable-next-line no-unused-expressions -- Old code before rule was applied (decryptedNote.title === note.title); encryptTime += tick2 - tick1; decryptTime += tick3 - tick2; diff --git a/packages/lib/services/ocr/OcrService.ts b/packages/lib/services/ocr/OcrService.ts index a5fc22a41..5b2164160 100644 --- a/packages/lib/services/ocr/OcrService.ts +++ b/packages/lib/services/ocr/OcrService.ts @@ -135,7 +135,7 @@ export default class OcrService { const result = await this.recognize(language, resource); toSave.ocr_status = ResourceOcrStatus.Done; toSave.ocr_text = filterOcrText(result.text); - toSave.ocr_details = Resource.serializeOcrDetails(result.lines), + toSave.ocr_details = Resource.serializeOcrDetails(result.lines); toSave.ocr_error = ''; } catch (error) { const errorMessage = typeof error === 'string' ? error : error?.message; diff --git a/packages/lib/services/synchronizer/ItemUploader.test.ts b/packages/lib/services/synchronizer/ItemUploader.test.ts index 7f4643880..cecba80d2 100644 --- a/packages/lib/services/synchronizer/ItemUploader.test.ts +++ b/packages/lib/services/synchronizer/ItemUploader.test.ts @@ -117,7 +117,7 @@ describe('synchronizer/ItemUploader', () => { expect(callRecorder.length).toBe(0); await time.msleep(1); - notes[1] = await Note.save({ title: '22' }), + notes[1] = await Note.save({ title: '22' }); await itemUploader.serializeAndUploadItem(Note, BaseItem.systemPath(notes[1]), notes[1]); expect(callRecorder.length).toBe(1); })); diff --git a/packages/lib/shim-init-node.ts b/packages/lib/shim-init-node.ts index 2c0dec44a..4f50e8bda 100644 --- a/packages/lib/shim-init-node.ts +++ b/packages/lib/shim-init-node.ts @@ -465,7 +465,7 @@ function shimInit(options: ShimInitOptions = null) { } else { throw new Error('Unsupported method'); } - }, + }; shim.imageFromDataUrl = async function(imageDataUrl, filePath, options = null) { if (options === null) options = {}; diff --git a/packages/plugin-repo-cli/index.ts b/packages/plugin-repo-cli/index.ts index cdeb93ad8..f8091d9c7 100644 --- a/packages/plugin-repo-cli/index.ts +++ b/packages/plugin-repo-cli/index.ts @@ -302,6 +302,7 @@ async function main() { selectedCommandArgs = args; } + // eslint-disable-next-line no-unused-expressions -- Old code before rule was applied require('yargs') .scriptName(scriptName) .usage('$0 [args]') diff --git a/packages/server/src/routes/index/items.ts b/packages/server/src/routes/index/items.ts index 8bdf61bab..4d122f52e 100644 --- a/packages/server/src/routes/index/items.ts +++ b/packages/server/src/routes/index/items.ts @@ -68,7 +68,7 @@ router.get('items', async (_path: SubPath, ctx: AppContext) => { }; const view: View = defaultView('items', 'Items'); - view.content.itemTable = makeTableView(table), + view.content.itemTable = makeTableView(table); view.content.postUrl = `${config().baseUrl}/items`; view.cssFiles = ['index/items']; return view; diff --git a/packages/server/src/services/TaskService.test.ts b/packages/server/src/services/TaskService.test.ts index 7c48b26b6..6b6164156 100644 --- a/packages/server/src/services/TaskService.test.ts +++ b/packages/server/src/services/TaskService.test.ts @@ -65,7 +65,7 @@ describe('TaskService', () => { const tasks = createDemoTasks(); tasks[0].run = async (_models: Models) => { taskHasRan = true; - }, + }; await service.registerTasks(tasks); const taskId = tasks[0].id; diff --git a/packages/tools/update-readme-contributors.ts b/packages/tools/update-readme-contributors.ts index 8a1ddd44a..4e9532d96 100644 --- a/packages/tools/update-readme-contributors.ts +++ b/packages/tools/update-readme-contributors.ts @@ -8,8 +8,6 @@ interface Contributor { html_url: string; } -rootDir; - const readmePath = `${rootDir}/README.md`; const { insertContentIntoFile } = require('./tool-utils.js'); diff --git a/packages/tools/website/processDocs.ts b/packages/tools/website/processDocs.ts index db4e48c31..dbbe36a9c 100644 --- a/packages/tools/website/processDocs.ts +++ b/packages/tools/website/processDocs.ts @@ -159,13 +159,13 @@ const processToken = (token: any, output: string[], context: Context): void => { context.inFence = true; content.push(`\`\`\`${token.info || ''}\n`); } else if (type === 'html_block') { - contentProcessed = true, + contentProcessed = true; content.push(parseHtml(token.content.trim())); } else if (type === 'html_inline') { - contentProcessed = true, + contentProcessed = true; content.push(parseHtml(token.content.trim())); } else if (type === 'code_inline') { - contentProcessed = true, + contentProcessed = true; content.push(`\`${token.content}\``); } else if (type === 'code_block') { contentProcessed = true;