Skip to content

Commit

Permalink
Revert "Tools: Added eslint rule arrow-parens"
Browse files Browse the repository at this point in the history
This reverts commit 0b6f558.

It causes too many conflicts with pull requests.
  • Loading branch information
laurent22 committed May 21, 2020
1 parent b83eee7 commit a96734f
Show file tree
Hide file tree
Showing 166 changed files with 444 additions and 445 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions CliClient/app/ResourceServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down Expand Up @@ -73,7 +73,7 @@ class ResourceServer {
response.end();
});

this.server_.on('error', (error) => {
this.server_.on('error', error => {
this.logger().error('Resource server:', error);
});

Expand Down
12 changes: 6 additions & 6 deletions CliClient/app/app-gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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 === '-') {
Expand Down Expand Up @@ -166,7 +166,7 @@ class AppGui {
});
}
});
this.rootWidget_.connect(folderList, (state) => {
this.rootWidget_.connect(folderList, state => {
return {
selectedFolderId: state.selectedFolderId,
selectedTagId: state.selectedTagId,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions CliClient/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -275,7 +275,7 @@ class Application extends BaseApplication {
},
showConsole: () => {},
maximizeConsole: () => {},
stdout: (text) => {
stdout: text => {
console.info(text);
},
fullScreen: () => {},
Expand Down Expand Up @@ -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');
Expand Down
18 changes: 9 additions & 9 deletions CliClient/app/autocompletion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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') {
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions CliClient/app/build-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion CliClient/app/cli-integration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async function main() {
}
}

main(process.argv).catch((error) => {
main(process.argv).catch(error => {
console.info('');
logger.error(error);
});
6 changes: 3 additions & 3 deletions CliClient/app/cli-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion CliClient/app/command-apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Command extends BaseCommand {
{
name: 'type',
label: 'Type',
filter: (value) => {
filter: value => {
return Database.enumName('fieldType', value);
},
},
Expand Down
2 changes: 1 addition & 1 deletion CliClient/app/command-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions CliClient/app/command-e2ee.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions CliClient/app/command-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.')]];
}
Expand All @@ -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));
}
}

Expand Down
6 changes: 3 additions & 3 deletions CliClient/app/command-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down
10 changes: 5 additions & 5 deletions CliClient/app/command-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.')]];
}
Expand All @@ -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));
Expand All @@ -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);
};
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion CliClient/app/command-rmnote.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions CliClient/app/command-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
Loading

0 comments on commit a96734f

Please sign in to comment.