Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint] re-enable no-var and prefer-const #9455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
extends: '@elastic/kibana'
rules:
no-unused-vars: off
no-var: off
prefer-const: off
no-extra-semi: off
quotes: off
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let version = pkg.version;

describe('plugins/elasticsearch', function () {
describe('lib/is_upgradeable', function () {
let server = {
const server = {
config: _.constant({
get: function (key) {
switch (key) {
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('plugins/elasticsearch', function () {
upgradeDoc('5.0.0-alpha1', '5.0.0', false);

it('should handle missing _id field', function () {
let doc = {
const doc = {
'_index': '.kibana',
'_type': 'config',
'_score': 1,
Expand All @@ -58,7 +58,7 @@ describe('plugins/elasticsearch', function () {
});

it('should handle _id of @@version', function () {
let doc = {
const doc = {
'_index': '.kibana',
'_type': 'config',
'_id': '@@version',
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kbn_doc_views/public/views/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ docViewsRegistry.register(function () {
};

$scope.showArrayInObjectsWarning = function (row, field) {
let value = $scope.flattened[field];
const value = $scope.flattened[field];
return _.isArray(value) && typeof value[0] === 'object';
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function (kibana) {
],

injectVars: function (server, options) {
let config = server.config();
const config = server.config();
return {
kbnDefaultAppId: config.get('kibana.defaultAppId'),
tilemap: config.get('tilemap')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('dashboard panels', function () {

it('loads with no vizualizations', function () {
ngMock.inject((SavedDashboard) => {
let dash = new SavedDashboard();
const dash = new SavedDashboard();
dash.init();
compile(dash);
});
Expand All @@ -50,7 +50,7 @@ describe('dashboard panels', function () {

it('loads one vizualization', function () {
ngMock.inject((SavedDashboard) => {
let dash = new SavedDashboard();
const dash = new SavedDashboard();
dash.init();
dash.panelsJSON = `[{"col":3,"id":"foo1","row":1,"size_x":2,"size_y":2,"type":"visualization"}]`;
compile(dash);
Expand All @@ -60,7 +60,7 @@ describe('dashboard panels', function () {

it('loads vizualizations in correct order', function () {
ngMock.inject((SavedDashboard) => {
let dash = new SavedDashboard();
const dash = new SavedDashboard();
dash.init();
dash.panelsJSON = `[
{"col":3,"id":"foo1","row":1,"size_x":2,"size_y":2,"type":"visualization"},
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('dashboard panels', function () {

it('initializes visualizations with the default size', function () {
ngMock.inject((SavedDashboard) => {
let dash = new SavedDashboard();
const dash = new SavedDashboard();
dash.init();
dash.panelsJSON = `[
{"col":3,"id":"foo1","row":1,"type":"visualization"},
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function VisEditor($scope, $route, timefilter, AppState, $location, kbnUrl, $tim
};

// Instance of app_state.js.
let $state = $scope.$state = (function initState() {
const $state = $scope.$state = (function initState() {
// This is used to sync visualization state with the url when `appState.save()` is called.
const appState = new AppState(stateDefaults);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('createMappingsFromPatternFields', function () {
});

it('should set the same default mapping for all non-strings', function () {
let mappings = createMappingsFromPatternFields(testFields);
const mappings = createMappingsFromPatternFields(testFields);

_.forEach(mappings, function (mapping) {
if (mapping.type !== 'text') {
Expand All @@ -50,7 +50,7 @@ describe('createMappingsFromPatternFields', function () {
});

it('should give strings a multi-field mapping with a "text" base type', function () {
let mappings = createMappingsFromPatternFields(testFields);
const mappings = createMappingsFromPatternFields(testFields);

_.forEach(mappings, function (mapping) {
if (mapping.type === 'text') {
Expand All @@ -61,7 +61,7 @@ describe('createMappingsFromPatternFields', function () {

it('should handle nested fields', function () {
testFields.push({name: 'geo.coordinates', type: 'geo_point'});
let mappings = createMappingsFromPatternFields(testFields);
const mappings = createMappingsFromPatternFields(testFields);

expect(mappings).to.have.property('geo');
expect(mappings.geo).to.have.property('properties');
Expand All @@ -74,7 +74,7 @@ describe('createMappingsFromPatternFields', function () {
});

it('should map all number fields as an ES double', function () {
let mappings = createMappingsFromPatternFields(testFields);
const mappings = createMappingsFromPatternFields(testFields);

expect(mappings).to.have.property('bytes');
expect(mappings.bytes).to.have.property('type', 'double');
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/table_vis/public/table_vis_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const module = uiModules.get('kibana/table_vis', ['kibana']);
module.controller('KbnTableVisController', function ($scope, $element, Private) {
const tabifyAggResponse = Private(AggResponseTabifyTabifyProvider);

var uiStateSort = ($scope.uiState) ? $scope.uiState.get('vis.params.sort') : {};
const uiStateSort = ($scope.uiState) ? $scope.uiState.get('vis.params.sort') : {};
assign($scope.vis.params.sort, uiStateSort);

$scope.sort = $scope.vis.params.sort;
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/tagcloud/public/tag_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function hashCode(string) {
return hash;
}
for (let i = 0; i < string.length; i++) {
let char = string.charCodeAt(i);
const char = string.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32bit integer
}
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/tagcloud/public/tag_cloud_vis_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ uiModules.get('kibana/table_vis')
template: tagCloudVisParamsTemplate,
link: function ($scope, $element) {
const sliderContainer = $element[0];
var slider = sliderContainer.querySelector('.tag-cloud-fontsize-slider');
const slider = sliderContainer.querySelector('.tag-cloud-fontsize-slider');
noUiSlider.create(slider, {
start: [$scope.vis.params.minFontSize, $scope.vis.params.maxFontSize],
connect: true,
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/tests_bundle/find_source_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resolve } from 'path';
import { map, fromNode } from 'bluebird';
import glob from 'glob-all';

let findSourceFiles = async (patterns, cwd = fromRoot('.')) => {
const findSourceFiles = async (patterns, cwd = fromRoot('.')) => {
patterns = [].concat(patterns || []);

const matches = await fromNode(cb => {
Expand Down
8 changes: 4 additions & 4 deletions src/core_plugins/tests_bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default (kibana) => {
uiExports: {
bundle: async (UiBundle, env, apps, plugins) => {
let modules = [];
let config = kibana.config;
const config = kibana.config;

const testGlobs = ['src/ui/public/**/*.js'];
const testingPluginIds = config.get('tests_bundle.pluginId');
Expand All @@ -28,7 +28,7 @@ export default (kibana) => {
if (!plugin) throw new Error('Invalid testingPluginId :: unknown plugin ' + pluginId);

// add the modules from all of this plugins apps
for (let app of plugin.apps) {
for (const app of plugin.apps) {
modules = union(modules, app.getModules());
}

Expand All @@ -37,7 +37,7 @@ export default (kibana) => {
} else {

// add the modules from all of the apps
for (let app of apps) {
for (const app of apps) {
modules = union(modules, app.getModules());
}

Expand All @@ -47,7 +47,7 @@ export default (kibana) => {
}

const testFiles = await findSourceFiles(testGlobs);
for (let f of testFiles) modules.push(f);
for (const f of testFiles) modules.push(f);

if (config.get('tests_bundle.instrument')) {
env.addPostLoader({
Expand Down
Loading