1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-11 11:12:03 +02:00

Tools: Apply eslint rules "no-console" and "id-denylist"

This commit is contained in:
Laurent Cozic 2023-02-16 10:55:24 +00:00
parent 625689dbb1
commit 7fa1459dc3
77 changed files with 183 additions and 79 deletions

View File

@ -77,6 +77,7 @@ module.exports = {
'no-array-constructor': ['error'],
'radix': ['error'],
'eqeqeq': ['error', 'always'],
'no-console': ['error', { 'allow': ['warn', 'error'] }],
// Warn only for now because fixing everything would take too much
// refactoring, but new code should try to stick to it.
@ -135,6 +136,13 @@ module.exports = {
'spaced-comment': ['error', 'always'],
'keyword-spacing': ['error', { 'before': true, 'after': true }],
'no-multi-spaces': ['error'],
// Regarding the keyword blacklist:
// - err: We generally avoid using too many abbreviations, so it should
// be "error", not "err"
// - notebook: In code, it should always be "folder" (not "notebook").
// In user-facing text, it should be "notebook".
'id-denylist': ['error', 'err', 'notebook', 'notebooks'],
},
'plugins': [
'react',
@ -147,6 +155,16 @@ module.exports = {
'promise',
],
'overrides': [
{
'files': [
'packages/tools/**',
'packages/app-mobile/tools/**',
'packages/app-desktop/tools/**',
],
'rules': {
'no-console': 'off',
},
},
{
// enable the rule specifically for TypeScript files
'files': ['*.ts', '*.tsx'],

View File

@ -246,6 +246,7 @@ class Application extends BaseApplication {
showConsole: () => {},
maximizeConsole: () => {},
stdout: text => {
// eslint-disable-next-line no-console
console.info(text);
},
fullScreen: () => {},
@ -407,6 +408,7 @@ class Application extends BaseApplication {
if (this.showStackTraces_) {
console.error(error);
} else {
// eslint-disable-next-line no-console
console.info(error.message);
}
process.exit(1);

View File

@ -131,6 +131,7 @@ async function main() {
const commandsText = commandBlocks.join('\n\n');
const footerText = getFooter();
// eslint-disable-next-line no-console
console.info(`${headerText}\n\n` + 'USAGE' + `\n\n${commandsText}\n\n${footerText}`);
}

View File

@ -1,5 +1,7 @@
'use strict';
/* eslint-disable no-console */
const fs = require('fs-extra');
const Logger = require('@joplin/lib/Logger').default;
const { dirname } = require('@joplin/lib/path-utils');

View File

@ -39,9 +39,9 @@ class Command extends BaseCommand {
let settingsObj;
try {
settingsObj = JSON.parse(json);
} catch (err) {
} catch (error) {
isSettled = true;
return reject(new Error(`Invalid JSON passed to config --import: \n${err.message}.`));
return reject(new Error(`Invalid JSON passed to config --import: \n${error.message}.`));
}
if (settingsObj) {
Object.entries(settingsObj)

View File

@ -118,6 +118,7 @@ class Command extends BaseCommand {
}
await Promise.all(promises);
// eslint-disable-next-line no-console
console.info(await api.exec('GET', 'api/items/root:/testing:'));
}

View File

@ -80,9 +80,9 @@ if (process.platform === 'win32') {
});
}
process.stdout.on('error', function(err) {
process.stdout.on('error', function(error) {
// https://stackoverflow.com/questions/12329816/error-write-epipe-when-piping-node-output-to-head#15884508
if (err.code === 'EPIPE') {
if (error.code === 'EPIPE') {
process.exit(0);
}
});

View File

@ -11,6 +11,7 @@ function createConsoleWrapper(pluginId: string) {
const wrapper: any = {};
for (const n in console) {
// eslint-disable-next-line no-console
if (!console.hasOwnProperty(n)) continue;
wrapper[n] = (...args: any[]) => {
const newArgs = args.slice();

View File

@ -49,6 +49,7 @@ describe('HtmlToHtml', function() {
}
if (actualHtml !== expectedHtml) {
/* eslint-disable no-console */
console.info('');
console.info(`Error converting file: ${htmlSourceFilename}`);
console.info('--------------------------------- Got:');
@ -59,6 +60,7 @@ describe('HtmlToHtml', function() {
console.info(expectedHtml.split('\n'));
console.info('--------------------------------------------');
console.info('');
/* eslint-enable */
expect(false).toBe(true);
// return;

View File

@ -57,6 +57,7 @@ describe('HtmlToMd', function() {
result.push('--------------------------------------------');
result.push('');
// eslint-disable-next-line no-console
console.info(result.join('\n'));
// console.info('');

View File

@ -72,6 +72,7 @@ describe('MdToHtml', function() {
'',
];
// eslint-disable-next-line no-console
console.info(msg.join('\n'));
expect(false).toBe(true);

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
// This script can be used to simulate a running production environment, by
// having multiple users in parallel changing notes and synchronising.
//

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
(function() {
if (window.jopext_hasRun) return;

View File

@ -1,5 +1,7 @@
'use strict';
/* eslint-disable no-console */
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
@ -104,9 +106,9 @@ checkBrowsers(paths.appPath, isInteractive)
);
const devServer = new WebpackDevServer(compiler, serverConfig);
// Launch WebpackDevServer.
devServer.listen(port, HOST, err => {
if (err) {
return console.log(err);
devServer.listen(port, HOST, error => {
if (error) {
return console.log(error);
}
if (isInteractive) {
clearConsole();
@ -135,9 +137,9 @@ checkBrowsers(paths.appPath, isInteractive)
});
});
})
.catch(err => {
if (err && err.message) {
console.log(err.message);
.catch(error => {
if (error && error.message) {
console.log(error.message);
}
process.exit(1);
});

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
const { randomClipperPort } = require('./randomClipperPort');
function msleep(ms) {

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

View File

@ -40,6 +40,7 @@ export default class InteropServiceHelper {
const service = InteropService.instance();
const result = await service.export(fullExportOptions);
// eslint-disable-next-line no-console
console.info('Export HTML result: ', result);
return tempFile;
}
@ -190,6 +191,7 @@ export default class InteropServiceHelper {
try {
const result = await service.export(exportOptions);
// eslint-disable-next-line no-console
console.info('Export result: ', result);
} catch (error) {
console.error(error);

View File

@ -61,8 +61,8 @@ export const KeymapConfigScreen = ({ themeId }: KeymapConfigScreenProps) => {
try {
const keymapFile = await shim.fsDriver().readFile(actualFilePath, 'utf-8');
overrideKeymapItems(JSON.parse(keymapFile));
} catch (err) {
bridge().showErrorMessageBox(_('Error: %s', err.message));
} catch (error) {
bridge().showErrorMessageBox(_('Error: %s', error.message));
}
}
};
@ -77,8 +77,8 @@ export const KeymapConfigScreen = ({ themeId }: KeymapConfigScreenProps) => {
try {
// KeymapService is already synchronized with the in-state keymap
await keymapService.saveCustomKeymap(filePath);
} catch (err) {
bridge().showErrorMessageBox(err.message);
} catch (error) {
bridge().showerrororMessageBox(error.message);
}
}
};

View File

@ -62,11 +62,11 @@ const useKeymap = (): [
// Then, update the state with the data from KeymapService
// Side-effect: Changes will also be saved to the disk
setKeymapItems(keymapService.getKeymapItems());
} catch (err) {
} catch (error) {
// oldKeymapItems includes even the unchanged keymap items
// However, it is not an issue because the logic accounts for such scenarios
keymapService.overrideKeymap(oldKeymapItems);
throw err;
throw error;
}
};
@ -80,8 +80,8 @@ const useKeymap = (): [
keymapService.overrideKeymap(keymapItems);
await keymapService.saveCustomKeymap();
setKeymapError(null);
} catch (err) {
const error = new Error(`Could not save file: ${err.message}`);
} catch (error) {
error.message = `Could not save file: ${error.message}`;
setKeymapError(error);
}
}

View File

@ -172,7 +172,6 @@ class MainScreenComponent extends React.Component<Props, State> {
}
private openCallbackUrl(url: string) {
console.log(`openUrl ${url}`);
const { command, params } = parseCallbackUrl(url);
void CommandService.instance().execute(command.toString(), params.id);
}
@ -393,6 +392,7 @@ class MainScreenComponent extends React.Component<Props, State> {
async waitForNoteToSaved(noteId: string) {
while (noteId && this.props.editorNoteStatuses[noteId] === 'saving') {
// eslint-disable-next-line no-console
console.info('Waiting for note to be saved...', this.props.editorNoteStatuses);
await time.msleep(100);
}
@ -401,6 +401,7 @@ class MainScreenComponent extends React.Component<Props, State> {
async printTo_(target: string, options: any) {
// Concurrent print calls are disallowed to avoid incorrect settings being restored upon completion
if (this.isPrinting_) {
// eslint-disable-next-line no-console
console.info(`Printing ${options.path} to ${target} disallowed, already printing.`);
return;
}

View File

@ -14,7 +14,6 @@ export const runtime = (): CommandRuntime => {
const resource = await Resource.load(resourceId);
if (!resource) throw new Error(`No such resource: ${resourceId}`);
if (resource.mime !== 'application/pdf') throw new Error(`Not a PDF: ${resource.mime}`);
console.log('Opening PDF', resource);
context.dispatch({
type: 'DIALOG_OPEN',
name: 'pdfViewer',

View File

@ -271,6 +271,7 @@ function useMenu(props: Props) {
const service = InteropService.instance();
try {
const result = await service.import(importOptions);
// eslint-disable-next-line no-console
console.info('Import result: ', result);
} catch (error) {
bridge().showErrorMessageBox(error.message);

View File

@ -351,6 +351,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
continue;
}
// eslint-disable-next-line no-console
console.info('Loading script', s.src);
await loadScript(s);

View File

@ -107,8 +107,8 @@ export const svgUriToPng = (document: Document, svg: string, width: number, heig
canvas.remove();
img.remove();
resolve(buff);
} catch (err) {
cleanUpAndReject(err);
} catch (error) {
cleanUpAndReject(error);
}
};
img.onerror = function(e) {

View File

@ -13,6 +13,7 @@ export default function useMessageHandler(scrollWhenReady: any, setScrollWhenRea
const args = event.args;
const arg0 = args && args.length >= 1 ? args[0] : null;
// eslint-disable-next-line no-console
if (msg !== 'percentScroll') console.info(`Got ipc-message: ${msg}`, arg0);
if (msg.indexOf('error:') === 0) {

View File

@ -68,8 +68,6 @@ function styles_(props: Props) {
}
export function ShareNoteDialog(props: Props) {
console.info('Render ShareNoteDialog');
const [notes, setNotes] = useState<NoteEntity[]>([]);
const [recursiveShare, setRecursiveShare] = useState<boolean>(false);
const [sharesState, setSharesState] = useState<string>('unknown');

View File

@ -20,6 +20,7 @@ export default function useEffectDebugger(effectHook: any, dependencies: any, de
}, {});
if (Object.keys(changedDeps).length) {
// eslint-disable-next-line no-console
console.log('[use-effet-debugger] ', changedDeps);
}

View File

@ -20,6 +20,7 @@ export default function useImperativeHandleDebugger(ref: any, effectHook: any, d
}, {});
if (Object.keys(changedDeps).length) {
// eslint-disable-next-line no-console
console.log('[use-imperativeHandler-debugger] ', changedDeps);
}

View File

@ -10,6 +10,7 @@ export interface Script {
export const loadScript = async (script: Script) => {
return new Promise((resolve) => {
// eslint-disable-next-line no-console
console.info('Loading script:', script);
let element: any = document.getElementById(script.id);

View File

@ -56,6 +56,7 @@ if (bridge().env() === 'dev') {
window.console = newConsole;
}
// eslint-disable-next-line no-console
console.info(`Environment: ${bridge().env()}`);
const fsDriver = new FsDriverNode();
@ -77,7 +78,9 @@ BaseItem.loadClass('Revision', Revision);
Setting.setConstant('appId', `net.cozic.joplin${bridge().env() === 'dev' ? 'dev' : ''}-desktop`);
Setting.setConstant('appType', 'desktop');
// eslint-disable-next-line no-console
console.info(`appId: ${Setting.value('appId')}`);
// eslint-disable-next-line no-console
console.info(`appType: ${Setting.value('appType')}`);
let keytar;

View File

@ -87,6 +87,7 @@ const webviewApi = {
// console.debug('UserWebviewIndex: setting html to', args.html);
window.requestAnimationFrame(() => {
// eslint-disable-next-line no-console
console.debug('UserWebviewIndex: setting html callback', args.hash);
window.postMessage({ target: 'UserWebview', message: 'htmlIsSet', hash: args.hash }, '*');
});
@ -155,6 +156,7 @@ const webviewApi = {
if (!ipc[callName]) {
console.warn('Missing IPC function:', event.data);
} else {
// eslint-disable-next-line no-console
console.debug('UserWebviewIndex: Got message', callName, args);
ipc[callName](args);
}
@ -166,6 +168,7 @@ const webviewApi = {
// Need to send it with a delay to make sure all listeners are
// ready when the message is sent.
window.requestAnimationFrame(() => {
// eslint-disable-next-line no-console
console.debug('UserWebViewIndex: calling isReady');
window.postMessage({ target: 'UserWebview', message: 'ready' }, '*');
});

View File

@ -16,6 +16,7 @@ export default function(frameWindow: any, isReady: boolean, postMessage: Functio
if (!data || data.target !== 'UserWebview') return;
// eslint-disable-next-line no-console
console.info('useHtmlLoader: message', data);
// We only update if the HTML that was loaded is the same as
@ -35,10 +36,12 @@ export default function(frameWindow: any, isReady: boolean, postMessage: Functio
}, [frameWindow, htmlHash]);
useEffect(() => {
// eslint-disable-next-line no-console
console.info('useHtmlLoader: isReady', isReady);
if (!isReady) return;
// eslint-disable-next-line no-console
console.info('useHtmlLoader: setHtml', htmlHash);
postMessage('setHtml', {

View File

@ -9,9 +9,11 @@ export default function useViewIsReady(viewRef: any) {
const [iframeContentReady, setIFrameContentReady] = useState(false);
useEffect(() => {
// eslint-disable-next-line no-console
console.debug('useViewIsReady ============== Setup Listeners');
function onIFrameReady() {
// eslint-disable-next-line no-console
console.debug('useViewIsReady: onIFrameReady');
setIFrameReady(true);
}
@ -21,6 +23,7 @@ export default function useViewIsReady(viewRef: any) {
if (!data || data.target !== 'UserWebview') return;
// eslint-disable-next-line no-console
console.debug('useViewIsReady: message', data);
if (data.message === 'ready') {
@ -30,6 +33,7 @@ export default function useViewIsReady(viewRef: any) {
const iframeDocument = viewRef.current.contentWindow.document;
// eslint-disable-next-line no-console
console.debug('useViewIsReady readyState', iframeDocument.readyState);
if (iframeDocument.readyState === 'complete') {

View File

@ -28,7 +28,7 @@ module.exports = async function() {
branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: 'pipe' }).toString().trim();
hash = execSync('git log --pretty="%h" -1', { stdio: 'pipe' }).toString().trim();
// The builds in CI are done from a 'detached HEAD' state, thus the branch name will be 'HEAD' for CI builds.
} catch (err) {
} catch (error) {
// Don't display error object as it's a "fatal" error, but
// not for us, since is it not critical information
// https://github.com/laurent22/joplin/issues/2256

View File

@ -10,6 +10,7 @@ import Setting from '@joplin/lib/models/Setting';
// We need this to suppress the useless warning
// https://github.com/oblador/react-native-vector-icons/issues/1465
// eslint-disable-next-line no-console
Icon.loadFont().catch((error: any) => { console.info(error); });
class CameraView extends Component {

View File

@ -11,6 +11,7 @@ export default function useOnMessage(onCheckboxChange: Function, noteBody: strin
// https://github.com/laurent22/joplin/issues/4494
const msg = event.nativeEvent.data;
// eslint-disable-next-line no-console
console.info('Got IPC message: ', msg);
if (msg.indexOf('checkboxclick:') === 0) {

View File

@ -315,6 +315,7 @@ function NoteEditor(props: Props, ref: any) {
const handlers: Record<string, Function> = {
onLog: (event: any) => {
// eslint-disable-next-line no-console
console.info('CodeMirror:', ...event.value);
},
@ -323,7 +324,6 @@ function NoteEditor(props: Props, ref: any) {
},
onUndoRedoDepthChange: (event: UndoRedoDepthChangeEvent) => {
console.info('onUndoRedoDepthChange', event);
props.onUndoRedoDepthChange(event);
},
@ -355,6 +355,7 @@ function NoteEditor(props: Props, ref: any) {
if (handlers[msg.name]) {
handlers[msg.name](msg.data);
} else {
// eslint-disable-next-line no-console
console.info('Unsupported CodeMirror message:', msg);
}
}, [props.onSelectionChange, props.onUndoRedoDepthChange, props.onChange, editorControl]);

View File

@ -23,6 +23,7 @@ import CustomButton from './CustomButton';
// We need this to suppress the useless warning
// https://github.com/oblador/react-native-vector-icons/issues/1465
// eslint-disable-next-line no-console
Icon.loadFont().catch((error: any) => { console.info(error); });
// Rather than applying a padding to the whole bar, it is applied to each

View File

@ -4,6 +4,7 @@ const { View, TouchableHighlight } = require('react-native');
const Icon = require('react-native-vector-icons/Ionicons').default;
// We need this to suppress the useless warning
// https://github.com/oblador/react-native-vector-icons/issues/1465
// eslint-disable-next-line no-console
Icon.loadFont().catch((error) => { console.info(error); });
const styles = {

View File

@ -542,6 +542,7 @@ class NoteScreenComponent extends BaseScreenComponent {
private async pickDocuments() {
const result = await shim.fsDriver().pickDocument({ multiple: true });
if (!result) {
// eslint-disable-next-line no-console
console.info('pickDocuments: user has cancelled');
}
return result;

View File

@ -11,6 +11,7 @@ const naturalCompare = require('string-natural-compare');
// We need this to suppress the useless warning
// https://github.com/oblador/react-native-vector-icons/issues/1465
// eslint-disable-next-line no-console
Icon.loadFont().catch((error) => { console.info(error); });
class NoteTagsDialogComponent extends React.Component {

View File

@ -17,6 +17,7 @@ import { AppState } from '../../utils/types';
// We need this to suppress the useless warning
// https://github.com/oblador/react-native-vector-icons/issues/1465
// eslint-disable-next-line no-console
Icon.loadFont().catch((error: any) => { console.info(error); });
class SearchScreenComponent extends BaseScreenComponent {

View File

@ -7,6 +7,7 @@ const { themeStyle } = require('./global-style.js');
// We need this to suppress the useless warning
// https://github.com/oblador/react-native-vector-icons/issues/1465
// eslint-disable-next-line no-console
Icon.loadFont().catch((error) => { console.info(error); });
class SideMenuContentNoteComponent extends Component {

View File

@ -17,6 +17,7 @@ import { ProfileConfig } from '@joplin/lib/services/profileConfig/types';
// We need this to suppress the useless warning
// https://github.com/oblador/react-native-vector-icons/issues/1465
// eslint-disable-next-line no-console
Icon.loadFont().catch((error: any) => { console.info(error); });
interface Props {

View File

@ -340,7 +340,7 @@ PODS:
- RCTTypeSafety
- React-Core
- ReactCommon/turbomodule/core
- react-native-slider (4.4.1):
- react-native-slider (4.4.2):
- React-Core
- react-native-sqlite-storage (6.0.1):
- React-Core
@ -726,7 +726,7 @@ SPEC CHECKSUMS:
react-native-rsa-native: 12132eb627797529fdb1f0d22fd0f8f9678df64a
react-native-saf-x: 22bcd49188a04d6d6df254ca33085f26e28879c9
react-native-safe-area-context: 39c2d8be3328df5d437ac1700f4f3a4f75716acc
react-native-slider: a0d45ce5ea1be39f149954cae4367afff44d5a32
react-native-slider: 33b8d190b59d4f67a541061bb91775d53d617d9d
react-native-sqlite-storage: f6d515e1c446d1e6d026aa5352908a25d4de3261
react-native-version-info: a106f23009ac0db4ee00de39574eb546682579b9
react-native-webview: 9f111dfbcfc826084d6c507f569e5e03342ee1c1

View File

@ -108,11 +108,11 @@ class BundledFile {
await writeFile(md5Path, newMd5, 'utf8');
}
private handleErrors(err: Error | undefined | null, stats: webpack.Stats | undefined): boolean {
private handleErrors(error: Error | undefined | null, stats: webpack.Stats | undefined): boolean {
let failed = false;
if (err) {
console.error(`Error: ${err.name}`, err.message, err.stack);
if (error) {
console.error(`Error: ${error.name}`, error.message, error.stack);
failed = true;
} else if (stats?.hasErrors() || stats?.hasWarnings()) {
const data = stats.toJson();
@ -153,8 +153,8 @@ class BundledFile {
return new Promise<void>((resolve, reject) => {
console.info(`Building bundle: ${this.bundleName}...`);
compiler.run((err, stats) => {
let failed = this.handleErrors(err, stats);
compiler.run((error, stats) => {
let failed = this.handleErrors(error, stats);
// Clean up.
compiler.close(async (error) => {
@ -180,8 +180,8 @@ class BundledFile {
};
console.info('Watching bundle: ', this.bundleName);
compiler.watch(watchOptions, async (err, stats) => {
const failed = this.handleErrors(err, stats);
compiler.watch(watchOptions, async (error, stats) => {
const failed = this.handleErrors(error, stats);
if (!failed) {
await this.uglify();
await this.copyToImportableFile();

View File

@ -296,6 +296,7 @@ export default class FsDriverRN extends FsDriverBase {
}
} catch (error) {
if (DocumentPicker.isCancel(error) || error?.message?.includes('cancel')) {
// eslint-disable-next-line no-console
console.info('pickDocuments: user has cancelled');
return null;
} else {

View File

@ -41,6 +41,8 @@ function shimInit() {
// uses the native XMLHttpRequest which is more likely to get the proper
// response and error message.
/* eslint-disable no-console */
shim.debugFetch = async (url, options = null) => {
options = {
method: 'GET',
@ -81,6 +83,8 @@ function shimInit() {
});
};
/* eslint-enable */
shim.fetch = async function(url, options = null) {
// The native fetch() throws an uncatchable error that crashes the
// app if calling it with an invalid URL such as '//.resource' or

View File

@ -2,6 +2,7 @@ import joplin from 'api';
joplin.plugins.register({
onStart: async function() {
// eslint-disable-next-line no-console
console.info('Hello world. Test plugin started!');
},
});

View File

@ -6,6 +6,8 @@
// update, you can easily restore the functionality you've added.
// -----------------------------------------------------------------------------
/* eslint-disable no-console */
const path = require('path');
const crypto = require('crypto');
const fs = require('fs-extra');

View File

@ -5,7 +5,7 @@ class Cache {
const storage = await Cache.storage();
output = await storage.getItem(name);
} catch (error) {
console.info(error);
// console.info(error);
// Defaults to returning null
}
return output;

View File

@ -111,8 +111,8 @@ class SyncTargetAmazonS3 extends BaseSyncTarget {
new HeadBucketCommand({
Bucket: options.path(),
}), (err, response) => {
if (err) reject(err);
}), (error, response) => {
if (error) reject(error);
else resolve(response);
});
});

View File

@ -119,6 +119,7 @@ export default class Database {
const queryId = this.queryId_++;
if (this.profilingEnabled_) {
// eslint-disable-next-line no-console
console.info(`SQL START ${queryId}`, sql, params);
profilingTimeoutId = shim.setInterval(() => {
@ -132,6 +133,7 @@ export default class Database {
shim.clearInterval(profilingTimeoutId);
profilingTimeoutId = null;
const elapsed = Date.now() - callStartTime;
// eslint-disable-next-line no-console
if (elapsed > 10) console.info(`SQL END ${queryId}`, elapsed, sql, params);
}

View File

@ -65,8 +65,8 @@ class FileApiDriverAmazonS3 {
Prefix: key,
Delimiter: '/',
ContinuationToken: cursor,
}), (err, response) => {
if (err) reject(err);
}), (error, response) => {
if (error) reject(error);
else resolve(response);
});
});
@ -78,8 +78,8 @@ class FileApiDriverAmazonS3 {
this.api().send(new HeadObjectCommand({
Bucket: this.s3_bucket_,
Key: key,
}), (err, response) => {
if (err) reject(err);
}), (error, response) => {
if (error) reject(error);
else resolve(response);
});
});
@ -91,8 +91,8 @@ class FileApiDriverAmazonS3 {
Bucket: this.s3_bucket_,
Key: key,
Body: body,
}), (err, response) => {
if (err) reject(err);
}), (error, response) => {
if (error) reject(error);
else resolve(response);
});
});
@ -108,8 +108,8 @@ class FileApiDriverAmazonS3 {
Key: key,
Body: Buffer.from(body, 'base64'),
ContentLength: `${fileStat.size}`,
}), (err, response) => {
if (err) reject(err);
}), (error, response) => {
if (error) reject(error);
else resolve(response);
});
});
@ -121,11 +121,10 @@ class FileApiDriverAmazonS3 {
Bucket: this.s3_bucket_,
Key: key,
}),
(err, response) => {
if (err) {
console.log(err.code);
console.log(err.message);
reject(err);
(error, response) => {
if (error) {
console.error(error);
reject(error);
} else { resolve(response); }
});
});
@ -138,11 +137,10 @@ class FileApiDriverAmazonS3 {
Bucket: this.s3_bucket_,
Delete: { Objects: keys },
}),
(err, response) => {
if (err) {
console.log(err.code);
console.log(err.message);
reject(err);
(error, response) => {
if (error) {
console.error(error);
reject(error);
} else { resolve(response); }
});
});
@ -353,8 +351,8 @@ class FileApiDriverAmazonS3 {
Bucket: this.s3_bucket_,
CopySource: this.makePath_(oldPath),
Key: newPath,
}), (err, response) => {
if (err) reject(err);
}), (error, response) => {
if (error) reject(error);
else resolve(response);
});
});
@ -383,8 +381,8 @@ class FileApiDriverAmazonS3 {
return this.api().send(new ListObjectsV2Command({
Bucket: this.s3_bucket_,
ContinuationToken: cursor,
}), (err, response) => {
if (err) reject(err);
}), (error, response) => {
if (error) reject(error);
else resolve(response);
});
});

View File

@ -54,6 +54,7 @@ describe('import-enex-md-gen', function() {
result.push('--------------------------------------------');
result.push('');
// eslint-disable-next-line no-console
console.info(result.join('\n'));
expect(false).toBe(true);

View File

@ -200,8 +200,8 @@ export default class KeymapService extends BaseService {
// Refresh the menu items so that the changes are reflected
eventManager.emit('keymapChange');
} catch (err) {
const message = err.message || '';
} catch (error) {
const message = error.message || '';
throw new Error(_('Error: %s', message));
}
}
@ -305,9 +305,9 @@ export default class KeymapService extends BaseService {
// Validate the entire keymap for duplicates
// Throws whenever there are duplicate Accelerators used in the keymap
this.validateKeymap();
} catch (err) {
} catch (error) {
this.resetKeymap(); // Discard all the changes if there are any issues
throw err;
throw error;
}
}

View File

@ -99,6 +99,7 @@ export default async function populateDatabase(db: any, options: Options = null)
if (!folderDepthToId[depth]) folderDepthToId[depth] = [];
folderDepthToId[depth].push(savedFolder.id);
// eslint-disable-next-line no-console
if (!options.silent) console.info(`Folders: ${i} / ${options.folderCount}`);
}
@ -108,6 +109,7 @@ export default async function populateDatabase(db: any, options: Options = null)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
tagBatch.push(Tag.save({ title: tagTitle }, { dispatchUpdateAction: false }).then((savedTag: any) => {
createdTagIds.push(savedTag.id);
// eslint-disable-next-line no-console
if (!options.silent) console.info(`Tags: ${i} / ${options.tagCount}`);
}));
@ -131,6 +133,7 @@ export default async function populateDatabase(db: any, options: Options = null)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
noteBatch.push(Note.save(note, { dispatchUpdateAction: false }).then((savedNote: any) => {
createdNoteIds.push(savedNote.id);
// eslint-disable-next-line no-console
console.info(`Notes: ${i} / ${options.noteCount}`);
}));

View File

@ -23,6 +23,7 @@ export async function createTestData() {
}
export async function printTestData() {
// eslint-disable-next-line no-console
console.info(JSON.stringify(await createTestData(), null, '\t'));
}
@ -76,6 +77,7 @@ export async function checkTestData(data: TestData, options: CheckTestDataOption
if (hasError) {
console.warn(msg);
} else {
// eslint-disable-next-line no-console
if (!options.silent) console.info(msg);
}
}
@ -103,6 +105,7 @@ const desktopData = {
export const runIntegrationTests = async (silent: boolean = false) => {
const log = (s: string) => {
if (silent) return;
// eslint-disable-next-line no-console
console.info(s);
};

View File

@ -41,11 +41,11 @@ export default class ViewController {
}
public async emitMessage(event: EmitMessageEvent): Promise<any> {
console.info('Calling ViewController.emitMessage - but not implemented', event);
console.warn('Calling ViewController.emitMessage - but not implemented', event);
}
public postMessage(message: any) {
console.info('Calling ViewController.postMessage - but not implemented', message);
console.warn('Calling ViewController.postMessage - but not implemented', message);
}
}

View File

@ -1,3 +1,5 @@
/* eslint-disable id-denylist */
import time from '../../time';
interface Term {

View File

@ -24,7 +24,7 @@ const proxySettings = {};
function fileExists(filePath) {
try {
return fs.statSync(filePath).isFile();
} catch (err) {
} catch (error) {
return false;
}
}
@ -232,9 +232,9 @@ function shimInit(options = null) {
fit: 'inside',
withoutEnlargement: true,
})
.toFile(targetPath, (err, info) => {
if (err) {
reject(err);
.toFile(targetPath, (error, info) => {
if (error) {
reject(error);
} else {
resolve(info);
}

View File

@ -134,5 +134,6 @@ export async function main(syncTargetType: string) {
await fs.mkdirp(destDir);
await fs.copy(syncDir, destDir);
// eslint-disable-next-line no-console
console.info(`Sync target snapshot created in: ${destDir}`);
}

View File

@ -65,7 +65,6 @@ export default function versionInfo(packageInfo: any, plugins: Plugins) {
if (gitInfo) {
body.push(`\n${gitInfo}`);
console.info(gitInfo);
}
const pluginList = getPluginLists(plugins);

View File

@ -10,9 +10,9 @@ const pdfFilePath1 = resolve('config/welcome.pdf');
function loadFile(filePath: string) {
return new Promise<Uint8Array>((resolve, reject) => {
readFile(filePath, (err, data) => {
if (err) {
reject(err);
readFile(filePath, (error, data) => {
if (error) {
reject(error);
} else {
resolve(new Uint8Array((data)));
}

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
import { githubOauthToken } from '@joplin/tools/tool-utils';
import { pathExists, readdir, readFile, stat, writeFile } from 'fs-extra';

View File

@ -1,5 +1,7 @@
#!/usr/bin/env node
/* eslint-disable no-console */
require('source-map-support').install();
import * as fs from 'fs-extra';

View File

@ -6,6 +6,8 @@
// update, you can easily restore the functionality you've added.
// -----------------------------------------------------------------------------
/* eslint-disable no-console */
const path = require('path');
const crypto = require('crypto');
const fs = require('fs-extra');

View File

@ -41,6 +41,7 @@ export async function up(db: DbConnection): Promise<any> {
if (!items.length) break;
// eslint-disable-next-line no-console
console.info(`Processing items ${itemDone} / ${itemCount}`);
await db.transaction(async trx => {

View File

@ -220,6 +220,7 @@ export default abstract class BaseModel<T> {
txIndex = await this.transactionHandler_.start(name);
// eslint-disable-next-line no-console
if (debugSteps) console.info('START', name, txIndex);
let output: T = null;
@ -227,6 +228,7 @@ export default abstract class BaseModel<T> {
try {
output = await fn();
} catch (error) {
// eslint-disable-next-line no-console
if (debugSteps) console.info('ROLLBACK', name, txIndex);
await this.transactionHandler_.rollback(txIndex);
@ -236,6 +238,7 @@ export default abstract class BaseModel<T> {
if (debugTimerId) clearTimeout(debugTimerId);
}
// eslint-disable-next-line no-console
if (debugSteps) console.info('COMMIT', name, txIndex);
await this.transactionHandler_.commit(txIndex);

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
import config from '../../config';
import { clearDatabase, createTestUsers, CreateTestUsersOptions, createUserDeletions } from '../../tools/debugTools';
import { bodyFields } from '../../utils/requestUtils';

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
import sqlts from '@rmp135/sql-ts';
require('source-map-support').install();

View File

@ -35,6 +35,7 @@ export default class TransactionHandler {
private log(s: string): void {
if (!this.logEnabled_) return;
// eslint-disable-next-line no-console
console.info(`TransactionHandler: ${s}`);
}

View File

@ -66,6 +66,7 @@ export default async function setupCommands(): Promise<Commands> {
if (cmdName && !selectedCommand) {
yargs.showHelp();
// eslint-disable-next-line no-console
console.info('');
throw new Error(`Invalid command: ${cmdName}`);
}

View File

@ -1,3 +1,5 @@
/* eslint-disable no-console */
import * as fs from 'fs-extra';
require('source-map-support').install();

View File

@ -50,5 +50,6 @@ export function timerPush(name: string) {
export function timerPop() {
const t = perfTimers_.pop();
// eslint-disable-next-line no-console
console.info(`Time: ${t.name}: ${Date.now() - t.startTime}`);
}

View File

@ -33,7 +33,7 @@ module.exports = async function compilePackageInfo(packageInfoPath, outputPath)
branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: 'pipe' }).toString().trim();
hash = execSync('git log --pretty="%h" -1', { stdio: 'pipe' }).toString().trim();
// The builds in CI are done from a 'detached HEAD' state, thus the branch name will be 'HEAD' for CI builds.
} catch (err) {
} catch (error) {
// Don't display error object as it's a "fatal" error, but
// not for us, since is it not critical information
// https://github.com/laurent22/joplin/issues/2256

View File

@ -299,13 +299,13 @@ export function fileExists(filePath: string) {
const fs = require('fs-extra');
return new Promise((resolve, reject) => {
fs.stat(filePath, function(err: any) {
if (!err) {
fs.stat(filePath, function(error: any) {
if (!error) {
resolve(true);
} else if (err.code === 'ENOENT') {
} else if (error.code === 'ENOENT') {
resolve(false);
} else {
reject(err);
reject(error);
}
});
});