1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Revert "Tools: Added eslint rule arrow-parens"

This reverts commit 0b6f5581f0.

It causes too many conflicts with pull requests.
This commit is contained in:
Laurent Cozic 2020-05-21 09:14:33 +01:00
parent b83eee751f
commit a96734f5be
166 changed files with 444 additions and 445 deletions

View File

@ -100,7 +100,6 @@ module.exports = {
"space-before-blocks": "error",
"spaced-comment": ["error", "always"],
"keyword-spacing": ["error", { "before": true, "after": true }],
"arrow-parens": ["error"],
},
"plugins": [
"react",

View File

@ -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);
});

View File

@ -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();

View File

@ -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');

View File

@ -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;
}

View File

@ -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);
});

View File

@ -236,7 +236,7 @@ async function main() {
}
}
main(process.argv).catch((error) => {
main(process.argv).catch(error => {
console.info('');
logger.error(error);
});

View File

@ -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);

View File

@ -25,7 +25,7 @@ class Command extends BaseCommand {
{
name: 'type',
label: 'Type',
filter: (value) => {
filter: value => {
return Database.enumName('fieldType', value);
},
},

View File

@ -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);

View File

@ -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;

View File

@ -17,8 +17,8 @@ class Command extends BaseCommand {
const service = new InteropService();
const formats = service
.modules()
.filter((m) => m.type === 'exporter' && m.format !== 'html')
.map((m) => m.format + (m.description ? ` (${m.description})` : ''));
.filter(m => m.type === 'exporter' && m.format !== 'html')
.map(m => m.format + (m.description ? ` (${m.description})` : ''));
return [['--format <format>', _('Destination format: %s', formats.join(', '))], ['--note <note>', _('Exports only the given note.')], ['--notebook <notebook>', _('Exports only the given notebook.')]];
}
@ -34,17 +34,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));
}
}

View File

@ -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('');

View File

@ -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 <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));
}

View File

@ -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);
}
}

View File

@ -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);
},

View File

@ -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 {

View File

@ -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);
});

View File

@ -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 : '';

View File

@ -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}`;

View File

@ -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(' '));

View File

@ -41,7 +41,7 @@ function renderCommandHelp(cmd, width = null) {
}
if (cmd.name() === 'config') {
const renderMetadata = (md) => {
const renderMetadata = md => {
const desc = [];
if (md.label) {

View File

@ -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.'));

View File

@ -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);

View File

@ -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);
}));

View File

@ -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);

View File

@ -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([]);
}));
});

View File

@ -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 () => {

View File

@ -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);
}));

View File

@ -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}`);

View File

@ -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) {

View File

@ -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(','));
}
}));

View File

@ -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;
}

View File

@ -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];

View File

