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/JSDOMParser.js
|
||||||
packages/app-clipper/content_scripts/Readability-readerable.js
|
packages/app-clipper/content_scripts/Readability-readerable.js
|
||||||
packages/app-clipper/content_scripts/Readability.js
|
packages/app-clipper/content_scripts/Readability.js
|
||||||
|
packages/app-clipper/content_scripts/clipperUtils.js
|
||||||
packages/app-clipper/dist
|
packages/app-clipper/dist
|
||||||
packages/app-clipper/icons
|
packages/app-clipper/icons
|
||||||
packages/app-clipper/popup/build
|
packages/app-clipper/popup/build
|
||||||
|
@ -87,6 +87,7 @@ module.exports = {
|
|||||||
allowEmptyReject: true,
|
allowEmptyReject: true,
|
||||||
}],
|
}],
|
||||||
'no-throw-literal': ['error'],
|
'no-throw-literal': ['error'],
|
||||||
|
'no-unused-expressions': ['error'],
|
||||||
|
|
||||||
// This rule should not be enabled since it matters in what order
|
// This rule should not be enabled since it matters in what order
|
||||||
// imports are done, in particular in relation to the shim.setReact
|
// 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);
|
characterSetter(counter.all);
|
||||||
characterNoSpaceSetter(counter.characters);
|
characterNoSpaceSetter(counter.characters);
|
||||||
});
|
});
|
||||||
text === '' ? lineSetter(0) : lineSetter(text.split('\n').length);
|
lineSetter(text === '' ? 0 : text.split('\n').length);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatReadTime(readTimeMinutes: number) {
|
function formatReadTime(readTimeMinutes: number) {
|
||||||
|
@ -117,7 +117,7 @@ export const startRecording = (vosk: Vosk, options: StartOptions): VoiceTypingSe
|
|||||||
eventHandler.remove();
|
eventHandler.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
vosk.cleanup(),
|
vosk.cleanup();
|
||||||
|
|
||||||
state_ = State.Idle;
|
state_ = State.Idle;
|
||||||
|
|
||||||
|
@ -207,6 +207,16 @@ if (typeof window === 'undefined') {
|
|||||||
quiet: false,
|
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 n = navigator;
|
||||||
const controlling = n.serviceWorker && n.serviceWorker.controller;
|
const controlling = n.serviceWorker && n.serviceWorker.controller;
|
||||||
|
|
||||||
@ -228,7 +238,7 @@ if (typeof window === 'undefined') {
|
|||||||
: coi.coepCredentialless(),
|
: coi.coepCredentialless(),
|
||||||
});
|
});
|
||||||
if (reloadToDegrade) {
|
if (reloadToDegrade) {
|
||||||
!coi.quiet && console.log('Reloading page to degrade COEP.');
|
consoleLog('Reloading page to degrade COEP.');
|
||||||
window.sessionStorage.setItem('coiReloadedBySelf', 'coepDegrade');
|
window.sessionStorage.setItem('coiReloadedBySelf', 'coepDegrade');
|
||||||
coi.doReload();
|
coi.doReload();
|
||||||
}
|
}
|
||||||
@ -245,28 +255,28 @@ if (typeof window === 'undefined') {
|
|||||||
// if (window.crossOriginIsolated !== false || !coi.shouldRegister()) return;
|
// if (window.crossOriginIsolated !== false || !coi.shouldRegister()) return;
|
||||||
|
|
||||||
if (!window.isSecureContext) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In some environments (e.g. Firefox private mode) this won't be available
|
// In some environments (e.g. Firefox private mode) this won't be available
|
||||||
if (!n.serviceWorker) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const registration = await n.serviceWorker.register(window.document.currentScript.getAttribute('src'));
|
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', () => {
|
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');
|
window.sessionStorage.setItem('coiReloadedBySelf', 'updatefound');
|
||||||
coi.doReload();
|
coi.doReload();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the registration is active, but it's not controlling the page
|
// If the registration is active, but it's not controlling the page
|
||||||
if (registration.active && !n.serviceWorker.controller) {
|
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');
|
window.sessionStorage.setItem('coiReloadedBySelf', 'notControlling');
|
||||||
coi.doReload();
|
coi.doReload();
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ const yargs = require('yargs');
|
|||||||
|
|
||||||
|
|
||||||
const build = () => {
|
const build = () => {
|
||||||
|
// eslint-disable-next-line no-unused-expressions -- Old code before rule was applied
|
||||||
yargs
|
yargs
|
||||||
.usage('$0 <cmd> [args]')
|
.usage('$0 <cmd> [args]')
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// 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) {
|
if (!accountProperties) {
|
||||||
accountProperties = await api.execAccountPropertiesRequest();
|
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));
|
Setting.setValue(`sync.${this.syncTargetId()}.context`, JSON.stringify(context));
|
||||||
}
|
}
|
||||||
api.setAccountProperties(accountProperties);
|
api.setAccountProperties(accountProperties);
|
||||||
|
@ -139,4 +139,5 @@ export function getStyleSheets(doc: Document) {
|
|||||||
|
|
||||||
// Required to run in Firefox with tabs.executeScript. See
|
// Required to run in Firefox with tabs.executeScript. See
|
||||||
// https://stackoverflow.com/a/44774834
|
// https://stackoverflow.com/a/44774834
|
||||||
|
// eslint-disable-next-line no-unused-expressions -- Old code before rule was applied
|
||||||
undefined;
|
undefined;
|
||||||
|
@ -113,6 +113,7 @@ export async function testStringPerformance(method: EncryptionMethod, dataSize:
|
|||||||
const deserialized = await Note.unserialize(serialized);
|
const deserialized = await Note.unserialize(serialized);
|
||||||
const decryptedNote = await Note.decrypt(deserialized);
|
const decryptedNote = await Note.decrypt(deserialized);
|
||||||
const tick3 = performance.now();
|
const tick3 = performance.now();
|
||||||
|
// eslint-disable-next-line no-unused-expressions -- Old code before rule was applied
|
||||||
(decryptedNote.title === note.title);
|
(decryptedNote.title === note.title);
|
||||||
encryptTime += tick2 - tick1;
|
encryptTime += tick2 - tick1;
|
||||||
decryptTime += tick3 - tick2;
|
decryptTime += tick3 - tick2;
|
||||||
|
@ -135,7 +135,7 @@ export default class OcrService {
|
|||||||
const result = await this.recognize(language, resource);
|
const result = await this.recognize(language, resource);
|
||||||
toSave.ocr_status = ResourceOcrStatus.Done;
|
toSave.ocr_status = ResourceOcrStatus.Done;
|
||||||
toSave.ocr_text = filterOcrText(result.text);
|
toSave.ocr_text = filterOcrText(result.text);
|
||||||
toSave.ocr_details = Resource.serializeOcrDetails(result.lines),
|
toSave.ocr_details = Resource.serializeOcrDetails(result.lines);
|
||||||
toSave.ocr_error = '';
|
toSave.ocr_error = '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = typeof error === 'string' ? error : error?.message;
|
const errorMessage = typeof error === 'string' ? error : error?.message;
|
||||||
|
@ -117,7 +117,7 @@ describe('synchronizer/ItemUploader', () => {
|
|||||||
expect(callRecorder.length).toBe(0);
|
expect(callRecorder.length).toBe(0);
|
||||||
|
|
||||||
await time.msleep(1);
|
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]);
|
await itemUploader.serializeAndUploadItem(Note, BaseItem.systemPath(notes[1]), notes[1]);
|
||||||
expect(callRecorder.length).toBe(1);
|
expect(callRecorder.length).toBe(1);
|
||||||
}));
|
}));
|
||||||
|
@ -465,7 +465,7 @@ function shimInit(options: ShimInitOptions = null) {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error('Unsupported method');
|
throw new Error('Unsupported method');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
shim.imageFromDataUrl = async function(imageDataUrl, filePath, options = null) {
|
shim.imageFromDataUrl = async function(imageDataUrl, filePath, options = null) {
|
||||||
if (options === null) options = {};
|
if (options === null) options = {};
|
||||||
|
@ -302,6 +302,7 @@ async function main() {
|
|||||||
selectedCommandArgs = args;
|
selectedCommandArgs = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-expressions -- Old code before rule was applied
|
||||||
require('yargs')
|
require('yargs')
|
||||||
.scriptName(scriptName)
|
.scriptName(scriptName)
|
||||||
.usage('$0 <cmd> [args]')
|
.usage('$0 <cmd> [args]')
|
||||||
|
@ -68,7 +68,7 @@ router.get('items', async (_path: SubPath, ctx: AppContext) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const view: View = defaultView('items', 'Items');
|
const view: View = defaultView('items', 'Items');
|
||||||
view.content.itemTable = makeTableView(table),
|
view.content.itemTable = makeTableView(table);
|
||||||
view.content.postUrl = `${config().baseUrl}/items`;
|
view.content.postUrl = `${config().baseUrl}/items`;
|
||||||
view.cssFiles = ['index/items'];
|
view.cssFiles = ['index/items'];
|
||||||
return view;
|
return view;
|
||||||
|
@ -65,7 +65,7 @@ describe('TaskService', () => {
|
|||||||
const tasks = createDemoTasks();
|
const tasks = createDemoTasks();
|
||||||
tasks[0].run = async (_models: Models) => {
|
tasks[0].run = async (_models: Models) => {
|
||||||
taskHasRan = true;
|
taskHasRan = true;
|
||||||
},
|
};
|
||||||
await service.registerTasks(tasks);
|
await service.registerTasks(tasks);
|
||||||
const taskId = tasks[0].id;
|
const taskId = tasks[0].id;
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@ interface Contributor {
|
|||||||
html_url: string;
|
html_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
rootDir;
|
|
||||||
|
|
||||||
const readmePath = `${rootDir}/README.md`;
|
const readmePath = `${rootDir}/README.md`;
|
||||||
const { insertContentIntoFile } = require('./tool-utils.js');
|
const { insertContentIntoFile } = require('./tool-utils.js');
|
||||||
|
|
||||||
|
@ -159,13 +159,13 @@ const processToken = (token: any, output: string[], context: Context): void => {
|
|||||||
context.inFence = true;
|
context.inFence = true;
|
||||||
content.push(`\`\`\`${token.info || ''}\n`);
|
content.push(`\`\`\`${token.info || ''}\n`);
|
||||||
} else if (type === 'html_block') {
|
} else if (type === 'html_block') {
|
||||||
contentProcessed = true,
|
contentProcessed = true;
|
||||||
content.push(parseHtml(token.content.trim()));
|
content.push(parseHtml(token.content.trim()));
|
||||||
} else if (type === 'html_inline') {
|
} else if (type === 'html_inline') {
|
||||||
contentProcessed = true,
|
contentProcessed = true;
|
||||||
content.push(parseHtml(token.content.trim()));
|
content.push(parseHtml(token.content.trim()));
|
||||||
} else if (type === 'code_inline') {
|
} else if (type === 'code_inline') {
|
||||||
contentProcessed = true,
|
contentProcessed = true;
|
||||||
content.push(`\`${token.content}\``);
|
content.push(`\`${token.content}\``);
|
||||||
} else if (type === 'code_block') {
|
} else if (type === 'code_block') {
|
||||||
contentProcessed = true;
|
contentProcessed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user