Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Backport eslint updates to 5.x (#10139)
Browse files Browse the repository at this point in the history
* [eslint] update eslint config to 0.3.0

* [eslint] autofix

* [fixtures/hits] reformat to comply with max-len lint rule

* [eslint] enable no-var and autofix

* [eslint] enable prefer-const and autofix

* [eslint] fix autofix-incompatible no-var and prefer-const violations

* [eslint] enable quotes+no-extra-semi and autofix
  • Loading branch information
spalger committed Feb 7, 2017
1 parent bf3734b commit 9ed7e81
Show file tree
Hide file tree
Showing 925 changed files with 5,415 additions and 5,404 deletions.
4 changes: 0 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
extends: '@elastic/kibana'
rules:
no-unused-vars: off
no-var: off
prefer-const: off
no-extra-semi: off
quotes: off
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"wreck": "6.2.0"
},
"devDependencies": {
"@elastic/eslint-config-kibana": "0.2.1",
"@elastic/eslint-config-kibana": "0.3.0",
"angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3",
"babel-eslint": "6.1.2",
Expand All @@ -180,6 +180,7 @@
"del": "1.2.1",
"elasticdump": "2.1.1",
"eslint": "3.11.1",
"eslint-plugin-babel": "4.0.0",
"eslint-plugin-mocha": "4.7.0",
"event-stream": "3.3.2",
"expect.js": "0.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cluster/base_path_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class BasePathProxy {
method: '*',
path: `/{oldBasePath}/{kbnPath*}`,
handler(req, reply) {
const {oldBasePath, kbnPath = ''} = req.params;
const { oldBasePath, kbnPath = '' } = req.params;

const isGet = req.method === 'get';
const isBasePath = oldBasePath.length === 3;
Expand Down
14 changes: 7 additions & 7 deletions src/cli/cluster/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { EventEmitter } from 'events';

import { BinderFor, fromRoot } from '../../utils';

let cliPath = fromRoot('src/cli');
let baseArgs = _.difference(process.argv.slice(2), ['--no-watch']);
let baseArgv = [process.execPath, cliPath].concat(baseArgs);
const cliPath = fromRoot('src/cli');
const baseArgs = _.difference(process.argv.slice(2), ['--no-watch']);
const baseArgv = [process.execPath, cliPath].concat(baseArgs);

cluster.setupMaster({
exec: cliPath,
silent: false
});

let dead = fork => {
const dead = fork => {
return fork.isDead() || fork.killed;
};

Expand All @@ -40,7 +40,7 @@ module.exports = class Worker extends EventEmitter {
this.clusterBinder = new BinderFor(cluster);
this.processBinder = new BinderFor(process);

let argv = _.union(baseArgv, opts.argv || []);
const argv = _.union(baseArgv, opts.argv || []);
this.env = {
kbnWorkerType: this.type,
kbnWorkerArgv: JSON.stringify(argv)
Expand Down Expand Up @@ -124,8 +124,8 @@ module.exports = class Worker extends EventEmitter {
}

flushChangeBuffer() {
let files = _.unique(this.changes.splice(0));
let prefix = files.length > 1 ? '\n - ' : '';
const files = _.unique(this.changes.splice(0));
const prefix = files.length > 1 ? '\n - ' : '';
return files.reduce(function (list, file) {
return `${list || ''}${prefix}"${file}"`;
}, '');
Expand Down
12 changes: 6 additions & 6 deletions src/cli/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ Command.prototype.unknownArgv = function (argv) {
* @return {[type]} [description]
*/
Command.prototype.collectUnknownOptions = function () {
let title = `Extra ${this._name} options`;
const title = `Extra ${this._name} options`;

this.allowUnknownOption();
this.getUnknownOptions = function () {
let opts = {};
let unknowns = this.unknownArgv();
const opts = {};
const unknowns = this.unknownArgv();

while (unknowns.length) {
let opt = unknowns.shift().split('=');
const opt = unknowns.shift().split('=');
if (opt[0].slice(0, 2) !== '--') {
this.error(`${title} "${opt[0]}" must start with "--"`);
}
Expand All @@ -75,14 +75,14 @@ Command.prototype.collectUnknownOptions = function () {
};

Command.prototype.parseOptions = _.wrap(Command.prototype.parseOptions, function (parse, argv) {
let opts = parse.call(this, argv);
const opts = parse.call(this, argv);
this.unknownArgv(opts.unknown);
return opts;
});

Command.prototype.action = _.wrap(Command.prototype.action, function (action, fn) {
return action.call(this, function (...args) {
let ret = fn.apply(this, args);
const ret = fn.apply(this, args);
if (ret && typeof ret.then === 'function') {
ret.then(null, function (e) {
console.log('FATAL CLI ERROR', e.stack);
Expand Down
18 changes: 9 additions & 9 deletions src/cli/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = function (command, spaces) {
return command.outputHelp();
}

let defCmd = _.find(command.commands, function (cmd) {
const defCmd = _.find(command.commands, function (cmd) {
return cmd._name === 'serve';
});

let desc = !command.description() ? '' : command.description();
let cmdDef = !defCmd ? '' : `=${defCmd._name}`;
const desc = !command.description() ? '' : command.description();
const cmdDef = !defCmd ? '' : `=${defCmd._name}`;

return (
`
Expand All @@ -31,11 +31,11 @@ function indent(str, n) {
}

function commandsSummary(program) {
let cmds = _.compact(program.commands.map(function (cmd) {
let name = cmd._name;
const cmds = _.compact(program.commands.map(function (cmd) {
const name = cmd._name;
if (name === '*') return;
let opts = cmd.options.length ? ' [options]' : '';
let args = cmd._args.map(function (arg) {
const opts = cmd.options.length ? ' [options]' : '';
const args = cmd._args.map(function (arg) {
return humanReadableArgName(arg);
}).join(' ');

Expand All @@ -45,7 +45,7 @@ function commandsSummary(program) {
];
}));

let cmdLColWidth = cmds.reduce(function (width, cmd) {
const cmdLColWidth = cmds.reduce(function (width, cmd) {
return Math.max(width, cmd[0].length);
}, 0);

Expand All @@ -69,6 +69,6 @@ ${indent(cmd.optionHelp(), 2)}
}

function humanReadableArgName(arg) {
let nameOutput = arg.name + (arg.variadic === true ? '...' : '');
const nameOutput = arg.name + (arg.variadic === true ? '...' : '');
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
}
2 changes: 1 addition & 1 deletion src/cli/log.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import ansicolors from 'ansicolors';

let log = _.restParam(function (color, label, rest1) {
const log = _.restParam(function (color, label, rest1) {
console.log.apply(console, [color(` ${_.trim(label)} `)].concat(rest1));
});

Expand Down
8 changes: 4 additions & 4 deletions src/cli_plugin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import listCommand from './list';
import installCommand from './install';
import removeCommand from './remove';

let argv = process.env.kbnWorkerArgv ? JSON.parse(process.env.kbnWorkerArgv) : process.argv.slice();
let program = new Command('bin/kibana-plugin');
const argv = process.env.kbnWorkerArgv ? JSON.parse(process.env.kbnWorkerArgv) : process.argv.slice();
const program = new Command('bin/kibana-plugin');

program
.version(pkg.version)
Expand All @@ -23,7 +23,7 @@ program
.command('help <command>')
.description('get the help for a specific command')
.action(function (cmdName) {
let cmd = _.find(program.commands, { _name: cmdName });
const cmd = _.find(program.commands, { _name: cmdName });
if (!cmd) return program.error(`unknown command ${cmdName}`);
cmd.help();
});
Expand All @@ -35,7 +35,7 @@ program
});

// check for no command name
let subCommand = argv[2] && !String(argv[2][0]).match(/^-|^\.|\//);
const subCommand = argv[2] && !String(argv[2][0]).match(/^-|^\.|\//);
if (!subCommand) {
program.defaultHelp();
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('kibana cli', function () {

describe('commander options', function () {

let program = {
const program = {
command: function () { return program; },
description: function () { return program; },
option: function () { return program; },
Expand Down
4 changes: 2 additions & 2 deletions src/cli_plugin/install/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function cleanPrevious(settings, logger) {
resolve();
}
});
};
}

export function cleanArtifacts(settings) {
// delete the working directory.
Expand All @@ -29,4 +29,4 @@ export function cleanArtifacts(settings) {
rimraf.sync(settings.plugins[0].path);
}
catch (e) {} // eslint-disable-line no-empty
};
}
2 changes: 1 addition & 1 deletion src/cli_plugin/install/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export function download(settings, logger) {
}

return tryNext();
};
}
2 changes: 1 addition & 1 deletion src/cli_plugin/install/downloaders/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createWriteStream, createReadStream, unlinkSync, statSync } from 'fs';

function openSourceFile({ sourcePath }) {
try {
let fileInfo = statSync(sourcePath);
const fileInfo = statSync(sourcePath);

const readStream = createReadStream(sourcePath);

Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/downloaders/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default async function downloadUrl(logger, sourceUrl, targetPath, timeout
const { req, resp } = await sendRequest({ sourceUrl, timeout });

try {
let totalSize = parseFloat(resp.headers['content-length']) || 0;
const totalSize = parseFloat(resp.headers['content-length']) || 0;
const progress = new Progress(logger);
progress.init(totalSize);

Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ export default function pluginInstall(program) {
install file:https:///Path/to/my/x-pack.zip
install https://path.to/my/x-pack.zip`)
.action(processCommand);
};
}
2 changes: 1 addition & 1 deletion src/cli_plugin/install/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ export async function extract(settings, logger) {
logger.error(err);
throw new Error('Error extracting plugin archive');
}
};
}
4 changes: 2 additions & 2 deletions src/cli_plugin/install/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function parseMilliseconds(val) {
}

return result;
};
}

export function parse(command, options, kbnPackage) {
const settings = {
Expand All @@ -44,4 +44,4 @@ export function parse(command, options, kbnPackage) {
};

return settings;
};
}
2 changes: 1 addition & 1 deletion src/cli_plugin/lib/errors.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export class UnsupportedProtocolError extends Error {};
export class UnsupportedProtocolError extends Error {}
2 changes: 1 addition & 1 deletion src/cli_plugin/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export default class Logger {
}
process.stderr.write(`${data}\n`);
this.previousLineEnded = true;
};
}

}
2 changes: 1 addition & 1 deletion src/cli_plugin/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ export default function pluginList(program) {
)
.description('list installed plugins')
.action(processCommand);
};
}
2 changes: 1 addition & 1 deletion src/cli_plugin/list/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export function parse(command, options) {
};

return settings;
};
}
2 changes: 1 addition & 1 deletion src/cli_plugin/remove/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ export default function pluginRemove(program) {
`common examples:
remove x-pack`)
.action(processCommand);
};
}
2 changes: 1 addition & 1 deletion src/cli_plugin/remove/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export function parse(command, options) {
settings.pluginPath = resolve(settings.pluginDir, settings.plugin);

return settings;
};
}
2 changes: 1 addition & 1 deletion src/core_plugins/console/api_server/es_5_0.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function ES_5_0() {
}, this);
}

ES_5_0.prototype = _.create(Api.prototype, {'constructor': ES_5_0});
ES_5_0.prototype = _.create(Api.prototype, { 'constructor': ES_5_0 });

(function (cls) {
cls.addEndpointDescription = function (endpoint, description) {
Expand Down
Loading

0 comments on commit 9ed7e81

Please sign in to comment.