mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Chore: Implement eslint rule no-unused-expressions
(#11533)
This commit is contained in:
parent
482c9e9aab
commit
3cba4ec82c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -117,7 +117,7 @@ export const startRecording = (vosk: Vosk, options: StartOptions): VoiceTypingSe
|
||||
eventHandler.remove();
|
||||
}
|
||||
|
||||
vosk.cleanup(),
|
||||
vosk.cleanup();
|
||||
|
||||
state_ = State.Idle;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 <cmd> [args]')
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}));
|
||||
|
@ -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 = {};
|
||||
|
@ -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 <cmd> [args]')
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -8,8 +8,6 @@ interface Contributor {
|
||||
html_url: string;
|
||||
}
|
||||
|
||||
rootDir;
|
||||
|
||||
const readmePath = `${rootDir}/README.md`;
|
||||
const { insertContentIntoFile } = require('./tool-utils.js');
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user