diff --git a/.eslintrc.js b/.eslintrc.js index 4027d6048..d750d69f5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -100,6 +100,7 @@ module.exports = { "space-before-blocks": "error", "spaced-comment": ["error", "always"], "keyword-spacing": ["error", { "before": true, "after": true }], + "arrow-parens": ["error"], }, "plugins": [ "react", diff --git a/CliClient/app/ResourceServer.js b/CliClient/app/ResourceServer.js index b2e9aea84..84eaa07e2 100644 --- a/CliClient/app/ResourceServer.js +++ b/CliClient/app/ResourceServer.js @@ -45,7 +45,7 @@ class ResourceServer { this.server_ = http.createServer(); this.server_.on('request', async (request, response) => { - const writeResponse = message => { + const writeResponse = (message) => { response.write(message); response.end(); }; @@ -73,7 +73,7 @@ class ResourceServer { response.end(); }); - this.server_.on('error', error => { + this.server_.on('error', (error) => { this.logger().error('Resource server:', error); }); diff --git a/CliClient/app/app-gui.js b/CliClient/app/app-gui.js index 1676b6a18..bf0774a33 100644 --- a/CliClient/app/app-gui.js +++ b/CliClient/app/app-gui.js @@ -61,7 +61,7 @@ class AppGui { this.renderer_ = new Renderer(this.term(), this.rootWidget_); - this.app_.on('modelAction', async event => { + this.app_.on('modelAction', async (event) => { await this.handleModelAction(event.action); }); @@ -131,7 +131,7 @@ class AppGui { }; folderList.name = 'folderList'; folderList.vStretch = true; - folderList.on('currentItemChange', async event => { + folderList.on('currentItemChange', async (event) => { const item = folderList.currentItem; if (item === '-') { @@ -166,7 +166,7 @@ class AppGui { }); } }); - this.rootWidget_.connect(folderList, state => { + this.rootWidget_.connect(folderList, (state) => { return { selectedFolderId: state.selectedFolderId, selectedTagId: state.selectedTagId, @@ -193,7 +193,7 @@ class AppGui { id: note ? note.id : null, }); }); - this.rootWidget_.connect(noteList, state => { + this.rootWidget_.connect(noteList, (state) => { return { selectedNoteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null, items: state.notes, @@ -207,7 +207,7 @@ class AppGui { borderBottomWidth: 1, borderLeftWidth: 1, }; - this.rootWidget_.connect(noteText, state => { + this.rootWidget_.connect(noteText, (state) => { return { noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null, notes: state.notes, @@ -222,7 +222,7 @@ class AppGui { borderLeftWidth: 1, borderRightWidth: 1, }; - this.rootWidget_.connect(noteMetadata, state => { + this.rootWidget_.connect(noteMetadata, (state) => { return { noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null }; }); noteMetadata.hide(); diff --git a/CliClient/app/app.js b/CliClient/app/app.js index 5dcc099a5..bc17262f9 100644 --- a/CliClient/app/app.js +++ b/CliClient/app/app.js @@ -117,11 +117,11 @@ class Application extends BaseApplication { } setupCommand(cmd) { - cmd.setStdout(text => { + cmd.setStdout((text) => { return this.stdout(text); }); - cmd.setDispatcher(action => { + cmd.setDispatcher((action) => { if (this.store()) { return this.store().dispatch(action); } else { @@ -176,7 +176,7 @@ class Application extends BaseApplication { commands(uiType = null) { if (!this.allCommandsLoaded_) { - fs.readdirSync(__dirname).forEach(path => { + fs.readdirSync(__dirname).forEach((path) => { if (path.indexOf('command-') !== 0) return; const ext = fileExtension(path); if (ext != 'js') return; @@ -275,7 +275,7 @@ class Application extends BaseApplication { }, showConsole: () => {}, maximizeConsole: () => {}, - stdout: text => { + stdout: (text) => { console.info(text); }, fullScreen: () => {}, @@ -370,7 +370,7 @@ class Application extends BaseApplication { // Map reserved shortcuts to their equivalent key // https://github.com/cronvel/terminal-kit/issues/101 for (let i = 0; i < output.length; i++) { - const newKeys = output[i].keys.map(k => { + const newKeys = output[i].keys.map((k) => { k = k.replace(/CTRL_H/g, 'BACKSPACE'); k = k.replace(/CTRL_I/g, 'TAB'); k = k.replace(/CTRL_M/g, 'ENTER'); diff --git a/CliClient/app/autocompletion.js b/CliClient/app/autocompletion.js index 73836e090..d54801fc4 100644 --- a/CliClient/app/autocompletion.js +++ b/CliClient/app/autocompletion.js @@ -14,11 +14,11 @@ async function handleAutocompletionPromise(line) { // should look for commands it could be if (words.length == 1) { if (names.indexOf(words[0]) === -1) { - const x = names.filter(n => n.indexOf(words[0]) === 0); + const x = names.filter((n) => n.indexOf(words[0]) === 0); if (x.length === 1) { return `${x[0]} `; } - return x.length > 0 ? x.map(a => `${a} `) : line; + return x.length > 0 ? x.map((a) => `${a} `) : line; } else { return line; } @@ -60,14 +60,14 @@ async function handleAutocompletionPromise(line) { if (l.length === 0) { return line; } - const ret = l.map(a => toCommandLine(a)); + const ret = l.map((a) => toCommandLine(a)); ret.prefix = `${toCommandLine(words.slice(0, -1))} `; return ret; } // Complete an argument // Determine the number of positional arguments by counting the number of // words that don't start with a - less one for the command name - const positionalArgs = words.filter(a => a.indexOf('-') !== 0).length - 1; + const positionalArgs = words.filter((a) => a.indexOf('-') !== 0).length - 1; const cmdUsage = yargParser(metadata.usage)['_']; cmdUsage.splice(0, 1); @@ -80,23 +80,23 @@ async function handleAutocompletionPromise(line) { if (argName == 'note' || argName == 'note-pattern') { const notes = currentFolder ? await Note.previews(currentFolder.id, { titlePattern: `${next}*` }) : []; - l.push(...notes.map(n => n.title)); + l.push(...notes.map((n) => n.title)); } if (argName == 'notebook') { const folders = await Folder.search({ titlePattern: `${next}*` }); - l.push(...folders.map(n => n.title)); + l.push(...folders.map((n) => n.title)); } if (argName == 'item') { const notes = currentFolder ? await Note.previews(currentFolder.id, { titlePattern: `${next}*` }) : []; const folders = await Folder.search({ titlePattern: `${next}*` }); - l.push(...notes.map(n => n.title), folders.map(n => n.title)); + l.push(...notes.map((n) => n.title), folders.map((n) => n.title)); } if (argName == 'tag') { const tags = await Tag.search({ titlePattern: `${next}*` }); - l.push(...tags.map(n => n.title)); + l.push(...tags.map((n) => n.title)); } if (argName == 'file') { @@ -117,7 +117,7 @@ async function handleAutocompletionPromise(line) { if (l.length === 1) { return toCommandLine([...words.slice(0, -1), l[0]]); } else if (l.length > 1) { - const ret = l.map(a => toCommandLine(a)); + const ret = l.map((a) => toCommandLine(a)); ret.prefix = `${toCommandLine(words.slice(0, -1))} `; return ret; } diff --git a/CliClient/app/build-doc.js b/CliClient/app/build-doc.js index afdfe9924..5602b2feb 100644 --- a/CliClient/app/build-doc.js +++ b/CliClient/app/build-doc.js @@ -49,7 +49,7 @@ function renderCommand(cmd) { function getCommands() { const output = []; - fs.readdirSync(__dirname).forEach(path => { + fs.readdirSync(__dirname).forEach((path) => { if (path.indexOf('command-') !== 0) return; const ext = fileExtension(path); if (ext != 'js') return; @@ -134,6 +134,6 @@ async function main() { console.info(`${headerText}\n\n` + 'USAGE' + `\n\n${commandsText}\n\n${footerText}`); } -main().catch(error => { +main().catch((error) => { console.error(error); }); diff --git a/CliClient/app/cli-integration-tests.js b/CliClient/app/cli-integration-tests.js index 294662eed..978ae0f98 100644 --- a/CliClient/app/cli-integration-tests.js +++ b/CliClient/app/cli-integration-tests.js @@ -236,7 +236,7 @@ async function main() { } } -main(process.argv).catch(error => { +main(process.argv).catch((error) => { console.info(''); logger.error(error); }); diff --git a/CliClient/app/cli-utils.js b/CliClient/app/cli-utils.js index 40d072613..61004b348 100644 --- a/CliClient/app/cli-utils.js +++ b/CliClient/app/cli-utils.js @@ -143,7 +143,7 @@ cliUtils.promptMcq = function(message, answers) { message += _('Your choice: '); return new Promise((resolve, reject) => { - rl.question(message, answer => { + rl.question(message, (answer) => { rl.close(); if (!(answer in answers)) { @@ -168,7 +168,7 @@ cliUtils.promptConfirm = function(message, answers = null) { message += ` (${answers.join('/')})`; return new Promise((resolve) => { - rl.question(`${message} `, answer => { + rl.question(`${message} `, (answer) => { const ok = !answer || answer.toLowerCase() == answers[0].toLowerCase(); rl.close(); resolve(ok); @@ -202,7 +202,7 @@ cliUtils.prompt = function(initialText = '', promptString = ':', options = null) return new Promise((resolve) => { mutableStdout.muted = false; - rl.question(promptString, answer => { + rl.question(promptString, (answer) => { rl.close(); if (options.secure) this.stdout_(''); resolve(answer); diff --git a/CliClient/app/command-apidoc.js b/CliClient/app/command-apidoc.js index ef9e5f7cf..a6f0a6ec5 100644 --- a/CliClient/app/command-apidoc.js +++ b/CliClient/app/command-apidoc.js @@ -25,7 +25,7 @@ class Command extends BaseCommand { { name: 'type', label: 'Type', - filter: value => { + filter: (value) => { return Database.enumName('fieldType', value); }, }, diff --git a/CliClient/app/command-config.js b/CliClient/app/command-config.js index e4af92ff3..82cce782b 100644 --- a/CliClient/app/command-config.js +++ b/CliClient/app/command-config.js @@ -69,7 +69,7 @@ class Command extends BaseCommand { const isImport = args.options.import || args.options.importFile; const importFile = args.options.importFile; - const renderKeyValue = name => { + const renderKeyValue = (name) => { const md = Setting.settingMetadata(name); let value = Setting.value(name); if (typeof value === 'object' || Array.isArray(value)) value = JSON.stringify(value); diff --git a/CliClient/app/command-e2ee.js b/CliClient/app/command-e2ee.js index 3a4082dbd..ed5e2d51e 100644 --- a/CliClient/app/command-e2ee.js +++ b/CliClient/app/command-e2ee.js @@ -31,7 +31,7 @@ class Command extends BaseCommand { async action(args) { const options = args.options; - const askForMasterKey = async error => { + const askForMasterKey = async (error) => { const masterKeyId = error.masterKeyId; const password = await this.prompt(_('Enter master password:'), { type: 'string', secure: true }); if (!password) { @@ -147,7 +147,7 @@ class Command extends BaseCommand { const dirPaths = function(targetPath) { const paths = []; - fs.readdirSync(targetPath).forEach(path => { + fs.readdirSync(targetPath).forEach((path) => { paths.push(path); }); return paths; diff --git a/CliClient/app/command-export.js b/CliClient/app/command-export.js index cd582f0ed..b8e364714 100644 --- a/CliClient/app/command-export.js +++ b/CliClient/app/command-export.js @@ -17,8 +17,8 @@ class Command extends BaseCommand { const service = new InteropService(); const formats = service .modules() - .filter(m => m.type === 'exporter') - .map(m => m.format + (m.description ? ` (${m.description})` : '')); + .filter((m) => m.type === 'exporter') + .map((m) => m.format + (m.description ? ` (${m.description})` : '')); return [['--format ', _('Destination format: %s', formats.join(', '))], ['--note ', _('Exports only the given note.')], ['--notebook ', _('Exports only the given notebook.')]]; } @@ -32,17 +32,17 @@ class Command extends BaseCommand { if (args.options.note) { const notes = await app().loadItems(BaseModel.TYPE_NOTE, args.options.note, { parent: app().currentFolder() }); if (!notes.length) throw new Error(_('Cannot find "%s".', args.options.note)); - exportOptions.sourceNoteIds = notes.map(n => n.id); + exportOptions.sourceNoteIds = notes.map((n) => n.id); } else if (args.options.notebook) { const folders = await app().loadItems(BaseModel.TYPE_FOLDER, args.options.notebook); if (!folders.length) throw new Error(_('Cannot find "%s".', args.options.notebook)); - exportOptions.sourceFolderIds = folders.map(n => n.id); + exportOptions.sourceFolderIds = folders.map((n) => n.id); } const service = new InteropService(); const result = await service.export(exportOptions); - result.warnings.map(w => this.stdout(w)); + result.warnings.map((w) => this.stdout(w)); } } diff --git a/CliClient/app/command-help.js b/CliClient/app/command-help.js index afce0ed47..0bf61df60 100644 --- a/CliClient/app/command-help.js +++ b/CliClient/app/command-help.js @@ -52,21 +52,21 @@ class Command extends BaseCommand { for (let i = 0; i < keymap.length; i++) { const item = keymap[i]; - const keys = item.keys.map(k => (k === ' ' ? '(SPACE)' : k)); + const keys = item.keys.map((k) => (k === ' ' ? '(SPACE)' : k)); rows.push([keys.join(', '), item.command]); } cliUtils.printArray(this.stdout.bind(this), rows); } else if (args.command === 'all') { const commands = this.allCommands(); - const output = commands.map(c => renderCommandHelp(c)); + const output = commands.map((c) => renderCommandHelp(c)); this.stdout(output.join('\n\n')); } else if (args.command) { const command = app().findCommandByName(args['command']); if (!command) throw new Error(_('Cannot find "%s".', args.command)); this.stdout(renderCommandHelp(command, stdoutWidth)); } else { - const commandNames = this.allCommands().map(a => a.name()); + const commandNames = this.allCommands().map((a) => a.name()); this.stdout(_('Type `help [command]` for more information about a command; or type `help all` for the complete usage information.')); this.stdout(''); diff --git a/CliClient/app/command-import.js b/CliClient/app/command-import.js index eac6fc248..6e590b9a3 100644 --- a/CliClient/app/command-import.js +++ b/CliClient/app/command-import.js @@ -18,8 +18,8 @@ class Command extends BaseCommand { const service = new InteropService(); const formats = service .modules() - .filter(m => m.type === 'importer') - .map(m => m.format); + .filter((m) => m.type === 'importer') + .map((m) => m.format); return [['--format ', _('Source format: %s', ['auto'].concat(formats).join(', '))], ['-f, --force', _('Do not ask for confirmation.')]]; } @@ -38,7 +38,7 @@ class Command extends BaseCommand { // onProgress/onError supported by Enex import only - importOptions.onProgress = progressState => { + importOptions.onProgress = (progressState) => { const line = []; line.push(_('Found: %d.', progressState.loaded)); line.push(_('Created: %d.', progressState.created)); @@ -50,7 +50,7 @@ class Command extends BaseCommand { cliUtils.redraw(lastProgress); }; - importOptions.onError = error => { + importOptions.onError = (error) => { const s = error.trace ? error.trace : error.toString(); this.stdout(s); }; @@ -61,7 +61,7 @@ class Command extends BaseCommand { this.stdout(_('Importing notes...')); const service = new InteropService(); const result = await service.import(importOptions); - result.warnings.map(w => this.stdout(w)); + result.warnings.map((w) => this.stdout(w)); cliUtils.redrawDone(); if (lastProgress) this.stdout(_('The notes have been imported: %s', lastProgress)); } diff --git a/CliClient/app/command-rmnote.js b/CliClient/app/command-rmnote.js index c832404e8..6b43658fe 100644 --- a/CliClient/app/command-rmnote.js +++ b/CliClient/app/command-rmnote.js @@ -26,7 +26,7 @@ class Command extends BaseCommand { const ok = force ? true : await this.prompt(notes.length > 1 ? _('%d notes match this pattern. Delete them?', notes.length) : _('Delete note?'), { booleanAnswerDefault: 'n' }); if (!ok) return; - const ids = notes.map(n => n.id); + const ids = notes.map((n) => n.id); await Note.batchDelete(ids); } } diff --git a/CliClient/app/command-sync.js b/CliClient/app/command-sync.js index 2425a4fd1..c779a6471 100644 --- a/CliClient/app/command-sync.js +++ b/CliClient/app/command-sync.js @@ -162,11 +162,11 @@ class Command extends BaseCommand { const sync = await syncTarget.synchronizer(); const options = { - onProgress: report => { + onProgress: (report) => { const lines = Synchronizer.reportToLines(report); if (lines.length) cliUtils.redraw(lines.join(' ')); }, - onMessage: msg => { + onMessage: (msg) => { cliUtils.redrawDone(); this.stdout(msg); }, diff --git a/CliClient/app/command-tag.js b/CliClient/app/command-tag.js index d199ff52d..c5be6be14 100644 --- a/CliClient/app/command-tag.js +++ b/CliClient/app/command-tag.js @@ -47,7 +47,7 @@ class Command extends BaseCommand { } else if (command == 'list') { if (tag) { const notes = await Tag.notes(tag.id); - notes.map(note => { + notes.map((note) => { let line = ''; if (options.long) { line += BaseModel.shortId(note.id); @@ -71,7 +71,7 @@ class Command extends BaseCommand { }); } else { const tags = await Tag.all(); - tags.map(tag => { + tags.map((tag) => { this.stdout(tag.title); }); } @@ -80,7 +80,7 @@ class Command extends BaseCommand { const note = await app().loadItem(BaseModel.TYPE_NOTE, args.tag); if (!note) throw new Error(_('Cannot find "%s".', args.tag)); const tags = await Tag.tagsByNoteId(note.id); - tags.map(tag => { + tags.map((tag) => { this.stdout(tag.title); }); } else { diff --git a/CliClient/app/fuzzing.js b/CliClient/app/fuzzing.js index e45a07020..f97c8e8b6 100644 --- a/CliClient/app/fuzzing.js +++ b/CliClient/app/fuzzing.js @@ -2328,11 +2328,11 @@ async function main() { clients[clientId].activeCommandCount++; execRandomCommand(clients[clientId]) - .catch(error => { + .catch((error) => { logger.info(`Client ${clientId}:`); logger.error(error); }) - .then(r => { + .then((r) => { if (r) { logger.info(`Client ${clientId}:\n${r.trim()}`); } @@ -2397,6 +2397,6 @@ async function main() { }, 100); } -main(process.argv).catch(error => { +main(process.argv).catch((error) => { logger.error(error); }); diff --git a/CliClient/app/gui/FolderListWidget.js b/CliClient/app/gui/FolderListWidget.js index 404291621..6b53f7bfa 100644 --- a/CliClient/app/gui/FolderListWidget.js +++ b/CliClient/app/gui/FolderListWidget.js @@ -19,7 +19,7 @@ class FolderListWidget extends ListWidget { this.updateItems_ = false; this.trimItemTitle = false; - this.itemRenderer = item => { + this.itemRenderer = (item) => { const output = []; if (item === '-') { output.push('-'.repeat(this.innerWidth)); @@ -134,7 +134,7 @@ class FolderListWidget extends ListWidget { const previousParentType = this.notesParentType; let newItems = []; - const orderFolders = parentId => { + const orderFolders = (parentId) => { for (let i = 0; i < this.folders.length; i++) { const f = this.folders[i]; const folderParentId = f.parent_id ? f.parent_id : ''; diff --git a/CliClient/app/gui/NoteListWidget.js b/CliClient/app/gui/NoteListWidget.js index 407c39281..f950b114f 100644 --- a/CliClient/app/gui/NoteListWidget.js +++ b/CliClient/app/gui/NoteListWidget.js @@ -8,7 +8,7 @@ class NoteListWidget extends ListWidget { this.updateIndexFromSelectedNoteId_ = false; - this.itemRenderer = note => { + this.itemRenderer = (note) => { let label = Note.displayTitle(note); // + ' ' + note.id; if (note.is_todo) { label = `[${note.todo_completed ? 'X' : ' '}] ${label}`; diff --git a/CliClient/app/gui/StatusBarWidget.js b/CliClient/app/gui/StatusBarWidget.js index 70e6788f2..d5231c5a7 100644 --- a/CliClient/app/gui/StatusBarWidget.js +++ b/CliClient/app/gui/StatusBarWidget.js @@ -86,7 +86,7 @@ class StatusBarWidget extends BaseWidget { // const textStyle = this.promptActive ? (s) => s : chalk.bgBlueBright.white; // const textStyle = (s) => s; - const textStyle = this.promptActive ? s => s : chalk.gray; + const textStyle = this.promptActive ? (s) => s : chalk.gray; this.term.drawHLine(this.absoluteInnerX, this.absoluteInnerY, this.innerWidth, textStyle(' ')); diff --git a/CliClient/app/help-utils.js b/CliClient/app/help-utils.js index b60f4e9c6..32430e1c2 100644 --- a/CliClient/app/help-utils.js +++ b/CliClient/app/help-utils.js @@ -41,7 +41,7 @@ function renderCommandHelp(cmd, width = null) { } if (cmd.name() === 'config') { - const renderMetadata = md => { + const renderMetadata = (md) => { const desc = []; if (md.label) { diff --git a/CliClient/app/main.js b/CliClient/app/main.js index b798ede8d..d847010a8 100644 --- a/CliClient/app/main.js +++ b/CliClient/app/main.js @@ -71,7 +71,7 @@ process.stdout.on('error', function(err) { } }); -application.start(process.argv).catch(error => { +application.start(process.argv).catch((error) => { if (error.code == 'flagError') { console.error(error.message); console.error(_('Type `joplin help` for usage information.')); diff --git a/CliClient/tests/feature_TagList.js b/CliClient/tests/feature_TagList.js index 348cf78f4..645d2eb60 100644 --- a/CliClient/tests/feature_TagList.js +++ b/CliClient/tests/feature_TagList.js @@ -84,7 +84,7 @@ describe('integration_TagList', function() { // check the tag list is updated state = testApp.store().getState(); - const tagIds = state.selectedNoteTags.map(n => n.id).sort(); + const tagIds = state.selectedNoteTags.map((n) => n.id).sort(); const expectedTagIds = [tags[0].id, tags[2].id].sort(); expect(state.selectedNoteTags.length).toEqual(2); expect(tagIds).toEqual(expectedTagIds); diff --git a/CliClient/tests/models_Note.js b/CliClient/tests/models_Note.js index d2076e4c1..df4e44e5b 100644 --- a/CliClient/tests/models_Note.js +++ b/CliClient/tests/models_Note.js @@ -173,7 +173,7 @@ describe('models_Note', function() { expect(allAfterDelete.length).toBe(expectedLength); // Common elements between the to-be-deleted notes and the notes and folders remaining after the delete - const intersection = [...notesToRemoveFromFolder1, ...notesToRemoveFromFolder2].filter(x => allAfterDelete.includes(x)); + const intersection = [...notesToRemoveFromFolder1, ...notesToRemoveFromFolder2].filter((x) => allAfterDelete.includes(x)); // Should be empty expect(intersection.length).toBe(0); })); diff --git a/CliClient/tests/models_Tag.js b/CliClient/tests/models_Tag.js index 843144f99..457134887 100644 --- a/CliClient/tests/models_Tag.js +++ b/CliClient/tests/models_Tag.js @@ -128,22 +128,22 @@ describe('models_Tag', function() { expect(commonTags.length).toBe(0); commonTags = await Tag.commonTagsByNoteIds([note0.id, note1.id, note2.id, note3.id]); - let commonTagIds = commonTags.map(t => t.id); + let commonTagIds = commonTags.map((t) => t.id); expect(commonTagIds.length).toBe(0); commonTags = await Tag.commonTagsByNoteIds([note1.id, note2.id, note3.id]); - commonTagIds = commonTags.map(t => t.id); + commonTagIds = commonTags.map((t) => t.id); expect(commonTagIds.length).toBe(1); expect(commonTagIds.includes(taga.id)).toBe(true); commonTags = await Tag.commonTagsByNoteIds([note2.id, note3.id]); - commonTagIds = commonTags.map(t => t.id); + commonTagIds = commonTags.map((t) => t.id); expect(commonTagIds.length).toBe(2); expect(commonTagIds.includes(taga.id)).toBe(true); expect(commonTagIds.includes(tagb.id)).toBe(true); commonTags = await Tag.commonTagsByNoteIds([note3.id]); - commonTagIds = commonTags.map(t => t.id); + commonTagIds = commonTags.map((t) => t.id); expect(commonTags.length).toBe(3); expect(commonTagIds.includes(taga.id)).toBe(true); expect(commonTagIds.includes(tagb.id)).toBe(true); diff --git a/CliClient/tests/reducer.js b/CliClient/tests/reducer.js index 799a6ccc8..3d83e0287 100644 --- a/CliClient/tests/reducer.js +++ b/CliClient/tests/reducer.js @@ -526,8 +526,8 @@ describe('Reducer', function() { // current = 3 state = goBackWard(state); - expect(state.backwardHistoryNotes.map(n=>n.id)).toEqual([notes[0], notes[1], notes[2], notes[3], notes[2], notes[3], notes[2]].map(n=>n.id)); - expect(state.forwardHistoryNotes.map(n=>n.id)).toEqual([notes[3], notes[2], notes[3], notes[2]].map(n=>n.id)); + expect(state.backwardHistoryNotes.map((n)=>n.id)).toEqual([notes[0], notes[1], notes[2], notes[3], notes[2], notes[3], notes[2]].map((n)=>n.id)); + expect(state.forwardHistoryNotes.map((n)=>n.id)).toEqual([notes[3], notes[2], notes[3], notes[2]].map((n)=>n.id)); expect(state.selectedNoteIds).toEqual([notes[3].id]); // delete third note @@ -547,8 +547,8 @@ describe('Reducer', function() { // backward = 0 1 // forward = // current = 3 - expect(state.backwardHistoryNotes.map(x => x.id)).toEqual([notes[0].id, notes[1].id]); - expect(state.forwardHistoryNotes.map(x => x.id)).toEqual([]); + expect(state.backwardHistoryNotes.map((x) => x.id)).toEqual([notes[0].id, notes[1].id]); + expect(state.forwardHistoryNotes.map((x) => x.id)).toEqual([]); expect(state.selectedNoteIds).toEqual([notes[3].id]); })); @@ -565,7 +565,7 @@ describe('Reducer', function() { } expect(state.backwardHistoryNotes.length).toEqual(MAX_HISTORY); - expect(state.forwardHistoryNotes.map(x => x.id)).toEqual([]); + expect(state.forwardHistoryNotes.map((x) => x.id)).toEqual([]); for (let i = 0; i < 2 * MAX_HISTORY; i++) { state = goBackWard(state); @@ -579,6 +579,6 @@ describe('Reducer', function() { } expect(state.backwardHistoryNotes.length).toEqual(MAX_HISTORY); - expect(state.forwardHistoryNotes.map(x => x.id)).toEqual([]); + expect(state.forwardHistoryNotes.map((x) => x.id)).toEqual([]); })); }); diff --git a/CliClient/tests/services_EncryptionService.js b/CliClient/tests/services_EncryptionService.js index 6871b1069..815cbfe0e 100644 --- a/CliClient/tests/services_EncryptionService.js +++ b/CliClient/tests/services_EncryptionService.js @@ -146,7 +146,7 @@ describe('services_EncryptionService', function() { const needUpgrade = service.masterKeysThatNeedUpgrading(await MasterKey.all()); expect(needUpgrade.length).toBe(2); - expect(needUpgrade.map(k => k.id).sort()).toEqual([masterKey1.id, masterKey2.id].sort()); + expect(needUpgrade.map((k) => k.id).sort()).toEqual([masterKey1.id, masterKey2.id].sort()); })); it('should encrypt and decrypt with a master key', asyncTest(async () => { diff --git a/CliClient/tests/services_KvStore.js b/CliClient/tests/services_KvStore.js index 5c1e461f3..16f4387bc 100644 --- a/CliClient/tests/services_KvStore.js +++ b/CliClient/tests/services_KvStore.js @@ -101,7 +101,7 @@ describe('services_KvStore', function() { const results = await store.searchByPrefix('testing:'); expect(results.length).toBe(2); - const numbers = results.map(r => r.value).sort(); + const numbers = results.map((r) => r.value).sort(); expect(numbers[0]).toBe(1); expect(numbers[1]).toBe(2); })); diff --git a/CliClient/tests/services_SearchEngine.js b/CliClient/tests/services_SearchEngine.js index d71de6639..2859e9ceb 100644 --- a/CliClient/tests/services_SearchEngine.js +++ b/CliClient/tests/services_SearchEngine.js @@ -110,7 +110,7 @@ describe('services_SearchEngine', function() { const rows = await engine.search(testCase[0]); for (let i = 0; i < notes.length; i++) { - const row = rows.find(row => row.id === notes[i].id); + const row = rows.find((row) => row.id === notes[i].id); const actual = row ? row.fields.sort().join(',') : ''; const expected = testCase[i + 1].sort().join(','); expect(expected).toBe(actual); @@ -330,9 +330,9 @@ describe('services_SearchEngine', function() { const expected = t[1]; const actual = engine.parseQuery(input); - const _Values = actual.terms._ ? actual.terms._.map(v => v.value) : undefined; - const titleValues = actual.terms.title ? actual.terms.title.map(v => v.value) : undefined; - const bodyValues = actual.terms.body ? actual.terms.body.map(v => v.value) : undefined; + const _Values = actual.terms._ ? actual.terms._.map((v) => v.value) : undefined; + const titleValues = actual.terms.title ? actual.terms.title.map((v) => v.value) : undefined; + const bodyValues = actual.terms.body ? actual.terms.body.map((v) => v.value) : undefined; expect(JSON.stringify(_Values)).toBe(JSON.stringify(expected._), `Test case (_) ${i}`); expect(JSON.stringify(titleValues)).toBe(JSON.stringify(expected.title), `Test case (title) ${i}`); diff --git a/CliClient/tests/test-utils.js b/CliClient/tests/test-utils.js index de7f2d129..cce63802b 100644 --- a/CliClient/tests/test-utils.js +++ b/CliClient/tests/test-utils.js @@ -426,7 +426,7 @@ function id(a) { } function ids(a) { - return a.map(n => n.id); + return a.map((n) => n.id); } function sortedIds(a) { diff --git a/CliClient/tests/urlUtils.js b/CliClient/tests/urlUtils.js index 131b7d7fb..ee60c5dbc 100644 --- a/CliClient/tests/urlUtils.js +++ b/CliClient/tests/urlUtils.js @@ -76,7 +76,7 @@ describe('urlUtils', function() { const result = urlUtils.extractResourceUrls(t[0]); const expected = t[1]; - const itemIds = result.map(r => r.itemId); + const itemIds = result.map((r) => r.itemId); expect(itemIds.sort().join(',')).toBe(expected.sort().join(',')); } })); diff --git a/Clipper/content_scripts/index.js b/Clipper/content_scripts/index.js index 9a4f0f93f..fe2dd9d58 100644 --- a/Clipper/content_scripts/index.js +++ b/Clipper/content_scripts/index.js @@ -266,7 +266,7 @@ for (const preElement of preElements) { const fontFamily = getComputedStyle(preElement).getPropertyValue('font-family'); - const fontFamilyArray = fontFamily.split(',').map(f => f.toLowerCase().trim()); + const fontFamilyArray = fontFamily.split(',').map((f) => f.toLowerCase().trim()); if (fontFamilyArray.indexOf('monospace') >= 0) { preElement.style.fontFamily = fontFamily; } diff --git a/Clipper/popup/config/env.js b/Clipper/popup/config/env.js index 9c76d46a3..a240c804d 100644 --- a/Clipper/popup/config/env.js +++ b/Clipper/popup/config/env.js @@ -30,7 +30,7 @@ const dotenvFiles = [ // that have already been set. Variable expansion is supported in .env files. // https://github.com/motdotla/dotenv // https://github.com/motdotla/dotenv-expand -dotenvFiles.forEach(dotenvFile => { +dotenvFiles.forEach((dotenvFile) => { if (fs.existsSync(dotenvFile)) { require('dotenv-expand')( require('dotenv').config({ @@ -52,8 +52,8 @@ dotenvFiles.forEach(dotenvFile => { const appDirectory = fs.realpathSync(process.cwd()); process.env.NODE_PATH = (process.env.NODE_PATH || '') .split(path.delimiter) - .filter(folder => folder && !path.isAbsolute(folder)) - .map(folder => path.resolve(appDirectory, folder)) + .filter((folder) => folder && !path.isAbsolute(folder)) + .map((folder) => path.resolve(appDirectory, folder)) .join(path.delimiter); // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be @@ -62,7 +62,7 @@ const REACT_APP = /^REACT_APP_/i; function getClientEnvironment(publicUrl) { const raw = Object.keys(process.env) - .filter(key => REACT_APP.test(key)) + .filter((key) => REACT_APP.test(key)) .reduce( (env, key) => { env[key] = process.env[key]; diff --git a/Clipper/popup/config/paths.js b/Clipper/popup/config/paths.js index 808d27110..3cd8bea4f 100644 --- a/Clipper/popup/config/paths.js +++ b/Clipper/popup/config/paths.js @@ -7,7 +7,7 @@ const url = require('url'); // Make sure any symlinks in the project folder are resolved: // https://github.com/facebook/create-react-app/issues/637 const appDirectory = fs.realpathSync(process.cwd()); -const resolveApp = relativePath => path.resolve(appDirectory, relativePath); +const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath); const envPublicUrl = process.env.PUBLIC_URL; @@ -22,7 +22,7 @@ function ensureSlash(inputPath, needsSlash) { } } -const getPublicUrl = appPackageJson => +const getPublicUrl = (appPackageJson) => envPublicUrl || require(appPackageJson).homepage; // We use `PUBLIC_URL` environment variable or "homepage" field to infer @@ -54,7 +54,7 @@ const moduleFileExtensions = [ // Resolve file paths in the same order as webpack const resolveModule = (resolveFn, filePath) => { - const extension = moduleFileExtensions.find(extension => + const extension = moduleFileExtensions.find((extension) => fs.existsSync(resolveFn(`${filePath}.${extension}`)) ); diff --git a/Clipper/popup/scripts/start.js b/Clipper/popup/scripts/start.js index 4dda1a2f0..66aca9e8b 100644 --- a/Clipper/popup/scripts/start.js +++ b/Clipper/popup/scripts/start.js @@ -7,7 +7,7 @@ process.env.NODE_ENV = 'development'; // Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. -process.on('unhandledRejection', err => { +process.on('unhandledRejection', (err) => { throw err; }); @@ -70,7 +70,7 @@ checkBrowsers(paths.appPath, isInteractive) // run on a different port. `choosePort()` Promise resolves to the next free port. return choosePort(HOST, DEFAULT_PORT); }) - .then(port => { + .then((port) => { if (port == null) { // We have not found a port. return; @@ -82,9 +82,9 @@ checkBrowsers(paths.appPath, isInteractive) const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true'; const urls = prepareUrls(protocol, HOST, port); const devSocket = { - warnings: warnings => + warnings: (warnings) => devServer.sockWrite(devServer.sockets, 'warnings', warnings), - errors: errors => + errors: (errors) => devServer.sockWrite(devServer.sockets, 'errors', errors), }; // Create a webpack compiler that is configured with custom messages. @@ -108,7 +108,7 @@ checkBrowsers(paths.appPath, isInteractive) ); const devServer = new WebpackDevServer(compiler, serverConfig); // Launch WebpackDevServer. - devServer.listen(port, HOST, err => { + devServer.listen(port, HOST, (err) => { if (err) { return console.log(err); } @@ -139,7 +139,7 @@ checkBrowsers(paths.appPath, isInteractive) }); }); }) - .catch(err => { + .catch((err) => { if (err && err.message) { console.log(err.message); } diff --git a/Clipper/popup/scripts/test.js b/Clipper/popup/scripts/test.js index c8b2fa96f..7f136a8c5 100644 --- a/Clipper/popup/scripts/test.js +++ b/Clipper/popup/scripts/test.js @@ -8,7 +8,7 @@ process.env.PUBLIC_URL = ''; // Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. -process.on('unhandledRejection', err => { +process.on('unhandledRejection', (err) => { throw err; }); diff --git a/Clipper/popup/src/index.js b/Clipper/popup/src/index.js index 1419672eb..ec5dfa059 100644 --- a/Clipper/popup/src/index.js +++ b/Clipper/popup/src/index.js @@ -21,7 +21,7 @@ const defaultState = { isProbablyReaderable: true, }; -const reduxMiddleware = store => next => async (action) => { +const reduxMiddleware = (store) => (next) => async (action) => { const result = next(action); const newState = store.getState(); diff --git a/ElectronClient/app.js b/ElectronClient/app.js index 39c5e8912..34314e9da 100644 --- a/ElectronClient/app.js +++ b/ElectronClient/app.js @@ -1137,7 +1137,7 @@ class Application extends BaseApplication { // It seems the "visible" property of separators is ignored by Electron, making // it display separators that we want hidden. So this function iterates through // them and remove them completely. - const cleanUpSeparators = items => { + const cleanUpSeparators = (items) => { const output = []; for (const item of items) { if ('visible' in item && item.type === 'separator' && !item.visible) continue; diff --git a/ElectronClient/checkForUpdates.js b/ElectronClient/checkForUpdates.js index 1f571c6f5..79b89b99a 100644 --- a/ElectronClient/checkForUpdates.js +++ b/ElectronClient/checkForUpdates.js @@ -157,7 +157,7 @@ function checkForUpdates(inBackground, window, logFilePath, options) { if (buttonIndex === 0) require('electron').shell.openExternal(release.downloadUrl ? release.downloadUrl : release.pageUrl); if (buttonIndex === 2) require('electron').shell.openExternal(release.pageUrl); } - }).catch(error => { + }).catch((error) => { autoUpdateLogger_.error(error); if (!checkInBackground_) showErrorMessageBox(error.message); }).then(() => { diff --git a/ElectronClient/gui/ClipperConfigScreen.jsx b/ElectronClient/gui/ClipperConfigScreen.jsx index 6e4c200ef..40bb8d595 100644 --- a/ElectronClient/gui/ClipperConfigScreen.jsx +++ b/ElectronClient/gui/ClipperConfigScreen.jsx @@ -143,7 +143,7 @@ class ClipperConfigScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, clipperServer: state.clipperServer, diff --git a/ElectronClient/gui/ConfigScreen.jsx b/ElectronClient/gui/ConfigScreen.jsx index 4e023f799..ebe81d38e 100644 --- a/ElectronClient/gui/ConfigScreen.jsx +++ b/ElectronClient/gui/ConfigScreen.jsx @@ -314,7 +314,7 @@ class ConfigScreenComponent extends React.Component { { + onChange={(event) => { onPathChange(event); }} value={cmd[0]} @@ -430,7 +430,7 @@ class ConfigScreenComponent extends React.Component { { + onChange={(event) => { onArgsChange(event); }} value={cmd[1]} @@ -449,7 +449,7 @@ class ConfigScreenComponent extends React.Component { ); } else { - const onTextChange = event => { + const onTextChange = (event) => { updateSettingValue(key, event.target.value); }; @@ -462,7 +462,7 @@ class ConfigScreenComponent extends React.Component { type={inputType} style={inputStyle} value={this.state.settings[key]} - onChange={event => { + onChange={(event) => { onTextChange(event); }} /> @@ -471,7 +471,7 @@ class ConfigScreenComponent extends React.Component { ); } } else if (md.type === Setting.TYPE_INT) { - const onNumChange = event => { + const onNumChange = (event) => { updateSettingValue(key, event.target.value); }; @@ -489,7 +489,7 @@ class ConfigScreenComponent extends React.Component { type="number" style={inputStyle} value={this.state.settings[key]} - onChange={event => { + onChange={(event) => { onNumChange(event); }} min={md.minimum} @@ -620,7 +620,7 @@ class ConfigScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, settings: state.settings, diff --git a/ElectronClient/gui/DropboxLoginScreen.jsx b/ElectronClient/gui/DropboxLoginScreen.jsx index 88be59f61..f9bc562aa 100644 --- a/ElectronClient/gui/DropboxLoginScreen.jsx +++ b/ElectronClient/gui/DropboxLoginScreen.jsx @@ -10,7 +10,7 @@ class DropboxLoginScreenComponent extends React.Component { constructor() { super(); - this.shared_ = new Shared(this, msg => bridge().showInfoMessageBox(msg), msg => bridge().showErrorMessageBox(msg)); + this.shared_ = new Shared(this, (msg) => bridge().showInfoMessageBox(msg), (msg) => bridge().showErrorMessageBox(msg)); } UNSAFE_componentWillMount() { @@ -51,7 +51,7 @@ class DropboxLoginScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, }; diff --git a/ElectronClient/gui/EncryptionConfigScreen.jsx b/ElectronClient/gui/EncryptionConfigScreen.jsx index 8851354e4..d83442d97 100644 --- a/ElectronClient/gui/EncryptionConfigScreen.jsx +++ b/ElectronClient/gui/EncryptionConfigScreen.jsx @@ -48,7 +48,7 @@ class EncryptionConfigScreenComponent extends React.Component { return shared.onSavePasswordClick(this, mk); }; - const onPasswordChange = event => { + const onPasswordChange = (event) => { return shared.onPasswordChange(this, mk, event.target.value); }; @@ -64,7 +64,7 @@ class EncryptionConfigScreenComponent extends React.Component { {time.formatMsToLocal(mk.created_time)} {time.formatMsToLocal(mk.updated_time)} - onPasswordChange(event)} />{' '} + onPasswordChange(event)} />{' '} @@ -287,7 +287,7 @@ class EncryptionConfigScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, masterKeys: state.masterKeys, diff --git a/ElectronClient/gui/Header.jsx b/ElectronClient/gui/Header.jsx index 667052dfc..855529658 100644 --- a/ElectronClient/gui/Header.jsx +++ b/ElectronClient/gui/Header.jsx @@ -17,13 +17,13 @@ class HeaderComponent extends React.Component { this.searchOnQuery_ = null; this.searchElement_ = null; - const triggerOnQuery = query => { + const triggerOnQuery = (query) => { clearTimeout(this.scheduleSearchChangeEventIid_); if (this.searchOnQuery_) this.searchOnQuery_(query); this.scheduleSearchChangeEventIid_ = null; }; - this.search_onChange = event => { + this.search_onChange = (event) => { this.setState({ searchQuery: event.target.value }); if (this.scheduleSearchChangeEventIid_) clearTimeout(this.scheduleSearchChangeEventIid_); @@ -55,7 +55,7 @@ class HeaderComponent extends React.Component { }, 5000); }; - this.search_keyDown = event => { + this.search_keyDown = (event) => { if (event.keyCode === 27) { // ESCAPE this.resetSearch(); @@ -261,7 +261,7 @@ class HeaderComponent extends React.Component { return (
- (this.searchElement_ = elem)} onFocus={this.search_onFocus} onBlur={this.search_onBlur} onKeyDown={this.search_keyDown} /> + (this.searchElement_ = elem)} onFocus={this.search_onFocus} onBlur={this.search_onBlur} onKeyDown={this.search_keyDown} /> {icon} @@ -326,7 +326,7 @@ class HeaderComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, windowCommand: state.windowCommand, diff --git a/ElectronClient/gui/HelpButton.jsx b/ElectronClient/gui/HelpButton.jsx index 9aa044605..08189d08e 100644 --- a/ElectronClient/gui/HelpButton.jsx +++ b/ElectronClient/gui/HelpButton.jsx @@ -27,7 +27,7 @@ class HelpButtonComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, }; diff --git a/ElectronClient/gui/ImportScreen.jsx b/ElectronClient/gui/ImportScreen.jsx index d2852442f..138949907 100644 --- a/ElectronClient/gui/ImportScreen.jsx +++ b/ElectronClient/gui/ImportScreen.jsx @@ -67,7 +67,7 @@ class ImportScreenComponent extends React.Component { let lastProgress = ''; const options = { - onProgress: progressState => { + onProgress: (progressState) => { const line = []; line.push(_('Found: %d.', progressState.loaded)); line.push(_('Created: %d.', progressState.created)); @@ -78,7 +78,7 @@ class ImportScreenComponent extends React.Component { lastProgress = line.join(' '); this.addMessage('progress', lastProgress); }, - onError: error => { + onError: (error) => { // Don't display the error directly because most of the time it doesn't matter // (eg. for weird broken HTML, but the note is still imported) console.warn('When importing ENEX file', error); @@ -123,7 +123,7 @@ class ImportScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, }; diff --git a/ElectronClient/gui/MainScreen.jsx b/ElectronClient/gui/MainScreen.jsx index 932859d01..4aec188a8 100644 --- a/ElectronClient/gui/MainScreen.jsx +++ b/ElectronClient/gui/MainScreen.jsx @@ -172,7 +172,7 @@ class MainScreenComponent extends React.Component { this.setState({ promptOptions: { label: _('Notebook title:'), - onClose: async answer => { + onClose: async (answer) => { if (answer) { let folder = null; try { @@ -197,7 +197,7 @@ class MainScreenComponent extends React.Component { } else if (command.name === 'setTags') { const tags = await Tag.commonTagsByNoteIds(command.noteIds); const startTags = tags - .map(a => { + .map((a) => { return { value: a.id, label: a.title }; }) .sort((a, b) => { @@ -206,7 +206,7 @@ class MainScreenComponent extends React.Component { return a.label.localeCompare(b.label, undefined, { sensitivity: 'accent' }); }); const allTags = await Tag.allWithNotes(); - const tagSuggestions = allTags.map(a => { + const tagSuggestions = allTags.map((a) => { return { value: a.id, label: a.title }; }) .sort((a, b) => { @@ -221,24 +221,24 @@ class MainScreenComponent extends React.Component { inputType: 'tags', value: startTags, autocomplete: tagSuggestions, - onClose: async answer => { + onClose: async (answer) => { if (answer !== null) { - const endTagTitles = answer.map(a => { + const endTagTitles = answer.map((a) => { return a.label.trim(); }); if (command.noteIds.length === 1) { await Tag.setNoteTagsByTitles(command.noteIds[0], endTagTitles); } else { - const startTagTitles = startTags.map(a => { return a.label.trim(); }); - const addTags = endTagTitles.filter(value => !startTagTitles.includes(value)); - const delTags = startTagTitles.filter(value => !endTagTitles.includes(value)); + const startTagTitles = startTags.map((a) => { return a.label.trim(); }); + const addTags = endTagTitles.filter((value) => !startTagTitles.includes(value)); + const delTags = startTagTitles.filter((value) => !endTagTitles.includes(value)); // apply the tag additions and deletions to each selected note for (let i = 0; i < command.noteIds.length; i++) { const tags = await Tag.tagsByNoteId(command.noteIds[i]); - let tagTitles = tags.map(a => { return a.title; }); + let tagTitles = tags.map((a) => { return a.title; }); tagTitles = tagTitles.concat(addTags); - tagTitles = tagTitles.filter(value => !delTags.includes(value)); + tagTitles = tagTitles.filter((value) => !delTags.includes(value)); await Tag.setNoteTagsByTitles(command.noteIds[i], tagTitles); } } @@ -268,7 +268,7 @@ class MainScreenComponent extends React.Component { inputType: 'dropdown', value: '', autocomplete: startFolders, - onClose: async answer => { + onClose: async (answer) => { if (answer != null) { for (let i = 0; i < command.noteIds.length; i++) { await Note.moveToFolder(command.noteIds[i], answer.value); @@ -286,7 +286,7 @@ class MainScreenComponent extends React.Component { promptOptions: { label: _('Rename notebook:'), value: folder.title, - onClose: async answer => { + onClose: async (answer) => { if (answer !== null) { try { folder.title = answer; @@ -307,7 +307,7 @@ class MainScreenComponent extends React.Component { promptOptions: { label: _('Rename tag:'), value: tag.title, - onClose: async answer => { + onClose: async (answer) => { if (answer !== null) { try { tag.title = answer; @@ -439,7 +439,7 @@ class MainScreenComponent extends React.Component { inputType: 'dropdown', value: this.props.templates[0], // Need to start with some value autocomplete: this.props.templates, - onClose: async answer => { + onClose: async (answer) => { if (answer) { if (command.noteType === 'note' || command.noteType === 'todo') { createNewNote(answer.value, command.noteType === 'todo'); @@ -839,7 +839,7 @@ class MainScreenComponent extends React.Component { headerItems.push({ title: _('Search...'), iconName: 'fa-search', - onQuery: query => { + onQuery: (query) => { this.doCommand({ name: 'search', query: query }); }, type: 'search', @@ -887,7 +887,7 @@ class MainScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, settingEditorCodeView: state.settings['editor.codeView'], diff --git a/ElectronClient/gui/Navigator.jsx b/ElectronClient/gui/Navigator.jsx index 5df5e67d3..816b94754 100644 --- a/ElectronClient/gui/Navigator.jsx +++ b/ElectronClient/gui/Navigator.jsx @@ -44,7 +44,7 @@ class NavigatorComponent extends Component { } } -const Navigator = connect(state => { +const Navigator = connect((state) => { return { route: state.route, }; diff --git a/ElectronClient/gui/NoteEditor/NoteBody/AceEditor/AceEditor.tsx b/ElectronClient/gui/NoteEditor/NoteBody/AceEditor/AceEditor.tsx index 437d6d0e8..17238b075 100644 --- a/ElectronClient/gui/NoteEditor/NoteBody/AceEditor/AceEditor.tsx +++ b/ElectronClient/gui/NoteEditor/NoteBody/AceEditor/AceEditor.tsx @@ -337,7 +337,7 @@ function AceEditor(props: NoteBodyEditorProps, ref: any) { }, [wrapSelectionWithStrings]); const onEditorKeyDown = useCallback((event: any) => { - setLastKeys(prevLastKeys => { + setLastKeys((prevLastKeys) => { const keys = prevLastKeys.slice(); keys.push(event.key); while (keys.length > 2) keys.splice(0, 1); diff --git a/ElectronClient/gui/NoteEditor/NoteEditor.tsx b/ElectronClient/gui/NoteEditor/NoteEditor.tsx index b9badf698..315b80819 100644 --- a/ElectronClient/gui/NoteEditor/NoteEditor.tsx +++ b/ElectronClient/gui/NoteEditor/NoteEditor.tsx @@ -252,7 +252,7 @@ function NoteEditor(props: NoteEditorProps) { const onBodyWillChange = useCallback((event: any) => { handleProvisionalFlag(); - setFormNote(prev => { + setFormNote((prev) => { return { ...prev, bodyWillChangeId: event.changeId, @@ -286,7 +286,7 @@ function NoteEditor(props: NoteEditorProps) { }, [formNote]); const onNotePropertyChange = useCallback((event) => { - setFormNote(formNote => { + setFormNote((formNote) => { if (formNote.id !== event.note.id) return formNote; const newFormNote: FormNote = { ...formNote }; diff --git a/ElectronClient/gui/NoteList.jsx b/ElectronClient/gui/NoteList.jsx index 8289d5fa1..41d3d4544 100644 --- a/ElectronClient/gui/NoteList.jsx +++ b/ElectronClient/gui/NoteList.jsx @@ -118,7 +118,7 @@ class NoteListComponent extends React.Component { } }; - const onDragStart = event => { + const onDragStart = (event) => { let noteIds = []; // Here there is two cases: @@ -138,7 +138,7 @@ class NoteListComponent extends React.Component { event.dataTransfer.setData('text/x-jop-note-ids', JSON.stringify(noteIds)); }; - const onCheckboxClick = async event => { + const onCheckboxClick = async (event) => { const checked = event.target.checked; const newNote = { id: item.id, @@ -173,7 +173,7 @@ class NoteListComponent extends React.Component { style={{ margin: 0, marginBottom: 1, marginRight: 5 }} type="checkbox" defaultChecked={!!item.todo_completed} - onClick={event => { + onClick={(event) => { onCheckboxClick(event, item); }} /> @@ -232,14 +232,14 @@ class NoteListComponent extends React.Component { {checkbox} this.itemContextMenu(event)} + onContextMenu={(event) => this.itemContextMenu(event)} href="#" draggable={true} style={listItemTitleStyle} - onClick={event => { + onClick={(event) => { onTitleClick(event, item); }} - onDragStart={event => onDragStart(event)} + onDragStart={(event) => onDragStart(event)} data-id={item.id} > {watchedIcon} @@ -365,7 +365,7 @@ class NoteListComponent extends React.Component { event.preventDefault(); const notes = BaseModel.modelsByIds(this.props.notes, noteIds); - const todos = notes.filter(n => !!n.is_todo); + const todos = notes.filter((n) => !!n.is_todo); if (!todos.length) return; for (let i = 0; i < todos.length; i++) { @@ -457,7 +457,7 @@ class NoteListComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { notes: state.notes, folders: state.folders, diff --git a/ElectronClient/gui/NotePropertiesDialog.jsx b/ElectronClient/gui/NotePropertiesDialog.jsx index da9a09d12..dba4836b9 100644 --- a/ElectronClient/gui/NotePropertiesDialog.jsx +++ b/ElectronClient/gui/NotePropertiesDialog.jsx @@ -232,7 +232,7 @@ class NotePropertiesDialog extends React.Component { let editCompHandler = null; let editCompIcon = null; - const onKeyDown = event => { + const onKeyDown = (event) => { if (event.keyCode === 13) { this.saveProperty(); } else if (event.keyCode === 27) { @@ -249,10 +249,10 @@ class NotePropertiesDialog extends React.Component { dateFormat={time.dateFormat()} timeFormat={time.timeFormat()} inputProps={{ - onKeyDown: event => onKeyDown(event, key), + onKeyDown: (event) => onKeyDown(event, key), style: styles.input, }} - onChange={momentObject => { + onChange={(momentObject) => { this.setState({ editedValue: momentObject }); }} /> @@ -268,10 +268,10 @@ class NotePropertiesDialog extends React.Component { defaultValue={value} type="text" ref="editField" - onChange={event => { + onChange={(event) => { this.setState({ editedValue: event.target.value }); }} - onKeyDown={event => onKeyDown(event)} + onKeyDown={(event) => onKeyDown(event)} style={styles.input} /> ); diff --git a/ElectronClient/gui/NoteRevisionViewer.jsx b/ElectronClient/gui/NoteRevisionViewer.jsx index eee75d756..6b7b51fe1 100644 --- a/ElectronClient/gui/NoteRevisionViewer.jsx +++ b/ElectronClient/gui/NoteRevisionViewer.jsx @@ -211,7 +211,7 @@ class NoteRevisionViewerComponent extends React.PureComponent { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, }; diff --git a/ElectronClient/gui/NoteSearchBar.jsx b/ElectronClient/gui/NoteSearchBar.jsx index d7ce5ca95..ff25c9bdf 100644 --- a/ElectronClient/gui/NoteSearchBar.jsx +++ b/ElectronClient/gui/NoteSearchBar.jsx @@ -170,7 +170,7 @@ class NoteSearchBarComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, }; diff --git a/ElectronClient/gui/NoteStatusBar.jsx b/ElectronClient/gui/NoteStatusBar.jsx index 15a71635f..8317fa064 100644 --- a/ElectronClient/gui/NoteStatusBar.jsx +++ b/ElectronClient/gui/NoteStatusBar.jsx @@ -23,7 +23,7 @@ class NoteStatusBarComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { // notes: state.notes, // folders: state.folders, diff --git a/ElectronClient/gui/NoteTextViewer.jsx b/ElectronClient/gui/NoteTextViewer.jsx index f5bb54fe1..8129ce709 100644 --- a/ElectronClient/gui/NoteTextViewer.jsx +++ b/ElectronClient/gui/NoteTextViewer.jsx @@ -167,7 +167,7 @@ class NoteTextViewerComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, }; diff --git a/ElectronClient/gui/OneDriveLoginScreen.jsx b/ElectronClient/gui/OneDriveLoginScreen.jsx index 6a72b625a..1b200c4c2 100644 --- a/ElectronClient/gui/OneDriveLoginScreen.jsx +++ b/ElectronClient/gui/OneDriveLoginScreen.jsx @@ -19,7 +19,7 @@ class OneDriveLoginScreenComponent extends React.Component { async componentDidMount() { const log = (s) => { - this.setState(state => { + this.setState((state) => { const authLog = state.authLog.slice(); authLog.push({ key: (Date.now() + Math.random()).toString(), text: s }); return { authLog: authLog }; @@ -76,7 +76,7 @@ class OneDriveLoginScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, }; diff --git a/ElectronClient/gui/PromptDialog.jsx b/ElectronClient/gui/PromptDialog.jsx index cc13a0df1..57110aa83 100644 --- a/ElectronClient/gui/PromptDialog.jsx +++ b/ElectronClient/gui/PromptDialog.jsx @@ -100,18 +100,18 @@ class PromptDialog extends React.Component { }; this.styles_.select = { - control: provided => + control: (provided) => Object.assign(provided, { minWidth: width * 0.2, maxWidth: width * 0.5, fontFamily: theme.fontFamily, }), - input: provided => + input: (provided) => Object.assign(provided, { minWidth: '20px', color: theme.color, }), - menu: provided => + menu: (provided) => Object.assign(provided, { color: theme.color, fontFamily: theme.fontFamily, @@ -123,17 +123,17 @@ class PromptDialog extends React.Component { fontFamily: theme.fontFamily, paddingLeft: `${10 + (state.data.indentDepth || 0) * 20}px`, }), - multiValueLabel: provided => + multiValueLabel: (provided) => Object.assign(provided, { fontFamily: theme.fontFamily, }), - multiValueRemove: provided => + multiValueRemove: (provided) => Object.assign(provided, { color: theme.color, }), }; - this.styles_.selectTheme = tagTheme => + this.styles_.selectTheme = (tagTheme) => Object.assign(tagTheme, { borderRadius: 2, colors: Object.assign(tagTheme.colors, { @@ -181,7 +181,7 @@ class PromptDialog extends React.Component { this.setState({ visible: false, answer: '' }); }; - const onChange = event => { + const onChange = (event) => { this.setState({ answer: event.target.value }); }; @@ -194,16 +194,16 @@ class PromptDialog extends React.Component { // return m.isValid() ? m.toDate() : null; // } - const onDateTimeChange = momentObject => { + const onDateTimeChange = (momentObject) => { this.setState({ answer: momentObject }); }; - const onSelectChange = newValue => { + const onSelectChange = (newValue) => { this.setState({ answer: newValue }); this.focusInput_ = true; }; - const onKeyDown = event => { + const onKeyDown = (event) => { if (event.key === 'Enter') { if (this.props.inputType !== 'tags' && this.props.inputType !== 'dropdown') { onClose(true); @@ -221,13 +221,13 @@ class PromptDialog extends React.Component { let inputComp = null; if (this.props.inputType === 'datetime') { - inputComp = onDateTimeChange(momentObject)} />; + inputComp = onDateTimeChange(momentObject)} />; } else if (this.props.inputType === 'tags') { - inputComp = onKeyDown(event)} />; + inputComp = onKeyDown(event)} />; } else if (this.props.inputType === 'dropdown') { - inputComp = onKeyDown(event)} />; } else { - inputComp = onChange(event)} onKeyDown={event => onKeyDown(event)} />; + inputComp = onChange(event)} onKeyDown={(event) => onKeyDown(event)} />; } const buttonComps = []; diff --git a/ElectronClient/gui/Root.jsx b/ElectronClient/gui/Root.jsx index 54e8fc36f..76c509ed7 100644 --- a/ElectronClient/gui/Root.jsx +++ b/ElectronClient/gui/Root.jsx @@ -98,7 +98,7 @@ class RootComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { size: state.windowContentSize, zoomFactor: state.settings.windowContentZoomFactor / 100, diff --git a/ElectronClient/gui/SideBar.jsx b/ElectronClient/gui/SideBar.jsx index 393e53595..d510b98f5 100644 --- a/ElectronClient/gui/SideBar.jsx +++ b/ElectronClient/gui/SideBar.jsx @@ -20,7 +20,7 @@ class SideBarComponent extends React.Component { constructor() { super(); - this.onFolderDragStart_ = event => { + this.onFolderDragStart_ = (event) => { const folderId = event.currentTarget.getAttribute('folderid'); if (!folderId) return; @@ -29,12 +29,12 @@ class SideBarComponent extends React.Component { event.dataTransfer.setData('text/x-jop-folder-ids', JSON.stringify([folderId])); }; - this.onFolderDragOver_ = event => { + this.onFolderDragOver_ = (event) => { if (event.dataTransfer.types.indexOf('text/x-jop-note-ids') >= 0) event.preventDefault(); if (event.dataTransfer.types.indexOf('text/x-jop-folder-ids') >= 0) event.preventDefault(); }; - this.onFolderDrop_ = async event => { + this.onFolderDrop_ = async (event) => { const folderId = event.currentTarget.getAttribute('folderid'); const dt = event.dataTransfer; if (!dt) return; @@ -62,7 +62,7 @@ class SideBarComponent extends React.Component { } }; - this.onTagDrop_ = async event => { + this.onTagDrop_ = async (event) => { const tagId = event.currentTarget.getAttribute('tagid'); const dt = event.dataTransfer; if (!dt) return; @@ -77,7 +77,7 @@ class SideBarComponent extends React.Component { } }; - this.onFolderToggleClick_ = async event => { + this.onFolderToggleClick_ = async (event) => { const folderId = event.currentTarget.getAttribute('folderid'); this.props.dispatch({ @@ -489,7 +489,7 @@ class SideBarComponent extends React.Component { href="#" data-id={folder.id} data-type={BaseModel.TYPE_FOLDER} - onContextMenu={event => this.itemContextMenu(event)} + onContextMenu={(event) => this.itemContextMenu(event)} style={style} folderid={folder.id} onClick={() => { @@ -517,7 +517,7 @@ class SideBarComponent extends React.Component { ref={anchorRef} data-id={tag.id} data-type={BaseModel.TYPE_TAG} - onContextMenu={event => this.itemContextMenu(event)} + onContextMenu={(event) => this.itemContextMenu(event)} tagid={tag.id} key={tag.id} style={style} @@ -586,7 +586,7 @@ class SideBarComponent extends React.Component { style={style} key={key} {...extraProps} - onClick={event => { + onClick={(event) => { // if a custom click event is attached, trigger that. if (headerClick) { headerClick(key, event); @@ -832,7 +832,7 @@ class SideBarComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { folders: state.folders, tags: state.tags, diff --git a/ElectronClient/gui/StatusScreen.jsx b/ElectronClient/gui/StatusScreen.jsx index aa8249c8b..77a97ef9b 100644 --- a/ElectronClient/gui/StatusScreen.jsx +++ b/ElectronClient/gui/StatusScreen.jsx @@ -146,7 +146,7 @@ class StatusScreenComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme, settings: state.settings, diff --git a/ElectronClient/gui/TagItem.jsx b/ElectronClient/gui/TagItem.jsx index ebad306d9..a321cdef5 100644 --- a/ElectronClient/gui/TagItem.jsx +++ b/ElectronClient/gui/TagItem.jsx @@ -12,7 +12,7 @@ class TagItemComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme }; }; diff --git a/ElectronClient/gui/TagList.jsx b/ElectronClient/gui/TagList.jsx index c5330b7ed..d6b138876 100644 --- a/ElectronClient/gui/TagList.jsx +++ b/ElectronClient/gui/TagList.jsx @@ -41,7 +41,7 @@ class TagListComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme }; }; diff --git a/ElectronClient/gui/Toolbar.jsx b/ElectronClient/gui/Toolbar.jsx index f70ed9336..07f499511 100644 --- a/ElectronClient/gui/Toolbar.jsx +++ b/ElectronClient/gui/Toolbar.jsx @@ -51,7 +51,7 @@ class ToolbarComponent extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { theme: state.settings.theme }; }; diff --git a/ElectronClient/gui/note-viewer/preload.js b/ElectronClient/gui/note-viewer/preload.js index 42ee97654..0ccc1b1cd 100644 --- a/ElectronClient/gui/note-viewer/preload.js +++ b/ElectronClient/gui/note-viewer/preload.js @@ -21,7 +21,7 @@ ipcRenderer.on('setMarkers', (event, keywords, options) => { window.postMessage({ target: 'webview', name: 'setMarkers', data: { keywords: keywords, options: options } }, '*'); }); -window.addEventListener('message', event => { +window.addEventListener('message', (event) => { // Here we only deal with messages that are sent from the webview to the main Electron process if (!event.data || event.data.target !== 'main') return; diff --git a/ElectronClient/gui/utils/NoteListUtils.js b/ElectronClient/gui/utils/NoteListUtils.js index 58e698159..587a21f44 100644 --- a/ElectronClient/gui/utils/NoteListUtils.js +++ b/ElectronClient/gui/utils/NoteListUtils.js @@ -12,7 +12,7 @@ const { substrWithEllipsis } = require('lib/string-utils'); class NoteListUtils { static makeContextMenu(noteIds, props) { - const notes = noteIds.map(id => BaseModel.byId(props.notes, id)); + const notes = noteIds.map((id) => BaseModel.byId(props.notes, id)); let hasEncrypted = false; for (let i = 0; i < notes.length; i++) { diff --git a/ElectronClient/main-html.js b/ElectronClient/main-html.js index 990f1a012..cd127464c 100644 --- a/ElectronClient/main-html.js +++ b/ElectronClient/main-html.js @@ -81,11 +81,11 @@ shimInit(); // Disable drag and drop of links inside application (which would // open it as if the whole app was a browser) -document.addEventListener('dragover', event => event.preventDefault()); -document.addEventListener('drop', event => event.preventDefault()); +document.addEventListener('dragover', (event) => event.preventDefault()); +document.addEventListener('drop', (event) => event.preventDefault()); // Disable middle-click (which would open a new browser window, but we don't want this) -document.addEventListener('auxclick', event => event.preventDefault()); +document.addEventListener('auxclick', (event) => event.preventDefault()); // Each link (rendered as a button or list item) has its own custom click event // so disable the default. In particular this will disable Ctrl+Clicking a link diff --git a/ElectronClient/plugins/GotoAnything.jsx b/ElectronClient/plugins/GotoAnything.jsx index d73776004..53346557a 100644 --- a/ElectronClient/plugins/GotoAnything.jsx +++ b/ElectronClient/plugins/GotoAnything.jsx @@ -208,7 +208,7 @@ class Dialog extends React.PureComponent { searchQuery = this.makeSearchQuery(this.state.query); results = await SearchEngine.instance().search(searchQuery); - resultsInBody = !!results.find(row => row.fields.includes('body')); + resultsInBody = !!results.find((row) => row.fields.includes('body')); if (!resultsInBody) { for (let i = 0; i < results.length; i++) { @@ -219,7 +219,7 @@ class Dialog extends React.PureComponent { } else { const limit = 20; const searchKeywords = this.keywords(searchQuery); - const notes = await Note.byIds(results.map(result => result.id).slice(0, limit), { fields: ['id', 'body'] }); + const notes = await Note.byIds(results.map((result) => result.id).slice(0, limit), { fields: ['id', 'body'] }); const notesById = notes.reduce((obj, { id, body }) => ((obj[[id]] = body), obj), {}); for (let i = 0; i < results.length; i++) { @@ -247,7 +247,7 @@ class Dialog extends React.PureComponent { // e.g. 'Joplin is a free, open source' and 'open source note taking application' // will result in 'Joplin is a free, open source note taking application' const mergedIndices = mergeOverlappingIntervals(indices, 3); - fragments = mergedIndices.map(f => body.slice(f[0], f[1])).join(' ... '); + fragments = mergedIndices.map((f) => body.slice(f[0], f[1])).join(' ... '); // Add trailing ellipsis if the final fragment doesn't end where the note is ending if (mergedIndices.length && mergedIndices[mergedIndices.length - 1][1] !== body.length) fragments += ' ...'; } diff --git a/ElectronClient/tools/copyTinyMceLangs.js b/ElectronClient/tools/copyTinyMceLangs.js index 79342e088..9d30a9e66 100644 --- a/ElectronClient/tools/copyTinyMceLangs.js +++ b/ElectronClient/tools/copyTinyMceLangs.js @@ -9,7 +9,7 @@ async function main() { await fs.mkdirp(destDir); await fs.copy(sourceDir, destDir); - const supportedLocales = glob.sync(`${sourceDir}/*.js`).map(s => { + const supportedLocales = glob.sync(`${sourceDir}/*.js`).map((s) => { s = s.split('/'); s = s[s.length - 1]; s = s.split('.'); diff --git a/ReactNativeClient/MarkdownEditor/MarkdownEditor.js b/ReactNativeClient/MarkdownEditor/MarkdownEditor.js index f6f05906b..2a9a6664e 100644 --- a/ReactNativeClient/MarkdownEditor/MarkdownEditor.js +++ b/ReactNativeClient/MarkdownEditor/MarkdownEditor.js @@ -110,7 +110,7 @@ export default class MarkdownEditor extends React.Component { if (this.props.onMarkdownChange) this.props.onMarkdownChange(input); }; - onSelectionChange = event => { + onSelectionChange = (event) => { this.setState({ selection: event.nativeEvent.selection }); }; diff --git a/ReactNativeClient/lib/BaseApplication.js b/ReactNativeClient/lib/BaseApplication.js index 31b93767b..682f1b317 100644 --- a/ReactNativeClient/lib/BaseApplication.js +++ b/ReactNativeClient/lib/BaseApplication.js @@ -358,7 +358,7 @@ class BaseApplication { } generalMiddlewareFn() { - const middleware = store => next => action => { + const middleware = (store) => (next) => (action) => { return this.generalMiddleware(store, next, action); }; @@ -690,7 +690,7 @@ class BaseApplication { if (!Setting.value('api.token')) { EncryptionService.instance() .randomHexString(64) - .then(token => { + .then((token) => { Setting.setValue('api.token', token); }); } diff --git a/ReactNativeClient/lib/BaseModel.js b/ReactNativeClient/lib/BaseModel.js index 7d28a0ef3..30070bc46 100644 --- a/ReactNativeClient/lib/BaseModel.js +++ b/ReactNativeClient/lib/BaseModel.js @@ -158,7 +158,7 @@ class BaseModel { if (options.where) sql += ` WHERE ${options.where}`; return this.db() .selectOne(sql) - .then(r => { + .then((r) => { return r ? r['total'] : 0; }); } @@ -198,7 +198,7 @@ class BaseModel { static async allIds(options = null) { const q = this.applySqlOptions(options, `SELECT id FROM \`${this.tableName()}\``); const rows = await this.db().selectAll(q.sql, q.params); - return rows.map(r => r.id); + return rows.map((r) => r.id); } static async all(options = null) { @@ -253,7 +253,7 @@ class BaseModel { if (params === null) params = []; return this.db() .selectOne(sql, params) - .then(model => { + .then((model) => { return this.filter(this.addModelMd(model)); }); } @@ -262,7 +262,7 @@ class BaseModel { if (params === null) params = []; return this.db() .selectAll(sql, params) - .then(models => { + .then((models) => { return this.filterArray(this.addModelMd(models)); }); } diff --git a/ReactNativeClient/lib/ClipperServer.js b/ReactNativeClient/lib/ClipperServer.js index 14a597e5d..b2a1c575e 100644 --- a/ReactNativeClient/lib/ClipperServer.js +++ b/ReactNativeClient/lib/ClipperServer.js @@ -189,7 +189,7 @@ class ClipperServer { if (request.method === 'POST' || request.method === 'PUT') { let body = ''; - request.on('data', data => { + request.on('data', (data) => { body += data; }); diff --git a/ReactNativeClient/lib/CssUtils.js b/ReactNativeClient/lib/CssUtils.js index 9f97a3706..68c2e4d20 100644 --- a/ReactNativeClient/lib/CssUtils.js +++ b/ReactNativeClient/lib/CssUtils.js @@ -1,6 +1,6 @@ const fs = require('fs-extra'); -const loadCustomCss = async filePath => { +const loadCustomCss = async (filePath) => { let cssString = ''; if (await fs.pathExists(filePath)) { try { @@ -16,7 +16,7 @@ const loadCustomCss = async filePath => { return cssString; }; -const injectCustomStyles = async cssFilePath => { +const injectCustomStyles = async (cssFilePath) => { const css = await loadCustomCss(cssFilePath); const styleTag = document.createElement('style'); styleTag.type = 'text/css'; diff --git a/ReactNativeClient/lib/DropboxApi.js b/ReactNativeClient/lib/DropboxApi.js index 7e80fc494..bc6f50daf 100644 --- a/ReactNativeClient/lib/DropboxApi.js +++ b/ReactNativeClient/lib/DropboxApi.js @@ -165,7 +165,7 @@ class DropboxApi { }; // Creates an error object with as much data as possible as it will appear in the log, which will make debugging easier - const newError = message => { + const newError = (message) => { const json = loadResponseJson(); let code = ''; if (json && json.error_summary) { diff --git a/ReactNativeClient/lib/HtmlToMd.js b/ReactNativeClient/lib/HtmlToMd.js index adb2de5b3..8d7b4b836 100644 --- a/ReactNativeClient/lib/HtmlToMd.js +++ b/ReactNativeClient/lib/HtmlToMd.js @@ -6,7 +6,7 @@ class HtmlToMd { const turndownPluginGfm = require('joplin-turndown-plugin-gfm').gfm; const turndown = new TurndownService({ headingStyle: 'atx', - anchorNames: options.anchorNames ? options.anchorNames.map(n => n.trim().toLowerCase()) : [], + anchorNames: options.anchorNames ? options.anchorNames.map((n) => n.trim().toLowerCase()) : [], codeBlockStyle: 'fenced', preserveImageTagsWithSize: !!options.preserveImageTagsWithSize, bulletListMarker: '-', diff --git a/ReactNativeClient/lib/SyncTargetDropbox.js b/ReactNativeClient/lib/SyncTargetDropbox.js index 2b2f325db..60b8dcdb2 100644 --- a/ReactNativeClient/lib/SyncTargetDropbox.js +++ b/ReactNativeClient/lib/SyncTargetDropbox.js @@ -50,7 +50,7 @@ class SyncTargetDropbox extends BaseSyncTarget { secret: params.secret, }); - api.on('authRefreshed', auth => { + api.on('authRefreshed', (auth) => { this.logger().info('Saving updated Dropbox auth.'); Setting.setValue(`sync.${SyncTargetDropbox.id()}.auth`, auth ? auth : null); }); diff --git a/ReactNativeClient/lib/SyncTargetOneDrive.js b/ReactNativeClient/lib/SyncTargetOneDrive.js index fa1ba2ee8..a5fb1f6a7 100644 --- a/ReactNativeClient/lib/SyncTargetOneDrive.js +++ b/ReactNativeClient/lib/SyncTargetOneDrive.js @@ -49,7 +49,7 @@ class SyncTargetOneDrive extends BaseSyncTarget { this.api_ = new OneDriveApi(this.oneDriveParameters().id, this.oneDriveParameters().secret, isPublic); this.api_.setLogger(this.logger()); - this.api_.on('authRefreshed', a => { + this.api_.on('authRefreshed', (a) => { this.logger().info('Saving updated OneDrive auth.'); Setting.setValue(`sync.${this.syncTargetId()}.auth`, a ? JSON.stringify(a) : null); }); diff --git a/ReactNativeClient/lib/TaskQueue.js b/ReactNativeClient/lib/TaskQueue.js index d1b162042..e398a4b26 100644 --- a/ReactNativeClient/lib/TaskQueue.js +++ b/ReactNativeClient/lib/TaskQueue.js @@ -55,10 +55,10 @@ class TaskQueue { task .callback() - .then(result => { + .then((result) => { completeTask(task, result, null); }) - .catch(error => { + .catch((error) => { if (!error) error = new Error('Unknown error'); completeTask(task, null, error); }); @@ -68,7 +68,7 @@ class TaskQueue { } isWaiting(taskId) { - return this.waitingTasks_.find(task => task.id === taskId); + return this.waitingTasks_.find((task) => task.id === taskId); } isProcessing(taskId) { diff --git a/ReactNativeClient/lib/TemplateUtils.js b/ReactNativeClient/lib/TemplateUtils.js index e6ab429fe..1b2186e9e 100644 --- a/ReactNativeClient/lib/TemplateUtils.js +++ b/ReactNativeClient/lib/TemplateUtils.js @@ -7,7 +7,7 @@ const TemplateUtils = {}; // Mustache escapes strings (including /) with the html code by default // This isn't useful for markdown so it's disabled -Mustache.escape = text => { +Mustache.escape = (text) => { return text; }; @@ -47,7 +47,7 @@ TemplateUtils.loadTemplates = async function(filePath) { // sensitivity ensures that the sort will ignore case files.sort((a, b) => { return a.path.localeCompare(b.path, undefined, { sensitivity: 'accent' }); }); - files.forEach(async file => { + files.forEach(async (file) => { if (file.path.endsWith('.md')) { try { const fileString = await shim.fsDriver().readFile(`${filePath}/${file.path}`, 'utf-8'); diff --git a/ReactNativeClient/lib/WebDavApi.js b/ReactNativeClient/lib/WebDavApi.js index fa3c9a619..62002d534 100644 --- a/ReactNativeClient/lib/WebDavApi.js +++ b/ReactNativeClient/lib/WebDavApi.js @@ -85,7 +85,7 @@ class WebDavApi { async xmlToJson(xml) { const davNamespaces = []; // Yes, there can be more than one... xmlns:a="DAV:" xmlns:D="DAV:" - const nameProcessor = name => { + const nameProcessor = (name) => { if (name.indexOf('xmlns') !== 0) { // Check if the current name is within the DAV namespace. If it is, normalise it // by moving it to the "d:" namespace, which is what all the functions are using. diff --git a/ReactNativeClient/lib/components/CameraView.js b/ReactNativeClient/lib/components/CameraView.js index 83ecbb1b8..66b0c0d15 100644 --- a/ReactNativeClient/lib/components/CameraView.js +++ b/ReactNativeClient/lib/components/CameraView.js @@ -170,7 +170,7 @@ class CameraView extends Component { { + ref={(ref) => { this.camera = ref; }} type={this.props.cameraType} @@ -223,7 +223,7 @@ class CameraView extends Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state) => { return { cameraRatio: state.settings['camera.ratio'], cameraType: state.settings['camera.type'], diff --git a/ReactNativeClient/lib/components/Dropdown.js b/ReactNativeClient/lib/components/Dropdown.js index 22cb2f14e..675f98905 100644 --- a/ReactNativeClient/lib/components/Dropdown.js +++ b/ReactNativeClient/lib/components/Dropdown.js @@ -90,7 +90,7 @@ class Dropdown extends React.Component { this.setState({ listVisible: false }); }; - const itemRenderer = item => { + const itemRenderer = (item) => { return ( (this.headerRef_ = ref)} + ref={(ref) => (this.headerRef_ = ref)} disabled={this.props.disabled} onPress={() => { this.updateHeaderCoordinates(); @@ -141,7 +141,7 @@ class Dropdown extends React.Component { style={itemListStyle} items={this.props.items} itemHeight={itemHeight} - itemRenderer={item => { + itemRenderer={(item) => { return itemRenderer(item); }} /> diff --git a/ReactNativeClient/lib/components/ItemList.js b/ReactNativeClient/lib/components/ItemList.js index e4cafb819..6a391b1a8 100644 --- a/ReactNativeClient/lib/components/ItemList.js +++ b/ReactNativeClient/lib/components/ItemList.js @@ -93,11 +93,11 @@ class ItemList extends React.Component { return ( { + onLayout={(event) => { this.onLayout(event); }} style={style} - onScroll={event => { + onScroll={(event) => { this.onScroll(event); }} > diff --git a/ReactNativeClient/lib/components/action-button.js b/ReactNativeClient/lib/components/action-button.js index d4f2a8848..21c4fe921 100644 --- a/ReactNativeClient/lib/components/action-button.js +++ b/ReactNativeClient/lib/components/action-button.js @@ -123,7 +123,7 @@ class ActionButtonComponent extends React.Component { } } -const ActionButton = connect(state => { +const ActionButton = connect((state) => { return { folders: state.folders, locale: state.settings.locale, diff --git a/ReactNativeClient/lib/components/app-nav.js b/ReactNativeClient/lib/components/app-nav.js index 16aacf2dd..11dca0b1e 100644 --- a/ReactNativeClient/lib/components/app-nav.js +++ b/ReactNativeClient/lib/components/app-nav.js @@ -78,7 +78,7 @@ class AppNavComponent extends Component { } } -const AppNav = connect(state => { +const AppNav = connect((state) => { return { route: state.route, theme: state.settings.theme, diff --git a/ReactNativeClient/lib/components/note-body-viewer.js b/ReactNativeClient/lib/components/note-body-viewer.js index 79d185de5..8a95b8a0a 100644 --- a/ReactNativeClient/lib/components/note-body-viewer.js +++ b/ReactNativeClient/lib/components/note-body-viewer.js @@ -240,7 +240,7 @@ class NoteBodyViewer extends Component { allowFileAccess={true} onLoadEnd={() => this.onLoadEnd()} onError={() => reg.logger().error('WebView error')} - onMessage={event => { + onMessage={(event) => { // Since RN 58 (or 59) messages are now escaped twice??? let msg = unescape(unescape(event.nativeEvent.data)); diff --git a/ReactNativeClient/lib/components/note-item.js b/ReactNativeClient/lib/components/note-item.js index 471c243a8..2c6ed20ef 100644 --- a/ReactNativeClient/lib/components/note-item.js +++ b/ReactNativeClient/lib/components/note-item.js @@ -133,7 +133,7 @@ class NoteItemComponent extends Component { - this.todoCheckbox_change(checked)} /> + this.todoCheckbox_change(checked)} /> {Note.displayTitle(note)} @@ -143,7 +143,7 @@ class NoteItemComponent extends Component { } } -const NoteItem = connect(state => { +const NoteItem = connect((state) => { return { theme: state.settings.theme, noteSelectionEnabled: state.noteSelectionEnabled, diff --git a/ReactNativeClient/lib/components/note-list.js b/ReactNativeClient/lib/components/note-list.js index 6c06a4eb2..1567d32cf 100644 --- a/ReactNativeClient/lib/components/note-list.js +++ b/ReactNativeClient/lib/components/note-list.js @@ -87,10 +87,10 @@ class NoteListComponent extends Component { if (this.props.items.length) { return (this.rootRef_ = ref)} + ref={(ref) => (this.rootRef_ = ref)} data={this.props.items} renderItem={({ item }) => } - keyExtractor={item => item.id} + keyExtractor={(item) => item.id} />; } else { if (!this.props.folders.length) { @@ -109,7 +109,7 @@ class NoteListComponent extends Component { } } -const NoteList = connect(state => { +const NoteList = connect((state) => { return { items: state.notes, folders: state.folders, diff --git a/ReactNativeClient/lib/components/screen-header.js b/ReactNativeClient/lib/components/screen-header.js index 2fde037cf..f6cfff714 100644 --- a/ReactNativeClient/lib/components/screen-header.js +++ b/ReactNativeClient/lib/components/screen-header.js @@ -356,8 +356,8 @@ class ScreenHeaderComponent extends React.PureComponent { return pickerItems; }; - const titlePickerItems = mustSelect => { - const folders = this.props.folders.filter(f => f.id !== Folder.conflictFolderId()); + const titlePickerItems = (mustSelect) => { + const folders = this.props.folders.filter((f) => f.id !== Folder.conflictFolderId()); let output = []; if (mustSelect) output.push({ label: _('Move to notebook...'), value: null }); const folderTree = Folder.buildTree(folders); @@ -448,7 +448,7 @@ class ScreenHeaderComponent extends React.PureComponent { const menuComp = !menuOptionComponents.length || !showContextMenuButton ? null : ( - this.menu_select(value)} style={this.styles().contextMenu}> + this.menu_select(value)} style={this.styles().contextMenu}> @@ -481,7 +481,7 @@ class ScreenHeaderComponent extends React.PureComponent { {warningComps} { + ref={(dialogbox) => { this.dialogbox = dialogbox; }} /> @@ -494,7 +494,7 @@ ScreenHeaderComponent.defaultProps = { menuOptions: [], }; -const ScreenHeader = connect(state => { +const ScreenHeader = connect((state) => { return { historyCanGoBack: state.historyCanGoBack, locale: state.settings.locale, diff --git a/ReactNativeClient/lib/components/screens/NoteTagsDialog.js b/ReactNativeClient/lib/components/screens/NoteTagsDialog.js index 9a172e45f..08c6f747c 100644 --- a/ReactNativeClient/lib/components/screens/NoteTagsDialog.js +++ b/ReactNativeClient/lib/components/screens/NoteTagsDialog.js @@ -23,7 +23,7 @@ class NoteTagsDialogComponent extends React.Component { savingTags: false, }; - const noteHasTag = tagId => { + const noteHasTag = (tagId) => { for (let i = 0; i < this.state.tagListData.length; i++) { if (this.state.tagListData[i].id === tagId) return this.state.tagListData[i].selected; } @@ -33,11 +33,11 @@ class NoteTagsDialogComponent extends React.Component { const newTagTitles = () => { return this.state.newTags .split(',') - .map(t => t.trim().toLowerCase()) - .filter(t => !!t); + .map((t) => t.trim().toLowerCase()) + .filter((t) => !!t); }; - this.tag_press = tagId => { + this.tag_press = (tagId) => { const newData = this.state.tagListData.slice(); for (let i = 0; i < newData.length; i++) { const t = newData[i]; @@ -52,7 +52,7 @@ class NoteTagsDialogComponent extends React.Component { this.setState({ tagListData: newData }); }; - this.renderTag = data => { + this.renderTag = (data) => { const tag = data.item; const iconName = noteHasTag(tag.id) ? 'md-checkbox-outline' : 'md-square-outline'; return ( @@ -71,7 +71,7 @@ class NoteTagsDialogComponent extends React.Component { this.setState({ savingTags: true }); try { - const tagIds = this.state.tagListData.filter(t => t.selected).map(t => t.id); + const tagIds = this.state.tagListData.filter((t) => t.selected).map((t) => t.id); await Tag.setNoteTagsByIds(this.state.noteId, tagIds); const extraTitles = newTagTitles(); @@ -98,9 +98,9 @@ class NoteTagsDialogComponent extends React.Component { async loadNoteTags(noteId) { const tags = await Tag.tagsByNoteId(noteId); - const tagIds = tags.map(t => t.id); + const tagIds = tags.map((t) => t.id); - const tagListData = this.props.tags.map(tag => { + const tagListData = this.props.tags.map((tag) => { return { id: tag.id, title: tag.title, @@ -165,7 +165,7 @@ class NoteTagsDialogComponent extends React.Component { selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} value={this.state.newTags} - onChangeText={value => { + onChangeText={(value) => { this.setState({ newTags: value }); }} style={this.styles().newTagBoxInput} @@ -179,7 +179,7 @@ class NoteTagsDialogComponent extends React.Component { } } -const NoteTagsDialog = connect(state => { +const NoteTagsDialog = connect((state) => { return { theme: state.settings.theme, tags: state.tags, diff --git a/ReactNativeClient/lib/components/screens/config.js b/ReactNativeClient/lib/components/screens/config.js index ab02339a6..7bb74ba2b 100644 --- a/ReactNativeClient/lib/components/screens/config.js +++ b/ReactNativeClient/lib/components/screens/config.js @@ -392,7 +392,7 @@ class ConfigScreenComponent extends BaseScreenComponent { {md.label()} - updateSettingValue(key, value)} /> + updateSettingValue(key, value)} /> {descriptionComp} @@ -410,7 +410,7 @@ class ConfigScreenComponent extends BaseScreenComponent { {unitLabel} - updateSettingValue(key, value)} /> + updateSettingValue(key, value)} /> ); @@ -420,7 +420,7 @@ class ConfigScreenComponent extends BaseScreenComponent { {md.label()} - updateSettingValue(key, value)} secureTextEntry={!!md.secure} /> + updateSettingValue(key, value)} secureTextEntry={!!md.secure} /> ); } else { @@ -557,7 +557,7 @@ class ConfigScreenComponent extends BaseScreenComponent { } } -const ConfigScreen = connect(state => { +const ConfigScreen = connect((state) => { return { settings: state.settings, theme: state.settings.theme, diff --git a/ReactNativeClient/lib/components/screens/dropbox-login.js b/ReactNativeClient/lib/components/screens/dropbox-login.js index 548480a43..ec6d7fd22 100644 --- a/ReactNativeClient/lib/components/screens/dropbox-login.js +++ b/ReactNativeClient/lib/components/screens/dropbox-login.js @@ -16,7 +16,7 @@ class DropboxLoginScreenComponent extends BaseScreenComponent { this.styles_ = {}; - this.shared_ = new Shared(this, msg => dialogs.info(this, msg), msg => dialogs.error(this, msg)); + this.shared_ = new Shared(this, (msg) => dialogs.info(this, msg), (msg) => dialogs.error(this, msg)); } UNSAFE_componentWillMount() { @@ -68,7 +68,7 @@ class DropboxLoginScreenComponent extends BaseScreenComponent { { + ref={(dialogbox) => { this.dialogbox = dialogbox; }} /> @@ -77,7 +77,7 @@ class DropboxLoginScreenComponent extends BaseScreenComponent { } } -const DropboxLoginScreen = connect(state => { +const DropboxLoginScreen = connect((state) => { return { theme: state.settings.theme, }; diff --git a/ReactNativeClient/lib/components/screens/encryption-config.js b/ReactNativeClient/lib/components/screens/encryption-config.js index 3f15e2753..f0fa355f9 100644 --- a/ReactNativeClient/lib/components/screens/encryption-config.js +++ b/ReactNativeClient/lib/components/screens/encryption-config.js @@ -103,7 +103,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent { return shared.onSavePasswordClick(this, mk); }; - const onPasswordChange = text => { + const onPasswordChange = (text) => { return shared.onPasswordChange(this, mk, text); }; @@ -120,7 +120,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent { {_('Created: %s', time.formatMsToLocal(mk.created_time))} {_('Password:')} - onPasswordChange(text)} style={inputStyle}> + onPasswordChange(text)} style={inputStyle}> {passwordOk} @@ -155,7 +155,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent { style={this.styles().normalTextInput} secureTextEntry={true} value={this.state.passwordPromptAnswer} - onChangeText={text => { + onChangeText={(text) => { this.setState({ passwordPromptAnswer: text }); }} > @@ -167,7 +167,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent { style={this.styles().normalTextInput} secureTextEntry={true} value={this.state.passwordPromptConfirmAnswer} - onChangeText={text => { + onChangeText={(text) => { this.setState({ passwordPromptConfirmAnswer: text }); }} > @@ -286,7 +286,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent { { + ref={(dialogbox) => { this.dialogbox = dialogbox; }} /> @@ -295,7 +295,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent { } } -const EncryptionConfigScreen = connect(state => { +const EncryptionConfigScreen = connect((state) => { return { theme: state.settings.theme, masterKeys: state.masterKeys, diff --git a/ReactNativeClient/lib/components/screens/folder.js b/ReactNativeClient/lib/components/screens/folder.js index f76b06922..b4a183629 100644 --- a/ReactNativeClient/lib/components/screens/folder.js +++ b/ReactNativeClient/lib/components/screens/folder.js @@ -50,7 +50,7 @@ class FolderScreenComponent extends BaseScreenComponent { lastSavedFolder: Object.assign({}, folder), }); } else { - Folder.load(this.props.folderId).then(folder => { + Folder.load(this.props.folderId).then((folder) => { this.setState({ folder: folder, lastSavedFolder: Object.assign({}, folder), @@ -107,9 +107,9 @@ class FolderScreenComponent extends BaseScreenComponent { return ( this.saveFolderButton_press()} showSideMenuButton={false} showSearchButton={false} /> - this.title_changeText(text)} /> + this.title_changeText(text)} /> { + ref={(dialogbox) => { this.dialogbox = dialogbox; }} /> @@ -118,7 +118,7 @@ class FolderScreenComponent extends BaseScreenComponent { } } -const FolderScreen = connect(state => { +const FolderScreen = connect((state) => { return { folderId: state.selectedFolderId, theme: state.settings.theme, diff --git a/ReactNativeClient/lib/components/screens/log.js b/ReactNativeClient/lib/components/screens/log.js index 8a89212c2..21dccacfa 100644 --- a/ReactNativeClient/lib/components/screens/log.js +++ b/ReactNativeClient/lib/components/screens/log.js @@ -101,7 +101,7 @@ class LogScreenComponent extends BaseScreenComponent { { return `${item.id}`; }} + keyExtractor={(item) => { return `${item.id}`; }} /> @@ -126,7 +126,7 @@ class LogScreenComponent extends BaseScreenComponent { } } -const LogScreen = connect(state => { +const LogScreen = connect((state) => { return { theme: state.settings.theme, }; diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index 530fa1f6f..f6b2994a3 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -128,7 +128,7 @@ class NoteScreenComponent extends BaseScreenComponent { this.setState({ noteTagDialogShown: false }); }; - this.onJoplinLinkClick_ = async msg => { + this.onJoplinLinkClick_ = async (msg) => { try { if (msg.indexOf('joplin://') === 0) { const resourceUrlInfo = urlUtils.parseResourceUrl(msg); @@ -407,7 +407,7 @@ class NoteScreenComponent extends BaseScreenComponent { (width, height) => { resolve({ width: width, height: height }); }, - error => { + (error) => { reject(error); } ); @@ -416,7 +416,7 @@ class NoteScreenComponent extends BaseScreenComponent { showImagePicker(options) { return new Promise((resolve) => { - ImagePicker.launchImageLibrary(options, response => { + ImagePicker.launchImageLibrary(options, (response) => { resolve(response); }); }); @@ -871,7 +871,7 @@ class NoteScreenComponent extends BaseScreenComponent { let bodyComponent = null; if (this.state.mode == 'view' && !Setting.value('editor.beta')) { - const onCheckboxChange = newBody => { + const onCheckboxChange = (newBody) => { this.saveOneProperty('body', newBody); }; @@ -899,7 +899,7 @@ class NoteScreenComponent extends BaseScreenComponent { highlightedKeywords={keywords} theme={this.props.theme} noteHash={this.props.noteHash} - onCheckboxChange={newBody => { + onCheckboxChange={(newBody) => { onCheckboxChange(newBody); }} onMarkForDownload={this.onMarkForDownload} @@ -923,7 +923,7 @@ class NoteScreenComponent extends BaseScreenComponent { keywords = SearchEngine.instance().allParsedQueryTerms(parsedQuery); } - const onCheckboxChange = newBody => { + const onCheckboxChange = (newBody) => { this.saveOneProperty('body', newBody); }; @@ -938,7 +938,7 @@ class NoteScreenComponent extends BaseScreenComponent { value={note.body} borderColor={this.styles().markdownButtons.borderColor} markdownButtonsColor={this.styles().markdownButtons.color} - saveText={text => this.body_changeText(text)} + saveText={(text) => this.body_changeText(text)} blurOnSubmit={false} selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} @@ -957,7 +957,7 @@ class NoteScreenComponent extends BaseScreenComponent { highlightedKeywords: keywords, theme: this.props.theme, noteHash: this.props.noteHash, - onCheckboxChange: newBody => { + onCheckboxChange: (newBody) => { onCheckboxChange(newBody); }, onMarkForDownload: this.onMarkForDownload, @@ -979,7 +979,7 @@ class NoteScreenComponent extends BaseScreenComponent { // a plain TextInput for now. // See https://github.com/laurent22/joplin/issues/3041 ( - this.body_changeText(text)} blurOnSubmit={false} selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} placeholder={_('Add body')} placeholderTextColor={theme.colorFaded} /> + this.body_changeText(text)} blurOnSubmit={false} selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} placeholder={_('Add body')} placeholderTextColor={theme.colorFaded} /> ); } @@ -1031,7 +1031,7 @@ class NoteScreenComponent extends BaseScreenComponent { { + ref={(dialogbox) => { this.dialogbox = dialogbox; }} /> @@ -1041,7 +1041,7 @@ class NoteScreenComponent extends BaseScreenComponent { } } -const NoteScreen = connect(state => { +const NoteScreen = connect((state) => { return { noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null, noteHash: state.selectedNoteHash, diff --git a/ReactNativeClient/lib/components/screens/notes.js b/ReactNativeClient/lib/components/screens/notes.js index ef39b043e..de45775cf 100644 --- a/ReactNativeClient/lib/components/screens/notes.js +++ b/ReactNativeClient/lib/components/screens/notes.js @@ -151,7 +151,7 @@ class NotesScreenComponent extends BaseScreenComponent { } deleteFolder_onPress(folderId) { - dialogs.confirm(this, _('Delete notebook? All notes and sub-notebooks within this notebook will also be deleted.')).then(ok => { + dialogs.confirm(this, _('Delete notebook? All notes and sub-notebooks within this notebook will also be deleted.')).then((ok) => { if (!ok) return; Folder.delete(folderId) @@ -162,7 +162,7 @@ class NotesScreenComponent extends BaseScreenComponent { smartFilterId: 'c3176726992c11e9ac940492261af972', }); }) - .catch(error => { + .catch((error) => { alert(error.message); }); }); @@ -237,7 +237,7 @@ class NotesScreenComponent extends BaseScreenComponent { {actionButtonComp} { + ref={(dialogbox) => { this.dialogbox = dialogbox; }} /> @@ -246,7 +246,7 @@ class NotesScreenComponent extends BaseScreenComponent { } } -const NotesScreen = connect(state => { +const NotesScreen = connect((state) => { return { folders: state.folders, tags: state.tags, diff --git a/ReactNativeClient/lib/components/screens/onedrive-login.js b/ReactNativeClient/lib/components/screens/onedrive-login.js index 5fd81a077..58912785b 100644 --- a/ReactNativeClient/lib/components/screens/onedrive-login.js +++ b/ReactNativeClient/lib/components/screens/onedrive-login.js @@ -98,7 +98,7 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent { { + onNavigationStateChange={(o) => { this.webview_load(o); }} onError={() => { diff --git a/ReactNativeClient/lib/components/screens/search.js b/ReactNativeClient/lib/components/screens/search.js index 789df7f66..f69a1bb82 100644 --- a/ReactNativeClient/lib/components/screens/search.js +++ b/ReactNativeClient/lib/components/screens/search.js @@ -178,7 +178,7 @@ class SearchScreenComponent extends BaseScreenComponent { onSubmitEditing={() => { this.searchTextInput_submit(); }} - onChangeText={text => this.searchTextInput_changeText(text)} + onChangeText={(text) => this.searchTextInput_changeText(text)} value={this.state.query} selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} @@ -188,10 +188,10 @@ class SearchScreenComponent extends BaseScreenComponent { - item.id} renderItem={event => } /> + item.id} renderItem={(event) => } /> { + ref={(dialogbox) => { this.dialogbox = dialogbox; }} /> @@ -200,7 +200,7 @@ class SearchScreenComponent extends BaseScreenComponent { } } -const SearchScreen = connect(state => { +const SearchScreen = connect((state) => { return { query: state.searchQuery, theme: state.settings.theme, diff --git a/ReactNativeClient/lib/components/screens/status.js b/ReactNativeClient/lib/components/screens/status.js index de33cd2a9..ba8f70064 100644 --- a/ReactNativeClient/lib/components/screens/status.js +++ b/ReactNativeClient/lib/components/screens/status.js @@ -41,7 +41,7 @@ class StatusScreenComponent extends BaseScreenComponent { render() { const theme = themeStyle(this.props.theme); - const renderBody = report => { + const renderBody = (report) => { const baseStyle = { paddingLeft: 6, paddingRight: 6, @@ -144,7 +144,7 @@ class StatusScreenComponent extends BaseScreenComponent { } } -const StatusScreen = connect(state => { +const StatusScreen = connect((state) => { return { theme: state.settings.theme, }; diff --git a/ReactNativeClient/lib/components/screens/tags.js b/ReactNativeClient/lib/components/screens/tags.js index d66fc550f..781c4b862 100644 --- a/ReactNativeClient/lib/components/screens/tags.js +++ b/ReactNativeClient/lib/components/screens/tags.js @@ -105,7 +105,7 @@ class TagsScreenComponent extends BaseScreenComponent { } } -const TagsScreen = connect(state => { +const TagsScreen = connect((state) => { return { theme: state.settings.theme, }; diff --git a/ReactNativeClient/lib/components/shared/config-shared.js b/ReactNativeClient/lib/components/shared/config-shared.js index 614257c07..f1a406293 100644 --- a/ReactNativeClient/lib/components/shared/config-shared.js +++ b/ReactNativeClient/lib/components/shared/config-shared.js @@ -18,7 +18,7 @@ shared.init = function(comp) { }; shared.advancedSettingsButton_click = (comp) => { - comp.setState(state => { + comp.setState((state) => { return { showAdvancedSettings: !state.showAdvancedSettings }; }); }; @@ -79,7 +79,7 @@ shared.checkNextcloudApp = async function(comp, settings) { }; shared.updateSettingValue = function(comp, key, value) { - comp.setState(state => { + comp.setState((state) => { const settings = Object.assign({}, state.settings); const changedSettingKeys = state.changedSettingKeys.slice(); settings[key] = Setting.formatValue(key, value); diff --git a/ReactNativeClient/lib/components/shared/dropbox-login-shared.js b/ReactNativeClient/lib/components/shared/dropbox-login-shared.js index 177038395..8cf6024d4 100644 --- a/ReactNativeClient/lib/components/shared/dropbox-login-shared.js +++ b/ReactNativeClient/lib/components/shared/dropbox-login-shared.js @@ -21,7 +21,7 @@ class Shared { shim.openUrl(this.comp_.state.loginUrl); }; - this.authCodeInput_change = event => { + this.authCodeInput_change = (event) => { this.comp_.setState({ authCode: typeof event === 'object' ? event.target.value : event, }); diff --git a/ReactNativeClient/lib/components/shared/note-screen-shared.js b/ReactNativeClient/lib/components/shared/note-screen-shared.js index 31129cd84..9942a2c6f 100644 --- a/ReactNativeClient/lib/components/shared/note-screen-shared.js +++ b/ReactNativeClient/lib/components/shared/note-screen-shared.js @@ -102,7 +102,7 @@ shared.saveNoteButton_press = async function(comp, folderId = null, options = nu comp.setState(newState); if (isProvisionalNote) { - Note.updateGeolocation(note.id).then(geoNote => { + Note.updateGeolocation(note.id).then((geoNote) => { const stateNote = comp.state.note; if (!stateNote || !geoNote) return; if (stateNote.id !== geoNote.id) return; // Another note has been loaded while geoloc was being retrieved diff --git a/ReactNativeClient/lib/components/side-menu-content-note.js b/ReactNativeClient/lib/components/side-menu-content-note.js index 7555de3e4..63a61b1bb 100644 --- a/ReactNativeClient/lib/components/side-menu-content-note.js +++ b/ReactNativeClient/lib/components/side-menu-content-note.js @@ -106,7 +106,7 @@ class SideMenuContentNoteComponent extends Component { } } -const SideMenuContentNote = connect(state => { +const SideMenuContentNote = connect((state) => { return { theme: state.settings.theme, }; diff --git a/ReactNativeClient/lib/components/side-menu-content.js b/ReactNativeClient/lib/components/side-menu-content.js index 42c8b768d..4203577fe 100644 --- a/ReactNativeClient/lib/components/side-menu-content.js +++ b/ReactNativeClient/lib/components/side-menu-content.js @@ -388,7 +388,7 @@ class SideMenuContentComponent extends Component { } } -const SideMenuContent = connect(state => { +const SideMenuContent = connect((state) => { return { folders: state.folders, syncStarted: state.syncStarted, diff --git a/ReactNativeClient/lib/components/side-menu.js b/ReactNativeClient/lib/components/side-menu.js index b30ee1d52..39335f18b 100644 --- a/ReactNativeClient/lib/components/side-menu.js +++ b/ReactNativeClient/lib/components/side-menu.js @@ -3,7 +3,7 @@ const SideMenu_ = require('react-native-side-menu').default; class SideMenuComponent extends SideMenu_ {} -const MySideMenu = connect(state => { +const MySideMenu = connect((state) => { return { isOpen: state.showSideMenu, }; diff --git a/ReactNativeClient/lib/database-driver-node.js b/ReactNativeClient/lib/database-driver-node.js index e8015af88..ac6b14052 100644 --- a/ReactNativeClient/lib/database-driver-node.js +++ b/ReactNativeClient/lib/database-driver-node.js @@ -4,7 +4,7 @@ const Promise = require('promise'); class DatabaseDriverNode { open(options) { return new Promise((resolve, reject) => { - this.db_ = new sqlite3.Database(options.name, sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE, error => { + this.db_ = new sqlite3.Database(options.name, sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE, (error) => { if (error) { reject(error); return; @@ -52,7 +52,7 @@ class DatabaseDriverNode { exec(sql, params = null) { if (!params) params = {}; return new Promise((resolve, reject) => { - this.db_.run(sql, params, error => { + this.db_.run(sql, params, (error) => { if (error) { reject(error); return; diff --git a/ReactNativeClient/lib/database-driver-react-native.js b/ReactNativeClient/lib/database-driver-react-native.js index 8b9744a05..890e7f3d4 100644 --- a/ReactNativeClient/lib/database-driver-react-native.js +++ b/ReactNativeClient/lib/database-driver-react-native.js @@ -10,11 +10,11 @@ class DatabaseDriverReactNative { return new Promise((resolve, reject) => { SQLite.openDatabase( { name: options.name }, - db => { + (db) => { this.db_ = db; resolve(); }, - error => { + (error) => { reject(error); } ); @@ -30,10 +30,10 @@ class DatabaseDriverReactNative { this.db_.executeSql( sql, params, - r => { + (r) => { resolve(r.rows.length ? r.rows.item(0) : null); }, - error => { + (error) => { reject(error); } ); @@ -41,7 +41,7 @@ class DatabaseDriverReactNative { } selectAll(sql, params = null) { - return this.exec(sql, params).then(r => { + return this.exec(sql, params).then((r) => { const output = []; for (let i = 0; i < r.rows.length; i++) { output.push(r.rows.item(i)); @@ -55,11 +55,11 @@ class DatabaseDriverReactNative { this.db_.executeSql( sql, params, - r => { + (r) => { if ('insertId' in r) this.lastInsertId_ = r.insertId; resolve(r); }, - error => { + (error) => { reject(error); } ); diff --git a/ReactNativeClient/lib/file-api-driver-local.js b/ReactNativeClient/lib/file-api-driver-local.js index 8393f623a..09981ec60 100644 --- a/ReactNativeClient/lib/file-api-driver-local.js +++ b/ReactNativeClient/lib/file-api-driver-local.js @@ -64,7 +64,7 @@ class FileApiDriverLocal { } async delta(path, options) { - const getStatFn = async path => { + const getStatFn = async (path) => { const stats = await this.fsDriver().readDirStats(path); return this.metadataFromStats_(stats); }; diff --git a/ReactNativeClient/lib/file-api-driver-memory.js b/ReactNativeClient/lib/file-api-driver-memory.js index 762a81e0c..2dbed94c5 100644 --- a/ReactNativeClient/lib/file-api-driver-memory.js +++ b/ReactNativeClient/lib/file-api-driver-memory.js @@ -138,7 +138,7 @@ class FileApiDriverMemory { } async delta(path, options = null) { - const getStatFn = async path => { + const getStatFn = async (path) => { const output = this.items_.slice(); for (let i = 0; i < output.length; i++) { const item = Object.assign({}, output[i]); diff --git a/ReactNativeClient/lib/file-api-driver-webdav.js b/ReactNativeClient/lib/file-api-driver-webdav.js index f43ec498d..fd149b9ac 100644 --- a/ReactNativeClient/lib/file-api-driver-webdav.js +++ b/ReactNativeClient/lib/file-api-driver-webdav.js @@ -88,7 +88,7 @@ class FileApiDriverWebDav { } async delta(path, options) { - const getDirStats = async path => { + const getDirStats = async (path) => { const result = await this.list(path); return result.items; }; diff --git a/ReactNativeClient/lib/file-api.js b/ReactNativeClient/lib/file-api.js index 754960090..6131ebc2d 100644 --- a/ReactNativeClient/lib/file-api.js +++ b/ReactNativeClient/lib/file-api.js @@ -268,7 +268,7 @@ async function basicDelta(path, getDirStatFn, options) { newContext.statsCache.sort(function(a, b) { return a.updated_time - b.updated_time; }); - newContext.statIdsCache = newContext.statsCache.filter(item => BaseItem.isSystemPath(item.path)).map(item => BaseItem.pathToId(item.path)); + newContext.statIdsCache = newContext.statsCache.filter((item) => BaseItem.isSystemPath(item.path)).map((item) => BaseItem.pathToId(item.path)); newContext.statIdsCache.sort(); // Items must be sorted to use binary search below } diff --git a/ReactNativeClient/lib/geolocation-react.js b/ReactNativeClient/lib/geolocation-react.js index a75dcd7da..885141eec 100644 --- a/ReactNativeClient/lib/geolocation-react.js +++ b/ReactNativeClient/lib/geolocation-react.js @@ -25,10 +25,10 @@ class GeolocationReact { return new Promise((resolve, reject) => { navigator.geolocation.getCurrentPosition( - data => { + (data) => { resolve(data); }, - error => { + (error) => { reject(error); }, options diff --git a/ReactNativeClient/lib/htmlUtils.js b/ReactNativeClient/lib/htmlUtils.js index a7ff8037a..ed65455f0 100644 --- a/ReactNativeClient/lib/htmlUtils.js +++ b/ReactNativeClient/lib/htmlUtils.js @@ -24,11 +24,11 @@ class HtmlUtils { output.push(matches[2]); } - return output.filter(url => !!url); + return output.filter((url) => !!url); } replaceImageUrls(html, callback) { - return this.processImageTags(html, data => { + return this.processImageTags(html, (data) => { const newSrc = callback(data.src); return { type: 'replaceSource', diff --git a/ReactNativeClient/lib/import-enex-html-gen.js b/ReactNativeClient/lib/import-enex-html-gen.js index 93b675d9e..f12cb7d9c 100644 --- a/ReactNativeClient/lib/import-enex-html-gen.js +++ b/ReactNativeClient/lib/import-enex-html-gen.js @@ -47,7 +47,7 @@ function attributeToLowerCase(node) { function enexXmlToHtml_(stream, resources) { const remainingResources = resources.slice(); - const removeRemainingResource = id => { + const removeRemainingResource = (id) => { for (let i = 0; i < remainingResources.length; i++) { const r = remainingResources[i]; if (r.id === id) { diff --git a/ReactNativeClient/lib/import-enex-md-gen.js b/ReactNativeClient/lib/import-enex-md-gen.js index 8fb91f22c..27bd857dd 100644 --- a/ReactNativeClient/lib/import-enex-md-gen.js +++ b/ReactNativeClient/lib/import-enex-md-gen.js @@ -409,7 +409,7 @@ function isSpanStyleItalic(attributes) { function enexXmlToMdArray(stream, resources) { const remainingResources = resources.slice(); - const removeRemainingResource = id => { + const removeRemainingResource = (id) => { for (let i = 0; i < remainingResources.length; i++) { const r = remainingResources[i]; if (r.id === id) { @@ -442,7 +442,7 @@ function enexXmlToMdArray(stream, resources) { console.warn(e); }); - const unwrapInnerText = text => { + const unwrapInnerText = (text) => { const lines = text.split('\n'); let output = ''; diff --git a/ReactNativeClient/lib/import-enex.js b/ReactNativeClient/lib/import-enex.js index fbf04a893..a645810e0 100644 --- a/ReactNativeClient/lib/import-enex.js +++ b/ReactNativeClient/lib/import-enex.js @@ -260,7 +260,7 @@ function importEnex(parentFolderId, filePath, importOptions = null) { const notes = []; let processingNotes = false; - stream.on('error', error => { + stream.on('error', (error) => { reject(new Error(error.toString())); }); @@ -327,7 +327,7 @@ function importEnex(parentFolderId, filePath, importOptions = null) { return true; } - saxStream.on('error', error => { + saxStream.on('error', (error) => { importOptions.onError(error); }); @@ -421,7 +421,7 @@ function importEnex(parentFolderId, filePath, importOptions = null) { notes.push(note); if (notes.length >= 10) { - processNotes().catch(error => { + processNotes().catch((error) => { importOptions.onError(error); }); } @@ -463,7 +463,7 @@ function importEnex(parentFolderId, filePath, importOptions = null) { saxStream.on('end', function() { // Wait till there is no more notes to process. const iid = setInterval(() => { - processNotes().then(allDone => { + processNotes().then((allDone) => { if (allDone) { clearTimeout(iid); resolve(); diff --git a/ReactNativeClient/lib/joplin-database.js b/ReactNativeClient/lib/joplin-database.js index a681cb0f3..1e58a732f 100644 --- a/ReactNativeClient/lib/joplin-database.js +++ b/ReactNativeClient/lib/joplin-database.js @@ -257,7 +257,7 @@ class JoplinDatabase extends Database { queries.push(this.wrapQuery('DELETE FROM table_fields')); return this.selectAll('SELECT name FROM sqlite_master WHERE type="table"') - .then(tableRows => { + .then((tableRows) => { const chain = []; for (let i = 0; i < tableRows.length; i++) { const tableName = tableRows[i].name; @@ -266,7 +266,7 @@ class JoplinDatabase extends Database { if (tableName == 'sqlite_sequence') continue; if (tableName.indexOf('notes_fts') === 0) continue; chain.push(() => { - return this.selectAll(`PRAGMA table_info("${tableName}")`).then(pragmas => { + return this.selectAll(`PRAGMA table_info("${tableName}")`).then((pragmas) => { for (let i = 0; i < pragmas.length; i++) { const item = pragmas[i]; // In SQLite, if the default value is a string it has double quotes around it, so remove them here diff --git a/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js b/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js index 803b27b9f..251308094 100644 --- a/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js +++ b/ReactNativeClient/lib/joplin-renderer/HtmlToHtml.js @@ -55,7 +55,7 @@ class HtmlToHtml { if (!html) { html = htmlUtils.sanitizeHtml(markup); - html = htmlUtils.processImageTags(html, data => { + html = htmlUtils.processImageTags(html, (data) => { if (!data.src) return null; const r = utils.imageReplacement(this.ResourceModel_, data.src, options.resources, this.resourceBaseUrl_); diff --git a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.js b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.js index d67bbd700..df0d69520 100644 --- a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.js +++ b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.js @@ -33,7 +33,7 @@ function createHighlightedTokens(Token, splitted) { function installRule(markdownIt, mdOptions, ruleOptions) { const divider = md5(Date.now().toString() + Math.random().toString()); - markdownIt.core.ruler.push('highlight_keywords', state => { + markdownIt.core.ruler.push('highlight_keywords', (state) => { const keywords = ruleOptions.highlightedKeywords; if (!keywords || !keywords.length) return; diff --git a/ReactNativeClient/lib/joplin-renderer/stringUtils.js b/ReactNativeClient/lib/joplin-renderer/stringUtils.js index 941f721b6..60985a0d8 100644 --- a/ReactNativeClient/lib/joplin-renderer/stringUtils.js +++ b/ReactNativeClient/lib/joplin-renderer/stringUtils.js @@ -57,7 +57,7 @@ function surroundKeywords(keywords, text, prefix, suffix) { if (!keywords.length) return text; let regexString = keywords - .map(k => { + .map((k) => { if (k.type === 'regex') { return replaceRegexDiacritics(k.valueRegex); } else { diff --git a/ReactNativeClient/lib/markdownUtils.js b/ReactNativeClient/lib/markdownUtils.js index 0893754a3..90476cde4 100644 --- a/ReactNativeClient/lib/markdownUtils.js +++ b/ReactNativeClient/lib/markdownUtils.js @@ -36,7 +36,7 @@ const markdownUtils = { const tokens = markdownIt.parse(md, env); const output = []; - const searchUrls = tokens => { + const searchUrls = (tokens) => { for (let i = 0; i < tokens.length; i++) { const token = tokens[i]; diff --git a/ReactNativeClient/lib/models/Alarm.js b/ReactNativeClient/lib/models/Alarm.js index d5994ee3f..08776a4cd 100644 --- a/ReactNativeClient/lib/models/Alarm.js +++ b/ReactNativeClient/lib/models/Alarm.js @@ -21,7 +21,7 @@ class Alarm extends BaseModel { static async alarmIdsWithoutNotes() { // https://stackoverflow.com/a/4967229/561309 const alarms = await this.db().selectAll('SELECT alarms.id FROM alarms LEFT JOIN notes ON alarms.note_id = notes.id WHERE notes.id IS NULL'); - return alarms.map(a => { + return alarms.map((a) => { return a.id; }); } diff --git a/ReactNativeClient/lib/models/BaseItem.js b/ReactNativeClient/lib/models/BaseItem.js index 60f05ac93..bab8fb075 100644 --- a/ReactNativeClient/lib/models/BaseItem.js +++ b/ReactNativeClient/lib/models/BaseItem.js @@ -186,7 +186,7 @@ class BaseItem extends BaseModel { let conflictNoteIds = []; if (this.modelType() == BaseModel.TYPE_NOTE) { const conflictNotes = await this.db().selectAll(`SELECT id FROM notes WHERE id IN ("${ids.join('","')}") AND is_conflict = 1`); - conflictNoteIds = conflictNotes.map(n => { + conflictNoteIds = conflictNotes.map((n) => { return n.id; }); } @@ -609,7 +609,7 @@ class BaseItem extends BaseModel { } static syncItemClassNames() { - return BaseItem.syncItemDefinitions_.map(def => { + return BaseItem.syncItemDefinitions_.map((def) => { return def.className; }); } @@ -625,7 +625,7 @@ class BaseItem extends BaseModel { } static syncItemTypes() { - return BaseItem.syncItemDefinitions_.map(def => { + return BaseItem.syncItemDefinitions_.map((def) => { return def.type; }); } @@ -726,7 +726,7 @@ class BaseItem extends BaseModel { ); const items = await ItemClass.modelSelectAll(sql); - const ids = items.map(item => { + const ids = items.map((item) => { return item.id; }); if (!ids.length) continue; diff --git a/ReactNativeClient/lib/models/Folder.js b/ReactNativeClient/lib/models/Folder.js index 25a79aee8..9bfefc8bd 100644 --- a/ReactNativeClient/lib/models/Folder.js +++ b/ReactNativeClient/lib/models/Folder.js @@ -34,7 +34,7 @@ class Folder extends BaseItem { static noteIds(parentId) { return this.db() .selectAll('SELECT id FROM notes WHERE is_conflict = 0 AND parent_id = ?', [parentId]) - .then(rows => { + .then((rows) => { const output = []; for (let i = 0; i < rows.length; i++) { const row = rows[i]; @@ -46,7 +46,7 @@ class Folder extends BaseItem { static async subFolderIds(parentId) { const rows = await this.db().selectAll('SELECT id FROM folders WHERE parent_id = ?', [parentId]); - return rows.map(r => r.id); + return rows.map((r) => r.id); } static async noteCount(parentId) { @@ -143,7 +143,7 @@ class Folder extends BaseItem { folderIdToTime[row.parent_id] = row.content_updated_time; } - const findFolderParent = folderId => { + const findFolderParent = (folderId) => { const folder = BaseModel.byId(folders, folderId); if (!folder) return null; // For the rare case of notes that are associated with a no longer existing folder if (!folder.parent_id) return null; @@ -157,7 +157,7 @@ class Folder extends BaseItem { return null; }; - const applyChildTimeToParent = folderId => { + const applyChildTimeToParent = (folderId) => { const parent = findFolderParent(folderId); if (!parent) return; @@ -429,7 +429,7 @@ class Folder extends BaseItem { if (o.title == Folder.conflictFolderTitle()) throw new Error(_('Notebooks cannot be named "%s", which is a reserved title.', o.title)); } - return super.save(o, options).then(folder => { + return super.save(o, options).then((folder) => { this.dispatch({ type: 'FOLDER_UPDATE_ONE', item: folder, diff --git a/ReactNativeClient/lib/models/MasterKey.js b/ReactNativeClient/lib/models/MasterKey.js index ace960e20..22c243418 100644 --- a/ReactNativeClient/lib/models/MasterKey.js +++ b/ReactNativeClient/lib/models/MasterKey.js @@ -19,11 +19,11 @@ class MasterKey extends BaseItem { } static allWithoutEncryptionMethod(masterKeys, method) { - return masterKeys.filter(m => m.encryption_method !== method); + return masterKeys.filter((m) => m.encryption_method !== method); } static async save(o, options = null) { - return super.save(o, options).then(item => { + return super.save(o, options).then((item) => { this.dispatch({ type: 'MASTERKEY_UPDATE_ONE', item: item, diff --git a/ReactNativeClient/lib/models/Note.js b/ReactNativeClient/lib/models/Note.js index 091bbf83b..b249aaa05 100644 --- a/ReactNativeClient/lib/models/Note.js +++ b/ReactNativeClient/lib/models/Note.js @@ -104,7 +104,7 @@ class Note extends BaseItem { if (!body || body.length <= 32) return []; const links = urlUtils.extractResourceUrls(body); - const itemIds = links.map(l => l.itemId); + const itemIds = links.map((l) => l.itemId); return ArrayUtils.unique(itemIds); } @@ -175,7 +175,7 @@ class Note extends BaseItem { for (const basePath of pathsToTry) { const reString = `${pregQuote(`${basePath}/`)}[a-zA-Z0-9.]+`; const re = new RegExp(reString, 'gi'); - body = body.replace(re, match => { + body = body.replace(re, (match) => { const id = Resource.pathToId(match); return `:/${id}`; }); @@ -200,7 +200,7 @@ class Note extends BaseItem { // Note: sort logic must be duplicated in previews(); static sortNotes(notes, orders, uncompletedTodosOnTop) { - const noteOnTop = note => { + const noteOnTop = (note) => { return uncompletedTodosOnTop && note.is_todo && !note.todo_completed; }; diff --git a/ReactNativeClient/lib/models/NoteResource.js b/ReactNativeClient/lib/models/NoteResource.js index 57e6e96eb..a83596756 100644 --- a/ReactNativeClient/lib/models/NoteResource.js +++ b/ReactNativeClient/lib/models/NoteResource.js @@ -66,7 +66,7 @@ class NoteResource extends BaseModel { `, [cutOffTime] ); - return output.map(r => r.resource_id); + return output.map((r) => r.resource_id); } static async deleteByResource(resourceId) { diff --git a/ReactNativeClient/lib/models/Revision.js b/ReactNativeClient/lib/models/Revision.js index a74b7980d..84098275d 100644 --- a/ReactNativeClient/lib/models/Revision.js +++ b/ReactNativeClient/lib/models/Revision.js @@ -67,7 +67,7 @@ class Revision extends BaseItem { static patchStats(patch) { if (typeof patch === 'object') throw new Error('Not implemented'); - const countChars = diffLine => { + const countChars = (diffLine) => { return unescape(diffLine).length - 1; }; @@ -125,7 +125,7 @@ class Revision extends BaseItem { if (!itemIds.length) return []; const rows = await this.db().selectAll(`SELECT distinct item_id FROM revisions WHERE item_type = ? AND item_id IN ("${itemIds.join('","')}")`, [itemType]); - return rows.map(r => r.item_id); + return rows.map((r) => r.item_id); } static async itemsWithNoRevisions(itemType, itemIds) { diff --git a/ReactNativeClient/lib/models/Search.js b/ReactNativeClient/lib/models/Search.js index f4bed53a0..f5c1037d9 100644 --- a/ReactNativeClient/lib/models/Search.js +++ b/ReactNativeClient/lib/models/Search.js @@ -12,7 +12,7 @@ class Search extends BaseModel { static keywords(query) { let output = query.trim(); output = output.split(/[\s\t\n]+/); - output = output.filter(o => !!o); + output = output.filter((o) => !!o); return output; } } diff --git a/ReactNativeClient/lib/models/Setting.js b/ReactNativeClient/lib/models/Setting.js index 749cc8b40..0712925fd 100644 --- a/ReactNativeClient/lib/models/Setting.js +++ b/ReactNativeClient/lib/models/Setting.js @@ -56,7 +56,7 @@ class Setting extends BaseModel { public: true, section: 'sync', label: () => _('Synchronisation target'), - description: appType => { + description: (appType) => { return appType !== 'cli' ? null : _('The target to synchonise to. Each sync target may have additional parameters which are named as `sync.NUM.NAME` (all documented below).'); }, options: () => { @@ -68,14 +68,14 @@ class Setting extends BaseModel { value: '', type: Setting.TYPE_STRING, section: 'sync', - show: settings => { + show: (settings) => { try { return settings['sync.target'] == SyncTargetRegistry.nameToId('filesystem'); } catch (error) { return false; } }, - filter: value => { + filter: (value) => { return value ? rtrimSlashes(value) : ''; }, public: true, @@ -87,7 +87,7 @@ class Setting extends BaseModel { value: '', type: Setting.TYPE_STRING, section: 'sync', - show: settings => { + show: (settings) => { return settings['sync.target'] == SyncTargetRegistry.nameToId('nextcloud'); }, public: true, @@ -98,7 +98,7 @@ class Setting extends BaseModel { value: '', type: Setting.TYPE_STRING, section: 'sync', - show: settings => { + show: (settings) => { return settings['sync.target'] == SyncTargetRegistry.nameToId('nextcloud'); }, public: true, @@ -108,7 +108,7 @@ class Setting extends BaseModel { value: '', type: Setting.TYPE_STRING, section: 'sync', - show: settings => { + show: (settings) => { return settings['sync.target'] == SyncTargetRegistry.nameToId('nextcloud'); }, public: true, @@ -120,7 +120,7 @@ class Setting extends BaseModel { value: '', type: Setting.TYPE_STRING, section: 'sync', - show: settings => { + show: (settings) => { return settings['sync.target'] == SyncTargetRegistry.nameToId('webdav'); }, public: true, @@ -131,7 +131,7 @@ class Setting extends BaseModel { value: '', type: Setting.TYPE_STRING, section: 'sync', - show: settings => { + show: (settings) => { return settings['sync.target'] == SyncTargetRegistry.nameToId('webdav'); }, public: true, @@ -141,7 +141,7 @@ class Setting extends BaseModel { value: '', type: Setting.TYPE_STRING, section: 'sync', - show: settings => { + show: (settings) => { return settings['sync.target'] == SyncTargetRegistry.nameToId('webdav'); }, public: true, @@ -557,7 +557,7 @@ class Setting extends BaseModel { type: Setting.TYPE_STRING, section: 'sync', advanced: true, - show: settings => { + show: (settings) => { return [SyncTargetRegistry.nameToId('nextcloud'), SyncTargetRegistry.nameToId('webdav')].indexOf(settings['sync.target']) >= 0; }, public: true, @@ -570,7 +570,7 @@ class Setting extends BaseModel { type: Setting.TYPE_BOOL, advanced: true, section: 'sync', - show: settings => { + show: (settings) => { return [SyncTargetRegistry.nameToId('nextcloud'), SyncTargetRegistry.nameToId('webdav')].indexOf(settings['sync.target']) >= 0; }, public: true, @@ -723,7 +723,7 @@ class Setting extends BaseModel { static load() { this.cancelScheduleSave(); this.cache_ = []; - return this.modelSelectAll('SELECT * FROM settings').then(rows => { + return this.modelSelectAll('SELECT * FROM settings').then((rows) => { this.cache_ = []; for (let i = 0; i < rows.length; i++) { diff --git a/ReactNativeClient/lib/models/Tag.js b/ReactNativeClient/lib/models/Tag.js index 2bb506fa3..391ed91c7 100644 --- a/ReactNativeClient/lib/models/Tag.js +++ b/ReactNativeClient/lib/models/Tag.js @@ -119,7 +119,7 @@ class Tag extends BaseItem { let commonTagIds = await NoteTag.tagIdsByNoteId(noteIds[0]); for (let i = 1; i < noteIds.length; i++) { const tagIds = await NoteTag.tagIdsByNoteId(noteIds[i]); - commonTagIds = commonTagIds.filter(value => tagIds.includes(value)); + commonTagIds = commonTagIds.filter((value) => tagIds.includes(value)); if (commonTagIds.length === 0) { break; } @@ -184,7 +184,7 @@ class Tag extends BaseItem { } } - return super.save(o, options).then(tag => { + return super.save(o, options).then((tag) => { this.dispatch({ type: 'TAG_UPDATE_ONE', item: tag, diff --git a/ReactNativeClient/lib/net-utils.js b/ReactNativeClient/lib/net-utils.js index 1226eb4a7..faa89e28b 100644 --- a/ReactNativeClient/lib/net-utils.js +++ b/ReactNativeClient/lib/net-utils.js @@ -30,7 +30,7 @@ netUtils.findAvailablePort = async (possiblePorts, extraRandomPortsToTry = 20) = return port; }; -netUtils.mimeTypeFromHeaders = headers => { +netUtils.mimeTypeFromHeaders = (headers) => { if (!headers || !headers['content-type']) return null; const splitted = headers['content-type'].split(';'); diff --git a/ReactNativeClient/lib/onedrive-api-node-utils.js b/ReactNativeClient/lib/onedrive-api-node-utils.js index e21b79864..736980d2c 100644 --- a/ReactNativeClient/lib/onedrive-api-node-utils.js +++ b/ReactNativeClient/lib/onedrive-api-node-utils.js @@ -87,7 +87,7 @@ class OneDriveApiNodeUtils { targetConsole.log(_('The application has been successfully authorised.')); waitAndDestroy(); }) - .catch(error => { + .catch((error) => { writeResponse(400, error.message); targetConsole.log(''); targetConsole.log(error.message); diff --git a/ReactNativeClient/lib/reducer.js b/ReactNativeClient/lib/reducer.js index 89169ad7a..aedc4f376 100644 --- a/ReactNativeClient/lib/reducer.js +++ b/ReactNativeClient/lib/reducer.js @@ -122,7 +122,7 @@ stateUtils.getCurrentNote = function(state) { const selectedNoteIds = state.selectedNoteIds; const notes = state.notes; if (selectedNoteIds != null && selectedNoteIds.length > 0) { - const currNote = notes.find(note => note.id === selectedNoteIds[0]); + const currNote = notes.find((note) => note.id === selectedNoteIds[0]); if (currNote != null) { return { id: currNote.id, @@ -451,14 +451,14 @@ function handleHistory(state, action) { case 'NOTE_UPDATE_ONE': { const modNote = action.note; - backwardHistoryNotes = backwardHistoryNotes.map(note => { + backwardHistoryNotes = backwardHistoryNotes.map((note) => { if (note.id === modNote.id) { return Object.assign(note, { parent_id: modNote.parent_id, selectedFolderId: modNote.parent_id }); } return note; }); - forwardHistoryNotes = forwardHistoryNotes.map(note => { + forwardHistoryNotes = forwardHistoryNotes.map((note) => { if (note.id === modNote.id) { return Object.assign(note, { parent_id: modNote.parent_id, selectedFolderId: modNote.parent_id }); } @@ -475,15 +475,15 @@ function handleHistory(state, action) { } break; case 'FOLDER_DELETE': - backwardHistoryNotes = backwardHistoryNotes.filter(note => note.parent_id != action.id); - forwardHistoryNotes = forwardHistoryNotes.filter(note => note.parent_id != action.id); + backwardHistoryNotes = backwardHistoryNotes.filter((note) => note.parent_id != action.id); + forwardHistoryNotes = forwardHistoryNotes.filter((note) => note.parent_id != action.id); backwardHistoryNotes = removeAdjacentDuplicates(backwardHistoryNotes); forwardHistoryNotes = removeAdjacentDuplicates(forwardHistoryNotes); break; case 'NOTE_DELETE': { - backwardHistoryNotes = backwardHistoryNotes.filter(note => note.id != action.id); - forwardHistoryNotes = forwardHistoryNotes.filter(note => note.id != action.id); + backwardHistoryNotes = backwardHistoryNotes.filter((note) => note.id != action.id); + forwardHistoryNotes = forwardHistoryNotes.filter((note) => note.id != action.id); backwardHistoryNotes = removeAdjacentDuplicates(backwardHistoryNotes); forwardHistoryNotes = removeAdjacentDuplicates(forwardHistoryNotes); @@ -563,16 +563,16 @@ const reducer = (state = defaultState, action) => { case 'NOTE_SELECT_ALL': newState = Object.assign({}, state); - newState.selectedNoteIds = newState.notes.map(n => n.id); + newState.selectedNoteIds = newState.notes.map((n) => n.id); break; case 'NOTE_SELECT_ALL_TOGGLE': { newState = Object.assign({}, state); - const allSelected = state.notes.every(n => state.selectedNoteIds.includes(n.id)); + const allSelected = state.notes.every((n) => state.selectedNoteIds.includes(n.id)); if (allSelected) { newState.selectedNoteIds = []; } else { - newState.selectedNoteIds = newState.notes.map(n => n.id); + newState.selectedNoteIds = newState.notes.map((n) => n.id); } break; } @@ -761,7 +761,7 @@ const reducer = (state = defaultState, action) => { case 'TAG_UPDATE_ONE': { // We only want to update the selected note tags if the tag belongs to the currently open note - const selectedNoteHasTag = !!state.selectedNoteTags.find(tag => tag.id === action.item.id); + const selectedNoteHasTag = !!state.selectedNoteTags.find((tag) => tag.id === action.item.id); newState = updateOneItem(state, action); if (selectedNoteHasTag) newState = updateOneItem(newState, action, 'selectedNoteTags'); } diff --git a/ReactNativeClient/lib/registry.js b/ReactNativeClient/lib/registry.js index b2765368f..1b70f6305 100644 --- a/ReactNativeClient/lib/registry.js +++ b/ReactNativeClient/lib/registry.js @@ -17,15 +17,15 @@ reg.logger = () => { return reg.logger_; }; -reg.setLogger = l => { +reg.setLogger = (l) => { reg.logger_ = l; }; -reg.setShowErrorMessageBoxHandler = v => { +reg.setShowErrorMessageBoxHandler = (v) => { reg.showErrorMessageBoxHandler_ = v; }; -reg.showErrorMessageBox = message => { +reg.showErrorMessageBox = (message) => { if (!reg.showErrorMessageBoxHandler_) return; reg.showErrorMessageBoxHandler_(message); }; @@ -124,7 +124,7 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => { reg.logger().info('Starting scheduled sync'); const options = Object.assign({}, syncOptions, { context: context }); if (!options.saveContextHandler) { - options.saveContextHandler = newContext => { + options.saveContextHandler = (newContext) => { Setting.setValue(contextKey, JSON.stringify(newContext)); }; } @@ -205,7 +205,7 @@ reg.setupRecurrentSync = () => { } }; -reg.setDb = v => { +reg.setDb = (v) => { reg.db_ = v; }; diff --git a/ReactNativeClient/lib/services/AlarmServiceDriver.ios.js b/ReactNativeClient/lib/services/AlarmServiceDriver.ios.js index 3872891fb..2e696e589 100644 --- a/ReactNativeClient/lib/services/AlarmServiceDriver.ios.js +++ b/ReactNativeClient/lib/services/AlarmServiceDriver.ios.js @@ -5,7 +5,7 @@ class AlarmServiceDriver { this.hasPermission_ = null; this.inAppNotificationHandler_ = null; - PushNotificationIOS.addEventListener('localNotification', instance => { + PushNotificationIOS.addEventListener('localNotification', (instance) => { if (!this.inAppNotificationHandler_) return; if (!instance || !instance._data || !instance._data.id) { @@ -36,7 +36,7 @@ class AlarmServiceDriver { if (this.hasPermission_ !== null) return this.hasPermission_; return new Promise((resolve) => { - PushNotificationIOS.checkPermissions(async perm => { + PushNotificationIOS.checkPermissions(async (perm) => { const ok = await this.hasPermissions(perm); this.hasPermission_ = ok; resolve(ok); diff --git a/ReactNativeClient/lib/services/DecryptionWorker.js b/ReactNativeClient/lib/services/DecryptionWorker.js index a47c2e55e..2ddb88567 100644 --- a/ReactNativeClient/lib/services/DecryptionWorker.js +++ b/ReactNativeClient/lib/services/DecryptionWorker.js @@ -74,8 +74,8 @@ class DecryptionWorker { async decryptionDisabledItems() { let items = await this.kvStore().searchByPrefix('decrypt:'); - items = items.filter(item => item.value > this.maxDecryptionAttempts_); - items = items.map(item => { + items = items.filter((item) => item.value > this.maxDecryptionAttempts_); + items = items.map((item) => { const s = item.key.split(':'); return { type_: Number(s[1]), diff --git a/ReactNativeClient/lib/services/EncryptionService.js b/ReactNativeClient/lib/services/EncryptionService.js index 578b7d013..40bace062 100644 --- a/ReactNativeClient/lib/services/EncryptionService.js +++ b/ReactNativeClient/lib/services/EncryptionService.js @@ -216,7 +216,7 @@ class EncryptionService { async randomHexString(byteCount) { const bytes = await shim.randomBytes(byteCount); return bytes - .map(a => { + .map((a) => { return hexPad(a.toString(16), 2); }) .join(''); @@ -251,7 +251,7 @@ class EncryptionService { }, options); const bytes = await shim.randomBytes(256); - const hexaBytes = bytes.map(a => hexPad(a.toString(16), 2)).join(''); + const hexaBytes = bytes.map((a) => hexPad(a.toString(16), 2)).join(''); return this.encryptMasterKeyContent_(options.encryptionMethod, hexaBytes, password); } @@ -505,7 +505,7 @@ class EncryptionService { const handle = await this.fsDriver().open(path, 'r'); const reader = { handle: handle, - read: async size => { + read: async (size) => { return this.fsDriver().readFileChunk(reader.handle, size, encoding); }, close: async () => { @@ -517,7 +517,7 @@ class EncryptionService { async fileWriter_(path, encoding) { return { - append: async data => { + append: async (data) => { return this.fsDriver().appendFile(path, data, encoding); }, close: function() {}, diff --git a/ReactNativeClient/lib/services/ExternalEditWatcher.js b/ReactNativeClient/lib/services/ExternalEditWatcher.js index 8e77fca7a..ca62b7b57 100644 --- a/ReactNativeClient/lib/services/ExternalEditWatcher.js +++ b/ReactNativeClient/lib/services/ExternalEditWatcher.js @@ -214,7 +214,7 @@ class ExternalEditWatcher { path = 'open'; } - const wrapError = error => { + const wrapError = (error) => { if (!error) return error; const msg = error.message ? [error.message] : []; msg.push(`Command was: "${path}" ${args.join(' ')}`); @@ -233,7 +233,7 @@ class ExternalEditWatcher { } }, 100); - subProcess.on('error', error => { + subProcess.on('error', (error) => { clearInterval(iid); reject(wrapError(error)); }); diff --git a/ReactNativeClient/lib/services/InteropService.js b/ReactNativeClient/lib/services/InteropService.js index 86b23c515..0b3cb375f 100644 --- a/ReactNativeClient/lib/services/InteropService.js +++ b/ReactNativeClient/lib/services/InteropService.js @@ -95,7 +95,7 @@ class InteropService { }, ]; - importModules = importModules.map(a => { + importModules = importModules.map((a) => { const className = a.importerClass || `InteropService_Importer_${toTitleCase(a.format)}`; const output = Object.assign( {}, @@ -109,7 +109,7 @@ class InteropService { return output; }); - exportModules = exportModules.map(a => { + exportModules = exportModules.map((a) => { const className = `InteropService_Exporter_${toTitleCase(a.format)}`; return Object.assign( {}, @@ -123,7 +123,7 @@ class InteropService { this.modules_ = importModules.concat(exportModules); - this.modules_ = this.modules_.map(a => { + this.modules_ = this.modules_.map((a) => { a.fullLabel = function(moduleSource = null) { const label = [`${this.format.toUpperCase()} - ${this.description}`]; if (moduleSource && this.sources.length > 1) { @@ -156,7 +156,7 @@ class InteropService { } } - const output = matches.find(m => !!m.isDefault); + const output = matches.find((m) => !!m.isDefault); if (output) return output; return matches.length ? matches[0] : null; diff --git a/ReactNativeClient/lib/services/InteropService_Exporter_Jex.js b/ReactNativeClient/lib/services/InteropService_Exporter_Jex.js index 4bf7995f5..37a61ab28 100644 --- a/ReactNativeClient/lib/services/InteropService_Exporter_Jex.js +++ b/ReactNativeClient/lib/services/InteropService_Exporter_Jex.js @@ -24,7 +24,7 @@ class InteropService_Exporter_Jex extends InteropService_Exporter_Base { async close() { const stats = await shim.fsDriver().readDirStats(this.tempDir_, { recursive: true }); - const filePaths = stats.filter(a => !a.isDirectory()).map(a => a.path); + const filePaths = stats.filter((a) => !a.isDirectory()).map((a) => a.path); if (!filePaths.length) throw new Error(_('There is no data to export.')); diff --git a/ReactNativeClient/lib/services/InteropService_Importer_Raw.js b/ReactNativeClient/lib/services/InteropService_Importer_Raw.js index ceffdbaba..9a74a5605 100644 --- a/ReactNativeClient/lib/services/InteropService_Importer_Raw.js +++ b/ReactNativeClient/lib/services/InteropService_Importer_Raw.js @@ -18,7 +18,7 @@ class InteropService_Importer_Raw extends InteropService_Importer_Base { const noteTagsToCreate = []; const destinationFolderId = this.options_.destinationFolderId; - const replaceLinkedItemIds = async noteBody => { + const replaceLinkedItemIds = async (noteBody) => { let output = noteBody; const itemIds = Note.linkedItemIds(noteBody); @@ -52,7 +52,7 @@ class InteropService_Importer_Raw extends InteropService_Importer_Base { return defaultFolder_; }; - const setFolderToImportTo = async itemParentId => { + const setFolderToImportTo = async (itemParentId) => { // Logic is a bit complex here: // - If a destination folder was specified, move the note to it. // - Otherwise, if the associated folder exists, use this. diff --git a/ReactNativeClient/lib/services/PluginManager.js b/ReactNativeClient/lib/services/PluginManager.js index f9bde697a..016c34d8b 100644 --- a/ReactNativeClient/lib/services/PluginManager.js +++ b/ReactNativeClient/lib/services/PluginManager.js @@ -39,7 +39,7 @@ class PluginManager { const p = this.plugins_[name]; if (p.instance) return p.instance; p.instance = new p.Class(); - p.instance.dispatch = action => this.dispatch_(action); + p.instance.dispatch = (action) => this.dispatch_(action); return p.instance; } @@ -73,7 +73,7 @@ class PluginManager { dialogProps_(name) { return { - dispatch: action => this.dispatch_(action), + dispatch: (action) => this.dispatch_(action), plugin: this.pluginInstance_(name), }; } diff --git a/ReactNativeClient/lib/services/ResourceFetcher.js b/ReactNativeClient/lib/services/ResourceFetcher.js index 2c8aa01bb..1965a1b19 100644 --- a/ReactNativeClient/lib/services/ResourceFetcher.js +++ b/ReactNativeClient/lib/services/ResourceFetcher.js @@ -176,7 +176,7 @@ class ResourceFetcher extends BaseService { this.logger().debug(`ResourceFetcher: Resource downloaded: ${resource.id}`); await completeDownload(true, localResourceContentPath); }) - .catch(async error => { + .catch(async (error) => { this.logger().error(`ResourceFetcher: Could not download resource: ${resource.id}`, error); await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_ERROR, fetch_error: error.message }); await completeDownload(); diff --git a/ReactNativeClient/lib/services/ResourceService.js b/ReactNativeClient/lib/services/ResourceService.js index 302b36fc8..0bdcd6be0 100644 --- a/ReactNativeClient/lib/services/ResourceService.js +++ b/ReactNativeClient/lib/services/ResourceService.js @@ -46,10 +46,10 @@ class ResourceService extends BaseService { if (!changes.length) break; - const noteIds = changes.map(a => a.item_id); + const noteIds = changes.map((a) => a.item_id); const notes = await Note.modelSelectAll(`SELECT id, title, body, encryption_applied FROM notes WHERE id IN ("${noteIds.join('","')}")`); - const noteById = noteId => { + const noteById = (noteId) => { for (let i = 0; i < notes.length; i++) { if (notes[i].id === noteId) return notes[i]; } diff --git a/ReactNativeClient/lib/services/RevisionService.js b/ReactNativeClient/lib/services/RevisionService.js index 87c8c1f57..270899066 100644 --- a/ReactNativeClient/lib/services/RevisionService.js +++ b/ReactNativeClient/lib/services/RevisionService.js @@ -130,7 +130,7 @@ class RevisionService extends BaseService { if (!changes.length) break; - const noteIds = changes.map(a => a.item_id); + const noteIds = changes.map((a) => a.item_id); const notes = await Note.modelSelectAll(`SELECT * FROM notes WHERE is_conflict = 0 AND encryption_applied = 0 AND id IN ("${noteIds.join('","')}")`); for (let i = 0; i < changes.length; i++) { diff --git a/ReactNativeClient/lib/services/SearchEngine.js b/ReactNativeClient/lib/services/SearchEngine.js index 9015bb2e3..935e2f358 100644 --- a/ReactNativeClient/lib/services/SearchEngine.js +++ b/ReactNativeClient/lib/services/SearchEngine.js @@ -53,7 +53,7 @@ class SearchEngine { async rebuildIndex_() { let noteIds = await this.db().selectAll('SELECT id FROM notes WHERE is_conflict = 0 AND encryption_applied = 0'); - noteIds = noteIds.map(n => n.id); + noteIds = noteIds.map((n) => n.id); const lastChangeId = await ItemChange.lastChangeId(); @@ -137,7 +137,7 @@ class SearchEngine { if (!changes.length) break; - const noteIds = changes.map(a => a.item_id); + const noteIds = changes.map((a) => a.item_id); const notes = await Note.modelSelectAll(`SELECT id, title, body FROM notes WHERE id IN ("${noteIds.join('","')}") AND is_conflict = 0 AND encryption_applied = 0`); const queries = []; @@ -238,7 +238,7 @@ class SearchEngine { processResults_(rows, parsedQuery) { for (let i = 0; i < rows.length; i++) { const row = rows[i]; - const offsets = row.offsets.split(' ').map(o => Number(o)); + const offsets = row.offsets.split(' ').map((o) => Number(o)); row.weight = this.calculateWeight_(offsets, parsedQuery.termCount); row.fields = this.fieldNamesFromOffsets_(offsets); } diff --git a/ReactNativeClient/lib/services/SearchEngineUtils.js b/ReactNativeClient/lib/services/SearchEngineUtils.js index 98cd2efaf..24635b899 100644 --- a/ReactNativeClient/lib/services/SearchEngineUtils.js +++ b/ReactNativeClient/lib/services/SearchEngineUtils.js @@ -12,7 +12,7 @@ class SearchEngineUtils { } const results = await SearchEngine.instance().search(query, { searchType }); - const noteIds = results.map(n => n.id); + const noteIds = results.map((n) => n.id); // We need at least the note ID to be able to sort them below so if not // present in field list, add it.L Also remember it was auto-added so that diff --git a/ReactNativeClient/lib/services/rest/Api.js b/ReactNativeClient/lib/services/rest/Api.js index 806fb3e95..ed66f63e2 100644 --- a/ReactNativeClient/lib/services/rest/Api.js +++ b/ReactNativeClient/lib/services/rest/Api.js @@ -163,8 +163,8 @@ class Api { if (!query || !query.fields) return defaultFields; const fields = query.fields .split(',') - .map(f => f.trim()) - .filter(f => !!f); + .map((f) => f.trim()) + .filter((f) => !!f); return fields.length ? fields : defaultFields; } @@ -649,7 +649,7 @@ class Api { const output = {}; - const downloadOne = async url => { + const downloadOne = async (url) => { const imagePath = await this.downloadImage_(url, allowFileProtocolImages); if (imagePath) output[url] = { path: imagePath, originalUrl: url }; }; @@ -699,7 +699,7 @@ class Api { const imageSizesIndexes = {}; if (markupLanguage === MarkupToHtml.MARKUP_LANGUAGE_HTML) { - return htmlUtils.replaceImageUrls(md, imageUrl => { + return htmlUtils.replaceImageUrls(md, (imageUrl) => { const urlInfo = urls[imageUrl]; if (!urlInfo || !urlInfo.resource) return imageUrl; return Resource.internalUrl(urlInfo.resource); diff --git a/ReactNativeClient/lib/shim-init-node.js b/ReactNativeClient/lib/shim-init-node.js index d1e4ffb39..c9382c50a 100644 --- a/ReactNativeClient/lib/shim-init-node.js +++ b/ReactNativeClient/lib/shim-init-node.js @@ -27,7 +27,7 @@ function shimInit() { return shim.fsDriver_; }; - shim.randomBytes = async count => { + shim.randomBytes = async (count) => { const buffer = require('crypto').randomBytes(count); return Array.from(buffer); }; @@ -281,7 +281,7 @@ function shimInit() { const nodeFetch = require('node-fetch'); // Not used?? - shim.readLocalFileBase64 = path => { + shim.readLocalFileBase64 = (path) => { const data = fs.readFileSync(path); return new Buffer(data).toString('base64'); }; @@ -336,7 +336,7 @@ function shimInit() { return new Promise((resolve, reject) => { let file = null; - const cleanUpOnError = error => { + const cleanUpOnError = (error) => { // We ignore any unlink error as we only want to report on the main error fs.unlink(filePath) .catch(() => {}) @@ -399,7 +399,7 @@ function shimInit() { shim.Buffer = Buffer; - shim.openUrl = url => { + shim.openUrl = (url) => { const { bridge } = require('electron').remote.require('./bridge'); // Returns true if it opens the file successfully; returns false if it could // not find the file. @@ -408,7 +408,7 @@ function shimInit() { shim.httpAgent_ = null; - shim.httpAgent = url => { + shim.httpAgent = (url) => { if (shim.isLinux() && !shim.httpAgent) { const AgentSettings = { keepAlive: true, diff --git a/ReactNativeClient/lib/shim-init-react.js b/ReactNativeClient/lib/shim-init-react.js index ee34cf8af..66953ef3d 100644 --- a/ReactNativeClient/lib/shim-init-react.js +++ b/ReactNativeClient/lib/shim-init-react.js @@ -27,7 +27,7 @@ function shimInit() { return shim.fsDriver_; }; - shim.randomBytes = async count => { + shim.randomBytes = async (count) => { const randomBytes = await generateSecureRandom(count); const temp = []; for (const n in randomBytes) { @@ -134,7 +134,7 @@ function shimInit() { shim.Buffer = Buffer; - shim.openUrl = url => { + shim.openUrl = (url) => { Linking.openURL(url); }; diff --git a/ReactNativeClient/lib/shim.js b/ReactNativeClient/lib/shim.js index c5ab7ec33..defeeba39 100644 --- a/ReactNativeClient/lib/shim.js +++ b/ReactNativeClient/lib/shim.js @@ -114,7 +114,7 @@ shim.fetchRequestCanBeRetried = function(error) { shim.fetchMaxRetry_ = 5; -shim.fetchMaxRetrySet = v => { +shim.fetchMaxRetrySet = (v) => { const previous = shim.fetchMaxRetry_; shim.fetchMaxRetry_ = v; return previous; @@ -153,7 +153,7 @@ shim.fsDriver = () => { }; shim.FileApiDriverLocal = null; -shim.readLocalFileBase64 = path => { +shim.readLocalFileBase64 = (path) => { throw new Error('Not implemented'); }; @@ -163,7 +163,7 @@ shim.uploadBlob = () => { shim.sjclModule = null; -shim.randomBytes = async count => { +shim.randomBytes = async (count) => { throw new Error('Not implemented'); }; @@ -204,7 +204,7 @@ shim.appVersion = () => { throw new Error('Not implemented'); }; -shim.injectedJs = name => ''; +shim.injectedJs = (name) => ''; let isTestingEnv_ = false; diff --git a/ReactNativeClient/lib/string-utils.js b/ReactNativeClient/lib/string-utils.js index 3314eee6e..de768140d 100644 --- a/ReactNativeClient/lib/string-utils.js +++ b/ReactNativeClient/lib/string-utils.js @@ -245,7 +245,7 @@ function surroundKeywords(keywords, text, prefix, suffix) { if (!keywords.length) return text; let regexString = keywords - .map(k => { + .map((k) => { if (k.type === 'regex') { return stringUtilsCommon.replaceRegexDiacritics(k.valueRegex); } else { diff --git a/ReactNativeClient/lib/synchronizer.js b/ReactNativeClient/lib/synchronizer.js index 0dbcff59d..3e1482870 100644 --- a/ReactNativeClient/lib/synchronizer.js +++ b/ReactNativeClient/lib/synchronizer.js @@ -315,7 +315,7 @@ class Synchronizer { this.dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' }); }; - const resourceRemotePath = resourceId => { + const resourceRemotePath = (resourceId) => { return `${this.resourceDirName_}/${resourceId}`; }; @@ -340,7 +340,7 @@ class Synchronizer { if (syncSteps.indexOf('update_remote') >= 0) { const donePaths = []; - const completeItemProcessing = path => { + const completeItemProcessing = (path) => { donePaths.push(path); }; diff --git a/ReactNativeClient/root.js b/ReactNativeClient/root.js index 62ceb66db..a11495531 100644 --- a/ReactNativeClient/root.js +++ b/ReactNativeClient/root.js @@ -95,7 +95,7 @@ const logReducerAction = function(action) { // reg.logger().debug('Reducer action', msg.join(', ')); }; -const generalMiddleware = store => next => async (action) => { +const generalMiddleware = (store) => (next) => async (action) => { logReducerAction(action); PoorManIntervals.update(); // This function needs to be called regularly so put it here @@ -757,7 +757,7 @@ class AppComponent extends React.Component { - this.dropdownAlert_ = ref} tapToCloseEnabled={true} /> + this.dropdownAlert_ = ref} tapToCloseEnabled={true} /> diff --git a/Tools/build-website.js b/Tools/build-website.js index 72b013d39..2aab1229f 100644 --- a/Tools/build-website.js +++ b/Tools/build-website.js @@ -394,7 +394,7 @@ function markdownToHtml(md, templateParams) { html: true, }); - markdownIt.core.ruler.push('checkbox', state => { + markdownIt.core.ruler.push('checkbox', (state) => { const tokens = state.tokens; const Token = state.Token; const doneNames = []; @@ -432,7 +432,7 @@ function markdownToHtml(md, templateParams) { return output; }; - const createAnchorTokens = anchorName => { + const createAnchorTokens = (anchorName) => { const output = []; { diff --git a/Tools/fetchPatreonPosts.js b/Tools/fetchPatreonPosts.js index de48ef101..fc3237619 100644 --- a/Tools/fetchPatreonPosts.js +++ b/Tools/fetchPatreonPosts.js @@ -35,7 +35,7 @@ async function fetchPosts(url) { const responseJson = await response.json(); - const posts = responseJson.data.map(p => { + const posts = responseJson.data.map((p) => { return { id: p.id, title: p.attributes.title, diff --git a/Tools/git-changelog.js b/Tools/git-changelog.js index 52875b68e..02a63c1d7 100644 --- a/Tools/git-changelog.js +++ b/Tools/git-changelog.js @@ -64,7 +64,7 @@ function filterLogs(logs, platform) { let prefix = log.message.trim().toLowerCase().split(':'); if (prefix.length <= 1) continue; - prefix = prefix[0].split(',').map(s => s.trim()); + prefix = prefix[0].split(',').map((s) => s.trim()); let addIt = false; @@ -104,8 +104,8 @@ function formatCommitMessage(msg, author, options) { let subModule = ''; - const isPlatformPrefix = prefix => { - prefix = prefix.split(',').map(p => p.trim().toLowerCase()); + const isPlatformPrefix = (prefix) => { + prefix = prefix.split(',').map((p) => p.trim().toLowerCase()); for (const p of prefix) { if (['android', 'mobile', 'ios', 'desktop', 'cli', 'clipper', 'all', 'api'].indexOf(p) >= 0) return true; } @@ -124,7 +124,7 @@ function formatCommitMessage(msg, author, options) { output = output.split('\n')[0].trim(); - const detectType = msg => { + const detectType = (msg) => { msg = msg.trim().toLowerCase(); if (msg.indexOf('fix') === 0) return 'fixed'; @@ -315,7 +315,7 @@ async function main() { changelog = [].concat(changelogNews).concat(changelogImproves).concat(changelogFixes); - const changelogString = changelog.map(l => `- ${l}`); + const changelogString = changelog.map((l) => `- ${l}`); console.info(changelogString.join('\n')); } diff --git a/Tools/gulp/utils.js b/Tools/gulp/utils.js index cbc76e8e6..06da43cac 100644 --- a/Tools/gulp/utils.js +++ b/Tools/gulp/utils.js @@ -105,7 +105,7 @@ utils.copyDir = async function(src, dest, options) { } else { let excludedFlag = ''; if (options.excluded.length) { - excludedFlag = options.excluded.map(f => { + excludedFlag = options.excluded.map((f) => { return `--exclude "${f}"`; }).join(' '); } diff --git a/Tools/release-clipper.js b/Tools/release-clipper.js index 724ada171..19f5204e8 100644 --- a/Tools/release-clipper.js +++ b/Tools/release-clipper.js @@ -66,8 +66,8 @@ async function compareDir(dir1, dir2) { return !stat.isDirectory(); }; - const files1 = glob.sync(`${dir1}/**/*`, globOptions).filter(filterFiles).map(f => f.substr(dir1.length + 1)); - const files2 = glob.sync(`${dir2}/**/*`, globOptions).filter(filterFiles).map(f => f.substr(dir2.length + 1)); + const files1 = glob.sync(`${dir1}/**/*`, globOptions).filter(filterFiles).map((f) => f.substr(dir1.length + 1)); + const files2 = glob.sync(`${dir2}/**/*`, globOptions).filter(filterFiles).map((f) => f.substr(dir2.length + 1)); const missingFiles1 = []; const missingFiles2 = []; diff --git a/Tools/tool-utils.js b/Tools/tool-utils.js index 93c88fdc5..2048f086b 100644 --- a/Tools/tool-utils.js +++ b/Tools/tool-utils.js @@ -206,7 +206,7 @@ toolUtils.githubRelease = async function(project, tagName, options = null) { return responseJson; }; -toolUtils.readline = question => { +toolUtils.readline = (question) => { return new Promise((resolve) => { const readline = require('readline'); @@ -215,7 +215,7 @@ toolUtils.readline = question => { output: process.stdout, }); - rl.question(`${question} `, answer => { + rl.question(`${question} `, (answer) => { resolve(answer); rl.close(); }); diff --git a/gulpfile.js b/gulpfile.js index d8b671ec4..f8969fed8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,9 +20,9 @@ const updateIgnoredTypeScriptBuildTask = async function() { '**/Modules/TinyMCE/JoplinLists/**', '**/Modules/TinyMCE/IconPack/**', ], - }).map(f => f.substr(__dirname.length + 1)); + }).map((f) => f.substr(__dirname.length + 1)); - const ignoredFiles = tsFiles.map(f => { + const ignoredFiles = tsFiles.map((f) => { const s = f.split('.'); s.pop(); return `${s.join('.')}.js`;