@ -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}`))
);

View File

@ -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);
}

View File

@ -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;
});

View File

@ -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();

View File

@ -1153,7 +1153,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;

View File

@ -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(() => {

View File

@ -143,7 +143,7 @@ class ClipperConfigScreenComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
clipperServer: state.clipperServer,

View File

@ -314,7 +314,7 @@ class ConfigScreenComponent extends React.Component {
<select
value={value}
style={selectStyle}
onChange={(event) => {
onChange={event => {
updateSettingValue(key, event.target.value);
}}
>
@ -338,12 +338,12 @@ class ConfigScreenComponent extends React.Component {
id={`setting_checkbox_${key}`}
type="checkbox"
checked={!!value}
onChange={(event) => {
onChange={event => {
onCheckboxClick(event);
}}
/>
<label
onClick={(event) => {
onClick={event => {
onCheckboxClick(event);
}}
style={checkboxLabelStyle}
@ -365,13 +365,13 @@ class ConfigScreenComponent extends React.Component {
if (md.subType === 'file_path_and_args') {
inputStyle.marginBottom = subLabel.marginBottom;
const splitCmd = (cmdString) => {
const splitCmd = cmdString => {
const path = pathUtils.extractExecutablePath(cmdString);
const args = cmdString.substr(path.length + 1);
return [pathUtils.unquotePath(path), args];
};
const joinCmd = (cmdArray) => {
const joinCmd = cmdArray => {
if (!cmdArray[0] && !cmdArray[1]) return '';
let cmdString = pathUtils.quotePath(cmdArray[0]);
if (!cmdString) cmdString = '""';
@ -379,13 +379,13 @@ class ConfigScreenComponent extends React.Component {
return cmdString;
};
const onPathChange = (event) => {
const onPathChange = event => {
const cmd = splitCmd(this.state.settings[key]);
cmd[0] = event.target.value;
updateSettingValue(key, joinCmd(cmd));
};
const onArgsChange = (event) => {
const onArgsChange = event => {
const cmd = splitCmd(this.state.settings[key]);
cmd[1] = event.target.value;
updateSettingValue(key, joinCmd(cmd));
@ -418,7 +418,7 @@ class ConfigScreenComponent extends React.Component {
<input
type={inputType}
style={Object.assign({}, inputStyle, { marginBottom: 0 })}
onChange={(event) => {
onChange={event => {
onPathChange(event);
}}
value={cmd[0]}
@ -430,7 +430,7 @@ class ConfigScreenComponent extends React.Component {
<input
type={inputType}
style={inputStyle}
onChange={(event) => {
onChange={event => {
onArgsChange(event);
}}
value={cmd[1]}
@ -449,7 +449,7 @@ class ConfigScreenComponent extends React.Component {
</div>
);
} 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,

View File

@ -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,
};

View File

@ -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 {
<td style={theme.textStyle}>{time.formatMsToLocal(mk.created_time)}</td>
<td style={theme.textStyle}>{time.formatMsToLocal(mk.updated_time)}</td>
<td style={theme.textStyle}>
<input type="password" style={passwordStyle} value={password} onChange={(event) => onPasswordChange(event)} />{' '}
<input type="password" style={passwordStyle} value={password} onChange={event => onPasswordChange(event)} />{' '}
<button style={theme.buttonStyle} onClick={() => onSaveClick()}>
{_('Save')}
</button>
@ -287,7 +287,7 @@ class EncryptionConfigScreenComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
masterKeys: state.masterKeys,

View File

@ -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 (
<div key={key} style={containerStyle}>
<input type="text" style={inputStyle} placeholder={options.title} value={state.searchQuery} onChange={this.search_onChange} ref={(elem) => (this.searchElement_ = elem)} onFocus={this.search_onFocus} onBlur={this.search_onBlur} onKeyDown={this.search_keyDown} />
<input type="text" style={inputStyle} placeholder={options.title} value={state.searchQuery} onChange={this.search_onChange} ref={elem => (this.searchElement_ = elem)} onFocus={this.search_onFocus} onBlur={this.search_onBlur} onKeyDown={this.search_keyDown} />
<a href="#" style={searchButton} onClick={this.search_onClear}>
{icon}
</a>
@ -326,7 +326,7 @@ class HeaderComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
windowCommand: state.windowCommand,

View File

@ -27,7 +27,7 @@ class HelpButtonComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
};

View File

@ -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,
};

View File

@ -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'],

View File

@ -44,7 +44,7 @@ class NavigatorComponent extends Component {
}
}
const Navigator = connect((state) => {
const Navigator = connect(state => {
return {
route: state.route,
};

View File

@ -332,7 +332,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);

View File

@ -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 };

View File

@ -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}
<a
ref={ref}
onContextMenu={(event) => 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,

View File

@ -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}
/>
);

View File

@ -211,7 +211,7 @@ class NoteRevisionViewerComponent extends React.PureComponent {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
};

View File

@ -170,7 +170,7 @@ class NoteSearchBarComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
};

View File

@ -23,7 +23,7 @@ class NoteStatusBarComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
// notes: state.notes,
// folders: state.folders,

View File

@ -167,7 +167,7 @@ class NoteTextViewerComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
};

View File

@ -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,
};

View File

@ -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 = <Datetime value={this.state.answer} inputProps={{ style: styles.input }} dateFormat={time.dateFormat()} timeFormat={time.timeFormat()} onChange={(momentObject) => onDateTimeChange(momentObject)} />;
inputComp = <Datetime value={this.state.answer} inputProps={{ style: styles.input }} dateFormat={time.dateFormat()} timeFormat={time.timeFormat()} onChange={momentObject => onDateTimeChange(momentObject)} />;
} else if (this.props.inputType === 'tags') {
inputComp = <CreatableSelect styles={styles.select} theme={styles.selectTheme} ref={this.answerInput_} value={this.state.answer} placeholder="" components={makeAnimated()} isMulti={true} isClearable={false} backspaceRemovesValue={true} options={this.props.autocomplete} onChange={onSelectChange} onKeyDown={(event) => onKeyDown(event)} />;
inputComp = <CreatableSelect styles={styles.select} theme={styles.selectTheme} ref={this.answerInput_} value={this.state.answer} placeholder="" components={makeAnimated()} isMulti={true} isClearable={false} backspaceRemovesValue={true} options={this.props.autocomplete} onChange={onSelectChange} onKeyDown={event => onKeyDown(event)} />;
} else if (this.props.inputType === 'dropdown') {
inputComp = <Select styles={styles.select} theme={styles.selectTheme} ref={this.answerInput_} components={makeAnimated()} value={this.props.answer} defaultValue={this.props.defaultValue} isClearable={false} options={this.props.autocomplete} onChange={onSelectChange} onKeyDown={(event) => onKeyDown(event)} />;
inputComp = <Select styles={styles.select} theme={styles.selectTheme} ref={this.answerInput_} components={makeAnimated()} value={this.props.answer} defaultValue={this.props.defaultValue} isClearable={false} options={this.props.autocomplete} onChange={onSelectChange} onKeyDown={event => onKeyDown(event)} />;
} else {
inputComp = <input style={styles.input} ref={this.answerInput_} value={this.state.answer} type="text" onChange={(event) => onChange(event)} onKeyDown={(event) => onKeyDown(event)} />;
inputComp = <input style={styles.input} ref={this.answerInput_} value={this.state.answer} type="text" onChange={event => onChange(event)} onKeyDown={event => onKeyDown(event)} />;
}
const buttonComps = [];

View File

@ -98,7 +98,7 @@ class RootComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
size: state.windowContentSize,
zoomFactor: state.settings.windowContentZoomFactor / 100,

View File

@ -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,

View File

@ -146,7 +146,7 @@ class StatusScreenComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
theme: state.settings.theme,
settings: state.settings,

View File

@ -12,7 +12,7 @@ class TagItemComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return { theme: state.settings.theme };
};

View File

@ -41,7 +41,7 @@ class TagListComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return { theme: state.settings.theme };
};

View File

@ -51,7 +51,7 @@ class ToolbarComponent extends React.Component {
}
}
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return { theme: state.settings.theme };
};

View File

@ -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;

View File

@ -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++) {

View File

@ -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

View File

@ -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 += ' ...';
}

View File

@ -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('.');

View File

@ -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 });
};

View File

@ -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);
});
}

View File

@ -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));
});
}

View File

@ -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;
});

View File

@ -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';

View File

@ -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) {

View File

@ -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: '-',

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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) {

View File

@ -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');

View File

@ -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.

View File

@ -170,7 +170,7 @@ class CameraView extends Component {
<View style={{ position: 'absolute', backgroundColor: '#000000', width: '100%', height: '100%' }}/>
<RNCamera
style={Object.assign({ position: 'absolute' }, cameraRect)}
ref={(ref) => {
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'],

View File

@ -90,7 +90,7 @@ class Dropdown extends React.Component {
this.setState({ listVisible: false });
};
const itemRenderer = (item) => {
const itemRenderer = item => {
return (
<TouchableOpacity
style={itemWrapperStyle}
@ -111,7 +111,7 @@ class Dropdown extends React.Component {
<View style={{ flex: 1, flexDirection: 'column' }}>
<TouchableOpacity
style={headerWrapperStyle}
ref={(ref) => (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);
}}
/>

View File

@ -93,11 +93,11 @@ class ItemList extends React.Component {
return (
<ScrollView
scrollEventThrottle={500}
onLayout={(event) => {
onLayout={event => {
this.onLayout(event);
}}
style={style}
onScroll={(event) => {
onScroll={event => {
this.onScroll(event);
}}
>

View File

@ -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,

View File

@ -78,7 +78,7 @@ class AppNavComponent extends Component {
}
}
const AppNav = connect((state) => {
const AppNav = connect(state => {
return {
route: state.route,
theme: state.settings.theme,

View File

@ -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));

View File

@ -133,7 +133,7 @@ class NoteItemComponent extends Component {
<View style={selectionWrapperStyle}>
<View style={opacityStyle}>
<View style={listItemStyle}>
<Checkbox style={checkboxStyle} checked={checkboxChecked} onChange={(checked) => this.todoCheckbox_change(checked)} />
<Checkbox style={checkboxStyle} checked={checkboxChecked} onChange={checked => this.todoCheckbox_change(checked)} />
<Text style={listItemTextStyle}>{Note.displayTitle(note)}</Text>
</View>
</View>
@ -143,7 +143,7 @@ class NoteItemComponent extends Component {
}
}
const NoteItem = connect((state) => {
const NoteItem = connect(state => {
return {
theme: state.settings.theme,
noteSelectionEnabled: state.noteSelectionEnabled,

View File

@ -87,10 +87,10 @@ class NoteListComponent extends Component {
if (this.props.items.length) {
return <FlatList
ref={(ref) => (this.rootRef_ = ref)}
ref={ref => (this.rootRef_ = ref)}
data={this.props.items}
renderItem={({ item }) => <NoteItem note={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,

View File

@ -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 : (
<Menu onSelect={(value) => this.menu_select(value)} style={this.styles().contextMenu}>
<Menu onSelect={value => this.menu_select(value)} style={this.styles().contextMenu}>
<MenuTrigger style={contextMenuStyle}>
<Icon name="md-more" style={this.styles().contextMenuTrigger} />
</MenuTrigger>
@ -481,7 +481,7 @@ class ScreenHeaderComponent extends React.PureComponent {
</View>
{warningComps}
<DialogBox
ref={(dialogbox) => {
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,

View File

@ -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,

View File

@ -392,7 +392,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
<Text key="label" style={this.styles().switchSettingText}>
{md.label()}
</Text>
<Switch key="control" style={this.styles().switchSettingControl} trackColor={{ false: theme.strongDividerColor }} value={value} onValueChange={(value) => updateSettingValue(key, value)} />
<Switch key="control" style={this.styles().switchSettingControl} trackColor={{ false: theme.strongDividerColor }} value={value} onValueChange={value => updateSettingValue(key, value)} />
</View>
{descriptionComp}
</View>
@ -410,7 +410,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
</Text>
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', flex: 1 }}>
<Text style={this.styles().sliderUnits}>{unitLabel}</Text>
<Slider key="control" style={{ flex: 1 }} step={md.step} minimumValue={md.minimum} maximumValue={md.maximum} value={value} onValueChange={(value) => updateSettingValue(key, value)} />
<Slider key="control" style={{ flex: 1 }} step={md.step} minimumValue={md.minimum} maximumValue={md.maximum} value={value} onValueChange={value => updateSettingValue(key, value)} />
</View>
</View>
);
@ -420,7 +420,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
<Text key="label" style={this.styles().settingText}>
{md.label()}
</Text>
<TextInput autoCorrect={false} autoCompleteType="off" selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} autoCapitalize="none" key="control" style={this.styles().settingControl} value={value} onChangeText={(value) => updateSettingValue(key, value)} secureTextEntry={!!md.secure} />
<TextInput autoCorrect={false} autoCompleteType="off" selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} autoCapitalize="none" key="control" style={this.styles().settingControl} value={value} onChangeText={value => updateSettingValue(key, value)} secureTextEntry={!!md.secure} />
</View>
);
} 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,

View File

@ -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 {
</ScrollView>
<DialogBox
ref={(dialogbox) => {
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,
};

View File

@ -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 {
<Text style={this.styles().normalText}>{_('Created: %s', time.formatMsToLocal(mk.created_time))}</Text>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<Text style={{ flex: 0, fontSize: theme.fontSize, marginRight: 10, color: theme.color }}>{_('Password:')}</Text>
<TextInput selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} secureTextEntry={true} value={password} onChangeText={(text) => onPasswordChange(text)} style={inputStyle}></TextInput>
<TextInput selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} secureTextEntry={true} value={password} onChangeText={text => onPasswordChange(text)} style={inputStyle}></TextInput>
<Text style={{ fontSize: theme.fontSize, marginRight: 10, color: theme.color }}>{passwordOk}</Text>
<Button title={_('Save')} onPress={() => onSaveClick()}></Button>
</View>
@ -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 });
}}
></TextInput>
@ -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 });
}}
></TextInput>
@ -286,7 +286,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
<View style={{ flex: 1, height: 20 }}></View>
</ScrollView>
<DialogBox
ref={(dialogbox) => {
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,

View File

@ -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 (
<View style={this.rootStyle(this.props.theme).root}>
<ScreenHeader title={_('Edit notebook')} showSaveButton={true} saveButtonDisabled={saveButtonDisabled} onSaveButtonPress={() => this.saveFolderButton_press()} showSideMenuButton={false} showSearchButton={false} />
<TextInput placeholder={_('Enter notebook title')} placeholderTextColor={theme.colorFaded} underlineColorAndroid={theme.strongDividerColor} selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} style={this.styles().textInput} autoFocus={true} value={this.state.folder.title} onChangeText={(text) => this.title_changeText(text)} />
<TextInput placeholder={_('Enter notebook title')} placeholderTextColor={theme.colorFaded} underlineColorAndroid={theme.strongDividerColor} selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} style={this.styles().textInput} autoFocus={true} value={this.state.folder.title} onChangeText={text => this.title_changeText(text)} />
<dialogs.DialogBox
ref={(dialogbox) => {
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,

View File

@ -101,7 +101,7 @@ class LogScreenComponent extends BaseScreenComponent {
<FlatList
data={this.state.logEntries}
renderItem={renderRow}
keyExtractor={(item) => { return `${item.id}`; }}
keyExtractor={item => { return `${item.id}`; }}
/>
<View style={{ flexDirection: 'row' }}>
<View style={{ flex: 1, marginRight: 5 }}>
@ -126,7 +126,7 @@ class LogScreenComponent extends BaseScreenComponent {
}
}
const LogScreen = connect((state) => {
const LogScreen = connect(state => {
return {
theme: state.settings.theme,
};

View File

@ -130,7 +130,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);
@ -411,7 +411,7 @@ class NoteScreenComponent extends BaseScreenComponent {
(width, height) => {
resolve({ width: width, height: height });
},
(error) => {
error => {
reject(error);
}
);
@ -420,7 +420,7 @@ class NoteScreenComponent extends BaseScreenComponent {
showImagePicker(options) {
return new Promise((resolve) => {
ImagePicker.launchImageLibrary(options, (response) => {
ImagePicker.launchImageLibrary(options, response => {
resolve(response);
});
});
@ -883,7 +883,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);
};
@ -911,7 +911,7 @@ class NoteScreenComponent extends BaseScreenComponent {
highlightedKeywords={keywords}
theme={this.props.theme}
noteHash={this.props.noteHash}
onCheckboxChange={(newBody) => {
onCheckboxChange={newBody => {
onCheckboxChange(newBody);
}}
onMarkForDownload={this.onMarkForDownload}
@ -935,7 +935,7 @@ class NoteScreenComponent extends BaseScreenComponent {
keywords = SearchEngine.instance().allParsedQueryTerms(parsedQuery);
}
const onCheckboxChange = (newBody) => {
const onCheckboxChange = newBody => {
this.saveOneProperty('body', newBody);
};
@ -950,7 +950,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}
@ -969,7 +969,7 @@ class NoteScreenComponent extends BaseScreenComponent {
highlightedKeywords: keywords,
theme: this.props.theme,
noteHash: this.props.noteHash,
onCheckboxChange: (newBody) => {
onCheckboxChange: newBody => {
onCheckboxChange(newBody);
},
onMarkForDownload: this.onMarkForDownload,
@ -1058,7 +1058,7 @@ class NoteScreenComponent extends BaseScreenComponent {
<SelectDateTimeDialog shown={this.state.alarmDialogShown} date={dueDate} onAccept={this.onAlarmDialogAccept} onReject={this.onAlarmDialogReject} />
<DialogBox
ref={(dialogbox) => {
ref={dialogbox => {
this.dialogbox = dialogbox;
}}
/>
@ -1068,7 +1068,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,

View File

@ -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 {
<NoteList style={this.styles().noteList} />
{actionButtonComp}
<DialogBox
ref={(dialogbox) => {
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,

View File

@ -98,7 +98,7 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent {
<ScreenHeader title={_('Login with OneDrive')} />
<WebView
source={source}
onNavigationStateChange={(o) => {
onNavigationStateChange={o => {
this.webview_load(o);
}}
onError={() => {

Some files were not shown because too many files have changed in this diff Show More