diff --git a/.eslintignore b/.eslintignore index 2482278de75cc..94357790433f7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,9 @@ +/optimize +/src/fixtures/vislib/mock_data +/src/ui/public/angular-bootstrap +/test/fixtures/scenarios +/src/core_plugins/console/public/webpackShims +/src/core_plugins/console/public/tests/webpackShims /src/core_plugins/timelion/bower_components /src/core_plugins/timelion/vendor_components -test/fixtures/scenarios -optimize -test/fixtures/scenarios +/src/ui/public/utils/decode_geo_hash.js diff --git a/.eslintrc b/.eslintrc index 7a623df06a6ca..62b30dd6c68e7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,2 +1,5 @@ --- extends: '@elastic/kibana' +rules: + object-curly-spacing: [error, always] + no-global-assign: [error] diff --git a/Gruntfile.js b/Gruntfile.js index d4246608d8d21..0b015febc9515 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,4 +1,3 @@ -const camelCase = require('lodash').camelCase; require('babel/register')(require('./src/optimize/babel_options').node); module.exports = function (grunt) { @@ -39,17 +38,6 @@ module.exports = function (grunt) { ' Licensed <%= package.license %> */\n' }, - lintThese: [ - 'Gruntfile.js', - '<%= root %>/tasks/**/*.js', - '<%= root %>/test/**/*.js', - '<%= src %>/**/*.js', - '!<%= src %>/ui/public/angular-bootstrap/**/*.js', - '!<%= src %>/core_plugins/timelion/bower_components/**/*.js', - '!<%= src %>/core_plugins/timelion/vendor_components/**/*.js', - '!<%= src %>/fixtures/**/*.js', - '!<%= root %>/test/fixtures/scenarios/**/*.js' - ], deepModules: { 'caniuse-db': '1.0.30000265', 'chalk': '1.1.0', diff --git a/package.json b/package.json index b5425331a79c5..7dac431a9e428 100644 --- a/package.json +++ b/package.json @@ -163,16 +163,16 @@ "wreck": "6.2.0" }, "devDependencies": { - "@elastic/eslint-config-kibana": "0.0.3", + "@elastic/eslint-config-kibana": "0.2.0", "angular-mocks": "1.4.7", "auto-release-sinon": "1.0.3", - "babel-eslint": "4.1.8", "chai": "3.5.0", + "babel-eslint": "6.1.2", "chokidar": "1.6.0", "chromedriver": "2.24.1", "elasticdump": "2.1.1", - "eslint": "1.10.3", - "eslint-plugin-mocha": "1.1.0", + "eslint": "3.3.1", + "eslint-plugin-mocha": "4.4.0", "event-stream": "3.3.2", "expect.js": "0.3.1", "faker": "1.1.0", @@ -186,7 +186,7 @@ "grunt-karma": "2.0.0", "grunt-run": "0.6.0", "grunt-simple-mocha": "0.4.0", - "gruntify-eslint": "1.0.1", + "gruntify-eslint": "3.0.0", "gulp-sourcemaps": "1.7.3", "handlebars": "4.0.5", "husky": "0.8.1", diff --git a/src/cli/cli.js b/src/cli/cli.js index f25608dec1cf7..b53dc922b67b0 100644 --- a/src/cli/cli.js +++ b/src/cli/cli.js @@ -27,7 +27,7 @@ program program .command('*', null, { noHelp: true }) -.action(function (cmd, options) { +.action(function (cmd) { program.error(`unknown command ${cmd}`); }); diff --git a/src/cli/cluster/__tests__/_mock_cluster_fork.js b/src/cli/cluster/__tests__/_mock_cluster_fork.js index 2671ca08bdb9a..0915d172a4cd6 100644 --- a/src/cli/cluster/__tests__/_mock_cluster_fork.js +++ b/src/cli/cluster/__tests__/_mock_cluster_fork.js @@ -24,7 +24,7 @@ export default class MockClusterFork extends EventEmitter { dead = true; this.emit('exit'); cluster.emit('exit', this, this.exitCode || 0); - }()); + })(); }), }, isDead: sinon.spy(() => dead), @@ -39,6 +39,6 @@ export default class MockClusterFork extends EventEmitter { await wait(); dead = false; this.emit('online'); - }()); + })(); } } diff --git a/src/cli/cluster/__tests__/cluster_manager.js b/src/cli/cluster/__tests__/cluster_manager.js index ae9ef7080981a..13184056c2b28 100644 --- a/src/cli/cluster/__tests__/cluster_manager.js +++ b/src/cli/cluster/__tests__/cluster_manager.js @@ -1,8 +1,7 @@ import expect from 'expect.js'; import sinon from 'auto-release-sinon'; import cluster from 'cluster'; -import { ChildProcess } from 'child_process'; -import { sample, difference } from 'lodash'; +import { sample } from 'lodash'; import ClusterManager from '../cluster_manager'; import Worker from '../worker'; diff --git a/src/cli/cluster/__tests__/worker.js b/src/cli/cluster/__tests__/worker.js index 4d8f4f53af148..b84b92d76e460 100644 --- a/src/cli/cluster/__tests__/worker.js +++ b/src/cli/cluster/__tests__/worker.js @@ -1,9 +1,7 @@ import expect from 'expect.js'; import sinon from 'auto-release-sinon'; import cluster from 'cluster'; -import { ChildProcess } from 'child_process'; -import { difference, findIndex, sample } from 'lodash'; -import { fromNode as fn } from 'bluebird'; +import { findIndex } from 'lodash'; import MockClusterFork from './_mock_cluster_fork'; import Worker from '../worker'; @@ -96,7 +94,7 @@ describe('CLI cluster manager', function () { describe('#parseIncomingMessage()', function () { context('on a started worker', function () { - it(`is bound to fork's message event`, async function () { + it('is bound to fork\'s message event', async function () { const worker = setup(); await worker.start(); sinon.assert.calledWith(worker.fork.on, 'message'); @@ -135,7 +133,6 @@ describe('CLI cluster manager', function () { context('when sent WORKER_LISTENING message', function () { it('sets the listening flag and emits the listening event', function () { const worker = setup(); - const data = {}; const stub = sinon.stub(worker, 'emit'); expect(worker).to.have.property('listening', false); worker.onMessage('WORKER_LISTENING'); diff --git a/src/cli/cluster/base_path_proxy.js b/src/cli/cluster/base_path_proxy.js index 4f8a3916166c9..b457a877efbe7 100644 --- a/src/cli/cluster/base_path_proxy.js +++ b/src/cli/cluster/base_path_proxy.js @@ -1,6 +1,6 @@ import { Server } from 'hapi'; import { notFound } from 'boom'; -import { merge, sample } from 'lodash'; +import { sample } from 'lodash'; import { format as formatUrl } from 'url'; import { map, fromNode } from 'bluebird'; import { Agent as HttpsAgent } from 'https'; @@ -106,9 +106,9 @@ export default class BasePathProxy { server.route({ method: '*', - path: `/{oldBasePath}/{kbnPath*}`, + 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; diff --git a/src/cli/cluster/cluster_manager.js b/src/cli/cluster/cluster_manager.js index 80b183cd663a6..f496bc9351ed6 100644 --- a/src/cli/cluster/cluster_manager.js +++ b/src/cli/cluster/cluster_manager.js @@ -1,12 +1,10 @@ -import cluster from 'cluster'; -const { join, resolve } = require('path'); -const { format: formatUrl } = require('url'); -import Hapi from 'hapi'; -const { debounce, compact, get, invoke, bindAll, once, sample, uniq } = require('lodash'); +import { resolve } from 'path'; +import { debounce, invoke, bindAll, once, uniq } from 'lodash'; import Log from '../log'; import Worker from './worker'; import BasePathProxy from './base_path_proxy'; +import fromRoot from '../../utils/from_root'; process.env.kbnWorkerType = 'managr'; @@ -84,21 +82,17 @@ module.exports = class ClusterManager { setupWatching(extraPaths) { const chokidar = require('chokidar'); - const fromRoot = require('../../utils/from_root'); - - const watchPaths = uniq( - [ - fromRoot('src/core_plugins'), - fromRoot('src/server'), - fromRoot('src/ui'), - fromRoot('src/utils'), - fromRoot('config'), - ...extraPaths - ] - .map(path => resolve(path)) - ); - - this.watcher = chokidar.watch(watchPaths, { + + const watchPaths = [ + fromRoot('src/core_plugins'), + fromRoot('src/server'), + fromRoot('src/ui'), + fromRoot('src/utils'), + fromRoot('config'), + ...extraPaths + ].map(path => resolve(path)); + + this.watcher = chokidar.watch(uniq(watchPaths), { cwd: fromRoot('.'), ignored: /[\\\/](\..*|node_modules|bower_components|public|__tests__)[\\\/]/ }); @@ -127,7 +121,7 @@ module.exports = class ClusterManager { rl.setPrompt(''); rl.prompt(); - rl.on('line', line => { + rl.on('line', () => { nls = nls + 1; if (nls >= 2) { diff --git a/src/cli/cluster/worker.js b/src/cli/cluster/worker.js index 4108627edea65..2c16ecf411154 100644 --- a/src/cli/cluster/worker.js +++ b/src/cli/cluster/worker.js @@ -1,20 +1,19 @@ import _ from 'lodash'; import cluster from 'cluster'; -import { resolve } from 'path'; 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; }; @@ -40,7 +39,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) @@ -124,8 +123,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}"`; }, ''); diff --git a/src/cli/command.js b/src/cli/command.js index 135d03e32b6c1..27e65a4e832d0 100644 --- a/src/cli/command.js +++ b/src/cli/command.js @@ -3,7 +3,6 @@ import _ from 'lodash'; import help from './help'; import { Command } from 'commander'; import { red } from './color'; -import { yellow } from './color'; Command.prototype.error = function (err) { if (err && err.message) err = err.message; @@ -40,15 +39,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 "--"`); } @@ -75,14 +74,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); diff --git a/src/cli/help.js b/src/cli/help.js index 89bc90a24cbd6..b5078aad458fe 100644 --- a/src/cli/help.js +++ b/src/cli/help.js @@ -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 ( ` @@ -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(' '); @@ -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); @@ -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 + ']'; } diff --git a/src/cli/log.js b/src/cli/log.js index bbbe3f2f21e89..584c27d5f9857 100644 --- a/src/cli/log.js +++ b/src/cli/log.js @@ -1,7 +1,6 @@ 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)); }); diff --git a/src/cli/serve/__tests__/read_yaml_config.js b/src/cli/serve/__tests__/read_yaml_config.js index 29b620b27dbb0..e5743445f7f87 100644 --- a/src/cli/serve/__tests__/read_yaml_config.js +++ b/src/cli/serve/__tests__/read_yaml_config.js @@ -9,7 +9,7 @@ function fixture(name) { describe('cli/serve/read_yaml_config', function () { it('reads a single config file', function () { - const config = readYamlConfig(fixture('one.yml')); + readYamlConfig(fixture('one.yml')); expect(readYamlConfig(fixture('one.yml'))).to.eql({ foo: 1, diff --git a/src/cli/serve/__tests__/reload_logging_config.js b/src/cli/serve/__tests__/reload_logging_config.js index 721ebad27b84b..d0c7a032c889a 100644 --- a/src/cli/serve/__tests__/reload_logging_config.js +++ b/src/cli/serve/__tests__/reload_logging_config.js @@ -1,13 +1,13 @@ import { spawn } from 'child_process'; -import { writeFileSync, readFile } from 'fs'; +import { writeFileSync } from 'fs'; import { relative, resolve } from 'path'; import { safeDump } from 'js-yaml'; import es from 'event-stream'; import readYamlConfig from '../read_yaml_config'; import expect from 'expect.js'; -const testConfigFile = follow(`fixtures/reload_logging_config/kibana.test.yml`); -const cli = follow(`../../../../bin/kibana`); +const testConfigFile = follow('fixtures/reload_logging_config/kibana.test.yml'); +const cli = follow('../../../../bin/kibana'); function follow(file) { return relative(process.cwd(), resolve(__dirname, file)); @@ -22,19 +22,19 @@ function setLoggingJson(enabled) { return conf; } -describe(`Server logging configuration`, function () { +describe('Server logging configuration', function () { const isWindows = /^win/.test(process.platform); if (isWindows) { it('SIGHUP is not a feature of Windows.'); } else { - it(`should be reloadable via SIGHUP process signaling`, function (done) { + it('should be reloadable via SIGHUP process signaling', function (done) { this.timeout(60000); let asserted = false; let json = Infinity; - const conf = setLoggingJson(true); - const child = spawn(cli, [`--config`, testConfigFile]); + setLoggingJson(true); + const child = spawn(cli, ['--config', testConfigFile]); child.on('error', err => { done(new Error(`error in child process while attempting to reload config. ${err.stack || err.message || err}`)); @@ -62,7 +62,7 @@ describe(`Server logging configuration`, function () { function parseJsonLogLine(line) { try { const data = JSON.parse(line); - const listening = data.tags.indexOf(`listening`) !== -1; + const listening = data.tags.indexOf('listening') !== -1; if (listening) { switchToPlainTextLog(); } @@ -74,13 +74,13 @@ describe(`Server logging configuration`, function () { function switchToPlainTextLog() { json = 3; // ignore both "reloading" messages + ui settings status message setLoggingJson(false); - child.kill(`SIGHUP`); // reload logging config + child.kill('SIGHUP'); // reload logging config } function expectPlainTextLogLine(line) { // assert - const tags = `[\u001b[32minfo\u001b[39m][\u001b[36mconfig\u001b[39m]`; - const status = `Reloaded logging configuration due to SIGHUP.`; + const tags = '[\u001b[32minfo\u001b[39m][\u001b[36mconfig\u001b[39m]'; + const status = 'Reloaded logging configuration due to SIGHUP.'; const expected = `${tags} ${status}`; const actual = line.slice(-expected.length); expect(actual).to.eql(expected); diff --git a/src/cli/serve/deprecated_config.js b/src/cli/serve/deprecated_config.js index d0ec271a8cee8..d5203ada10c78 100644 --- a/src/cli/serve/deprecated_config.js +++ b/src/cli/serve/deprecated_config.js @@ -1,4 +1,4 @@ -import { forOwn, has, noop } from 'lodash'; +import { has, noop } from 'lodash'; // deprecated settings are still allowed, but will be removed at a later time. They // are checked for after the config object is prepared and known, so legacySettings diff --git a/src/cli/serve/read_yaml_config.js b/src/cli/serve/read_yaml_config.js index 18e3a4520e875..4cf1f2c2a3d9b 100644 --- a/src/cli/serve/read_yaml_config.js +++ b/src/cli/serve/read_yaml_config.js @@ -1,9 +1,8 @@ -import { chain, isArray, isPlainObject, forOwn, memoize, set, transform } from 'lodash'; +import { isArray, isPlainObject, forOwn, memoize, set, transform } from 'lodash'; import { readFileSync as read } from 'fs'; import { safeLoad } from 'js-yaml'; import { red } from 'ansicolors'; -import { fromRoot } from '../../utils'; import { rewriteLegacyConfig } from './legacy_config'; import { checkForDeprecatedConfig } from './deprecated_config'; diff --git a/src/cli_plugin/cli.js b/src/cli_plugin/cli.js index 5a09416a9cb1a..5d3dd2f702267 100644 --- a/src/cli_plugin/cli.js +++ b/src/cli_plugin/cli.js @@ -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) @@ -23,19 +23,19 @@ program .command('help ') .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(); }); program .command('*', null, { noHelp: true }) -.action(function (cmd, options) { +.action(function (cmd) { program.error(`unknown command ${cmd}`); }); // 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(); } diff --git a/src/cli_plugin/install/__tests__/cleanup.js b/src/cli_plugin/install/__tests__/cleanup.js index c8812c8dedf8f..27ebda2363883 100644 --- a/src/cli_plugin/install/__tests__/cleanup.js +++ b/src/cli_plugin/install/__tests__/cleanup.js @@ -16,21 +16,14 @@ describe('kibana cli', function () { }; describe('cleanPrevious', function () { - let cleaner; let errorStub; let logger; - let progress; - let request; beforeEach(function () { errorStub = sinon.stub(); logger = new Logger(settings); sinon.stub(logger, 'log'); sinon.stub(logger, 'error'); - request = { - abort: sinon.stub(), - emit: sinon.stub() - }; }); afterEach(function () { @@ -50,7 +43,7 @@ describe('kibana cli', function () { return cleanPrevious(settings, logger) .catch(errorStub) - .then(function (data) { + .then(function () { expect(errorStub.called).to.be(false); }); }); @@ -76,7 +69,7 @@ describe('kibana cli', function () { return cleanPrevious(settings, logger) .catch(errorStub) - .then(function (data) { + .then(function () { expect(logger.log.calledWith('Found previous install attempt. Deleting...')).to.be(true); }); }); @@ -101,19 +94,14 @@ describe('kibana cli', function () { return cleanPrevious(settings, logger) .catch(errorStub) - .then(function (data) { + .then(function () { expect(errorStub.called).to.be(false); }); }); - }); describe('cleanArtifacts', function () { - let logger; - - beforeEach(function () { - logger = new Logger(settings); - }); + beforeEach(function () {}); afterEach(function () { rimraf.sync.restore(); @@ -133,7 +121,6 @@ describe('kibana cli', function () { expect(cleanArtifacts).withArgs(settings).to.not.throwError(); }); - }); }); diff --git a/src/cli_plugin/install/__tests__/download.js b/src/cli_plugin/install/__tests__/download.js index d38728fe25578..eb2b52de1325e 100644 --- a/src/cli_plugin/install/__tests__/download.js +++ b/src/cli_plugin/install/__tests__/download.js @@ -62,7 +62,7 @@ describe('kibana cli', function () { describe('http downloader', function () { it('should throw an ENOTFOUND error for a http ulr that returns 404', function () { - const couchdb = nock('http://example.com') + nock('http://example.com') .get('/plugin.tar.gz') .reply(404); @@ -88,7 +88,7 @@ describe('kibana cli', function () { it('should download a file from a valid http url', function () { const filePath = join(__dirname, 'replies/banana.jpg'); - const couchdb = nock('http://example.com') + nock('http://example.com') .defaultReplyHeaders({ 'content-length': '341965', 'content-type': 'application/zip' @@ -143,7 +143,7 @@ describe('kibana cli', function () { 'http://example.com/goodfile.tar.gz' ]; - const couchdb = nock('http://example.com') + nock('http://example.com') .defaultReplyHeaders({ 'content-length': '10' }) @@ -173,7 +173,7 @@ describe('kibana cli', function () { 'http://example.com/badfile3.tar.gz' ]; - const couchdb = nock('http://example.com') + nock('http://example.com') .defaultReplyHeaders({ 'content-length': '10' }) @@ -202,7 +202,7 @@ describe('kibana cli', function () { 'http://example.com/badfile3.tar.gz' ]; - const couchdb = nock('http://example.com') + nock('http://example.com') .defaultReplyHeaders({ 'content-length': '10' }) diff --git a/src/cli_plugin/install/__tests__/index.js b/src/cli_plugin/install/__tests__/index.js index 470d9452a1c12..701247a49492e 100644 --- a/src/cli_plugin/install/__tests__/index.js +++ b/src/cli_plugin/install/__tests__/index.js @@ -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; }, diff --git a/src/cli_plugin/install/__tests__/pack.js b/src/cli_plugin/install/__tests__/pack.js index 39a61e58a93d6..0bd194b3212db 100644 --- a/src/cli_plugin/install/__tests__/pack.js +++ b/src/cli_plugin/install/__tests__/pack.js @@ -173,7 +173,7 @@ describe('kibana cli', function () { it('throw an error if there is no kibana plugin', function () { return copyReplyFile('test_plugin_no_kibana.zip') - .then((data) => { + .then(() => { return getPackData(settings, logger); }) .then(shouldReject, (err) => { @@ -183,7 +183,7 @@ describe('kibana cli', function () { it('throw an error with a corrupt zip', function () { return copyReplyFile('corrupt.zip') - .then((data) => { + .then(() => { return getPackData(settings, logger); }) .then(shouldReject, (err) => { @@ -193,7 +193,7 @@ describe('kibana cli', function () { it('throw an error if there an invalid plugin name', function () { return copyReplyFile('invalid_name.zip') - .then((data) => { + .then(() => { return getPackData(settings, logger); }) .then(shouldReject, (err) => { diff --git a/src/cli_plugin/install/__tests__/progress.js b/src/cli_plugin/install/__tests__/progress.js index 15f4fd9a1bc18..40f0c60b6f88a 100644 --- a/src/cli_plugin/install/__tests__/progress.js +++ b/src/cli_plugin/install/__tests__/progress.js @@ -10,7 +10,6 @@ describe('kibana cli', function () { describe('progressReporter', function () { let logger; let progress; - let request; beforeEach(function () { logger = new Logger({ silent: false, quiet: false }); @@ -87,7 +86,6 @@ describe('kibana cli', function () { }); }); - }); }); diff --git a/src/cli_plugin/install/__tests__/settings.js b/src/cli_plugin/install/__tests__/settings.js index 8186e585788b2..080984c43fef6 100644 --- a/src/cli_plugin/install/__tests__/settings.js +++ b/src/cli_plugin/install/__tests__/settings.js @@ -1,8 +1,7 @@ -import path from 'path'; import expect from 'expect.js'; import { fromRoot } from '../../../utils'; import { resolve } from 'path'; -import { parseMilliseconds, parse, getPlatform } from '../settings'; +import { parseMilliseconds, parse } from '../settings'; describe('kibana cli', function () { diff --git a/src/cli_plugin/install/__tests__/zip.js b/src/cli_plugin/install/__tests__/zip.js index f6e61d320f6aa..8bb3345e0c531 100644 --- a/src/cli_plugin/install/__tests__/zip.js +++ b/src/cli_plugin/install/__tests__/zip.js @@ -20,7 +20,7 @@ describe('kibana cli', function () { workingPath: testWorkingPath, tempArchiveFile: tempArchiveFilePath, plugin: 'test-plugin', - setPlugin: function (plugin) {} + setPlugin: function () {} }; function shouldReject() { diff --git a/src/cli_plugin/install/cleanup.js b/src/cli_plugin/install/cleanup.js index 5e8f6fec58b30..e6b6a899126de 100644 --- a/src/cli_plugin/install/cleanup.js +++ b/src/cli_plugin/install/cleanup.js @@ -19,7 +19,7 @@ export function cleanPrevious(settings, logger) { resolve(); } }); -}; +} export function cleanArtifacts(settings) { // delete the working directory. @@ -29,4 +29,4 @@ export function cleanArtifacts(settings) { rimraf.sync(settings.plugins[0].path); } catch (e) {} // eslint-disable-line no-empty -}; +} diff --git a/src/cli_plugin/install/download.js b/src/cli_plugin/install/download.js index 871b170628fe8..9083d38a338ea 100644 --- a/src/cli_plugin/install/download.js +++ b/src/cli_plugin/install/download.js @@ -42,4 +42,4 @@ export function download(settings, logger) { } return tryNext(); -}; +} diff --git a/src/cli_plugin/install/downloaders/file.js b/src/cli_plugin/install/downloaders/file.js index 505a103755e66..6a89f4c60338d 100644 --- a/src/cli_plugin/install/downloaders/file.js +++ b/src/cli_plugin/install/downloaders/file.js @@ -1,9 +1,9 @@ import Progress from '../progress'; -import { createWriteStream, createReadStream, unlinkSync, statSync } from 'fs'; +import { createWriteStream, createReadStream, statSync } from 'fs'; function openSourceFile({ sourcePath }) { try { - let fileInfo = statSync(sourcePath); + const fileInfo = statSync(sourcePath); const readStream = createReadStream(sourcePath); diff --git a/src/cli_plugin/install/downloaders/http.js b/src/cli_plugin/install/downloaders/http.js index 40069c4cd063e..f8c28d65b7733 100644 --- a/src/cli_plugin/install/downloaders/http.js +++ b/src/cli_plugin/install/downloaders/http.js @@ -1,7 +1,7 @@ import Wreck from 'wreck'; import Progress from '../progress'; import { fromNode as fn } from 'bluebird'; -import { createWriteStream, unlinkSync } from 'fs'; +import { createWriteStream } from 'fs'; function sendRequest({ sourceUrl, timeout }) { const maxRedirects = 11; //Because this one goes to 11. @@ -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); diff --git a/src/cli_plugin/install/index.js b/src/cli_plugin/install/index.js index c42b3ad687884..d34160ff82c2f 100644 --- a/src/cli_plugin/install/index.js +++ b/src/cli_plugin/install/index.js @@ -1,11 +1,9 @@ import { fromRoot } from '../../utils'; -import fs from 'fs'; import install from './install'; import Logger from '../lib/logger'; import pkg from '../../utils/package_json'; import { getConfig } from '../../server/path'; import { parse, parseMilliseconds } from './settings'; -import { find } from 'lodash'; import logWarnings from '../lib/log_warnings'; function processCommand(command, options) { @@ -49,4 +47,4 @@ export default function pluginInstall(program) { install file:///Path/to/my/x-pack.zip install https://path.to/my/x-pack.zip`) .action(processCommand); -}; +} diff --git a/src/cli_plugin/install/kibana.js b/src/cli_plugin/install/kibana.js index 11738a53277b3..07db2cf6dea77 100644 --- a/src/cli_plugin/install/kibana.js +++ b/src/cli_plugin/install/kibana.js @@ -50,7 +50,7 @@ export async function rebuildCache(settings, logger) { export function assertVersion(settings) { if (!settings.plugins[0].kibanaVersion) { - throw new Error (`Plugin package.json is missing both a version property (required) and a kibana.version property (optional).`); + throw new Error ('Plugin package.json is missing both a version property (required) and a kibana.version property (optional).'); } const actual = cleanVersion(settings.plugins[0].kibanaVersion); diff --git a/src/cli_plugin/install/pack.js b/src/cli_plugin/install/pack.js index 76056523a3121..669c4c64bd88f 100644 --- a/src/cli_plugin/install/pack.js +++ b/src/cli_plugin/install/pack.js @@ -17,7 +17,7 @@ async function listPackages(settings) { .map(file => file.replace(/\\/g, '/')) .map(file => file.match(regExp)) .compact() - .map(([ file, _, folder ]) => ({ file, folder })) + .map(([ file, , folder ]) => ({ file, folder })) .uniq() .value(); } @@ -140,4 +140,4 @@ export async function extract(settings, logger) { logger.error(err); throw new Error('Error extracting plugin archive'); } -}; +} diff --git a/src/cli_plugin/install/progress.js b/src/cli_plugin/install/progress.js index dca7f9a2b88fc..f0e8424852b5e 100644 --- a/src/cli_plugin/install/progress.js +++ b/src/cli_plugin/install/progress.js @@ -32,7 +32,7 @@ export default class Progress { } complete() { - this.logger.log(`Transfer complete`, false); + this.logger.log('Transfer complete', false); } } diff --git a/src/cli_plugin/install/settings.js b/src/cli_plugin/install/settings.js index 6c09aff47d721..628ae5b72203d 100644 --- a/src/cli_plugin/install/settings.js +++ b/src/cli_plugin/install/settings.js @@ -1,7 +1,5 @@ import expiry from 'expiry-js'; -import { intersection } from 'lodash'; import { resolve } from 'path'; -import { arch, platform } from 'os'; function generateUrls({ version, plugin }) { return [ @@ -21,7 +19,7 @@ export function parseMilliseconds(val) { } return result; -}; +} export function parse(command, options, kbnPackage) { const settings = { @@ -44,4 +42,4 @@ export function parse(command, options, kbnPackage) { }; return settings; -}; +} diff --git a/src/cli_plugin/lib/errors.js b/src/cli_plugin/lib/errors.js index 9bcdac145ca55..3a06950c5af8a 100644 --- a/src/cli_plugin/lib/errors.js +++ b/src/cli_plugin/lib/errors.js @@ -1 +1 @@ -export class UnsupportedProtocolError extends Error {}; +export class UnsupportedProtocolError extends Error {} diff --git a/src/cli_plugin/lib/logger.js b/src/cli_plugin/lib/logger.js index 16bc15f33e026..13adcd2201cec 100644 --- a/src/cli_plugin/lib/logger.js +++ b/src/cli_plugin/lib/logger.js @@ -41,6 +41,6 @@ export default class Logger { } process.stderr.write(`${data}\n`); this.previousLineEnded = true; - }; + } } diff --git a/src/cli_plugin/list/__tests__/settings.js b/src/cli_plugin/list/__tests__/settings.js index ebfb245dc8c29..433037c12114b 100644 --- a/src/cli_plugin/list/__tests__/settings.js +++ b/src/cli_plugin/list/__tests__/settings.js @@ -1,8 +1,6 @@ -import path from 'path'; import expect from 'expect.js'; import fromRoot from '../../../utils/from_root'; -import { resolve } from 'path'; -import { parseMilliseconds, parse } from '../settings'; +import { parse } from '../settings'; describe('kibana cli', function () { diff --git a/src/cli_plugin/list/index.js b/src/cli_plugin/list/index.js index 1efe265902472..72e0ddc5ae2b9 100644 --- a/src/cli_plugin/list/index.js +++ b/src/cli_plugin/list/index.js @@ -29,4 +29,4 @@ export default function pluginList(program) { ) .description('list installed plugins') .action(processCommand); -}; +} diff --git a/src/cli_plugin/list/settings.js b/src/cli_plugin/list/settings.js index f372bfc0d35eb..b4f59581c08f0 100644 --- a/src/cli_plugin/list/settings.js +++ b/src/cli_plugin/list/settings.js @@ -1,9 +1,7 @@ -import { resolve } from 'path'; - -export function parse(command, options) { +export function parse(command) { const settings = { pluginDir: command.pluginDir || '' }; return settings; -}; +} diff --git a/src/cli_plugin/remove/__tests__/settings.js b/src/cli_plugin/remove/__tests__/settings.js index f29aa9d6e33c6..0d031f820829f 100644 --- a/src/cli_plugin/remove/__tests__/settings.js +++ b/src/cli_plugin/remove/__tests__/settings.js @@ -1,8 +1,6 @@ -import path from 'path'; import expect from 'expect.js'; import fromRoot from '../../../utils/from_root'; -import { resolve } from 'path'; -import { parseMilliseconds, parse } from '../settings'; +import { parse } from '../settings'; describe('kibana cli', function () { diff --git a/src/cli_plugin/remove/index.js b/src/cli_plugin/remove/index.js index 425112a35045e..f8133c99201ed 100644 --- a/src/cli_plugin/remove/index.js +++ b/src/cli_plugin/remove/index.js @@ -39,4 +39,4 @@ export default function pluginRemove(program) { `common examples: remove x-pack`) .action(processCommand); -}; +} diff --git a/src/cli_plugin/remove/settings.js b/src/cli_plugin/remove/settings.js index 7e7ed37d2e5a9..105902687b355 100644 --- a/src/cli_plugin/remove/settings.js +++ b/src/cli_plugin/remove/settings.js @@ -12,4 +12,4 @@ export function parse(command, options) { settings.pluginPath = resolve(settings.pluginDir, settings.plugin); return settings; -}; +} diff --git a/src/core_plugins/console/.eslintrc b/src/core_plugins/console/.eslintrc index c5fcfc4ff6fda..f539f6cd5878f 100644 --- a/src/core_plugins/console/.eslintrc +++ b/src/core_plugins/console/.eslintrc @@ -1,34 +1,36 @@ --- root: true -extends: '@elastic/kibana' +extends: '../../../.eslintrc' rules: - block-scoped-var: [0] - camelcase: [0] - curly: [0] - dot-location: [0] - dot-notation: [0] - eqeqeq: [0] - guard-for-in: [0] - indent: [0] - max-len: [0] - new-cap: [0] - no-caller: [0] - no-empty: [0] - no-extend-native: [0] - no-loop-func: [0] - no-multi-str: [0] - no-nested-ternary: [0] - no-proto: [0] - no-sequences: [0] - no-undef: [0] - no-use-before-define: [0] - one-var: [0] - quotes: [0] - space-before-blocks: [0] - space-in-parens: [0] - space-infix-ops: [0] - semi: [0] - strict: [0] - wrap-iife: [0] + block-scoped-var: off + camelcase: off + curly: off + dot-location: off + dot-notation: off + eqeqeq: off + guard-for-in: off + indent: off + max-len: off + new-cap: off + no-caller: off + no-empty: off + no-extend-native: off + no-loop-func: off + no-multi-str: off + no-nested-ternary: off + no-proto: off + no-sequences: off + no-undef: off + no-use-before-define: off + one-var: off + quotes: off + space-before-blocks: off + space-in-parens: off + space-infix-ops: off + semi: off + strict: off + wrap-iife: off + no-var: off + prefer-const: off diff --git a/src/core_plugins/console/api_server/api.js b/src/core_plugins/console/api_server/api.js index 7b1f4f2acd36e..f52525a92f46f 100644 --- a/src/core_plugins/console/api_server/api.js +++ b/src/core_plugins/console/api_server/api.js @@ -1,4 +1,4 @@ -const _ = require("lodash"); +import _ from "lodash"; 'use strict'; diff --git a/src/core_plugins/console/api_server/es_5_0.js b/src/core_plugins/console/api_server/es_5_0.js index 99c9b1c25b6f8..d91f986fba8a0 100644 --- a/src/core_plugins/console/api_server/es_5_0.js +++ b/src/core_plugins/console/api_server/es_5_0.js @@ -28,7 +28,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) { diff --git a/src/core_plugins/console/api_server/es_5_0/aggregations.js b/src/core_plugins/console/api_server/es_5_0/aggregations.js index 5dbd0ee21b8ac..aa653f1beec75 100644 --- a/src/core_plugins/console/api_server/es_5_0/aggregations.js +++ b/src/core_plugins/console/api_server/es_5_0/aggregations.js @@ -1,12 +1,12 @@ var simple_metric = { - __template: {field: ""}, + __template: { field: "" }, field: "{field}", missing: 0, script: { // populated by a global rule } }, field_metric = { - __template: {field: ""}, + __template: { field: "" }, field: "{field}" }, gap_policy = { __one_of: ["skip", "insert_zeros"] @@ -51,9 +51,9 @@ var rules = { } }, "filters": { - "*": {__scope_link: "GLOBAL.filter"} + "*": { __scope_link: "GLOBAL.filter" } }, - "other_bucket": {__one_of: [true, false]}, + "other_bucket": { __one_of: [true, false] }, "other_bucket_key": "" }, "missing": field_metric, @@ -81,9 +81,9 @@ var rules = { __template: { "_term": "asc" }, - "_term": {__one_of: ["asc", "desc"]}, - "_count": {__one_of: ["asc", "desc"]}, - "*": {__one_of: ["asc", "desc"]} + "_term": { __one_of: ["asc", "desc"] }, + "_count": { __one_of: ["asc", "desc"] }, + "*": { __one_of: ["asc", "desc"] } }, "min_doc_count": 10, "script": { @@ -91,9 +91,9 @@ var rules = { }, "include": ".*", "exclude": ".*", - "execution_hint": {__one_of: ["map", "global_ordinals", "global_ordinals_hash", "global_ordinals_low_cardinality"]}, - "show_term_doc_count_error": {__one_of: [true, false]}, - "collect_mode": {__one_of: ["depth_first", "breadth_first"]}, + "execution_hint": { __one_of: ["map", "global_ordinals", "global_ordinals_hash", "global_ordinals_low_cardinality"] }, + "show_term_doc_count_error": { __one_of: [true, false] }, + "collect_mode": { __one_of: ["depth_first", "breadth_first"] }, "missing": "" }, "significant_terms": { @@ -105,22 +105,22 @@ var rules = { "shard_size": 10, "shard_min_doc_count": 10, "min_doc_count": 10, - "include": {__one_of: ["*", {pattern: "", flags: ""}]}, - "exclude": {__one_of: ["*", {pattern: "", flags: ""}]}, - "execution_hint": {__one_of: ["map", "global_ordinals", "global_ordinals_hash"]}, + "include": { __one_of: ["*", { pattern: "", flags: "" }] }, + "exclude": { __one_of: ["*", { pattern: "", flags: "" }] }, + "execution_hint": { __one_of: ["map", "global_ordinals", "global_ordinals_hash"] }, "background_filter": { __scope_link: "GLOBAL.filter" }, "mutual_information": { - "include_negatives": {__one_of: [true, false]} + "include_negatives": { __one_of: [true, false] } }, "chi_square": { - "include_negatives": {__one_of: [true, false]}, - "background_is_superset": {__one_of: [true, false]} + "include_negatives": { __one_of: [true, false] }, + "background_is_superset": { __one_of: [true, false] } }, "percentage": {}, "gnd": { - "background_is_superset": {__one_of: [true, false]} + "background_is_superset": { __one_of: [true, false] } }, "script_heuristic": { __template: { @@ -135,14 +135,14 @@ var rules = { __template: { "field": "", "ranges": [ - {"from": 50, "to": 100}, + { "from": 50, "to": 100 }, ] }, "field": "{field}", "ranges": [ - {"to": 50, "from": 100, "key": ""} + { "to": 50, "from": 100, "key": "" } ], - "keyed": {__one_of: [true, false]}, + "keyed": { __one_of: [true, false] }, "script": { // populated by a global rule } @@ -151,15 +151,15 @@ var rules = { __template: { "field": "", "ranges": [ - {"from": "now-10d/d", "to": "now"}, + { "from": "now-10d/d", "to": "now" }, ] }, "field": "{field}", "format": "MM-yyy", "ranges": [ - {"to": "", "from": "", "key": ""} + { "to": "", "from": "", "key": "" } ], - "keyed": {__one_of: [true, false]}, + "keyed": { __one_of: [true, false] }, "script": { // populated by a global rule } @@ -168,15 +168,15 @@ var rules = { __template: { "field": "", "ranges": [ - {"from": "10.0.0.5", "to": "10.0.0.10"}, + { "from": "10.0.0.5", "to": "10.0.0.10" }, ] }, "field": "{field}", "format": "MM-yyy", "ranges": [ - {"to": "", "from": "", "key": "", "mask": "10.0.0.127/25"} + { "to": "", "from": "", "key": "", "mask": "10.0.0.127/25" } ], - "keyed": {__one_of: [true, false]}, + "keyed": { __one_of: [true, false] }, "script": { // populated by a global rule } @@ -193,11 +193,11 @@ var rules = { __template: { "_key": "asc" }, - "_key": {__one_of: ["asc", "desc"]}, - "_count": {__one_of: ["asc", "desc"]}, - "*": {__one_of: ["asc", "desc"]} + "_key": { __one_of: ["asc", "desc"] }, + "_count": { __one_of: ["asc", "desc"] }, + "*": { __one_of: ["asc", "desc"] } }, - "keyed": {__one_of: [true, false]}, + "keyed": { __one_of: [true, false] }, "missing": 0 }, "date_histogram": { @@ -206,20 +206,20 @@ var rules = { "interval": "month" }, "field": "{field}", - "interval": {__one_of: ["year", "quarter", "week", "day", "hour", "minute", "second"]}, + "interval": { __one_of: ["year", "quarter", "week", "day", "hour", "minute", "second"] }, "min_doc_count": 0, "order": { __template: { "_key": "asc" }, - "_key": {__one_of: ["asc", "desc"]}, - "_count": {__one_of: ["asc", "desc"]}, - "*": {__one_of: ["asc", "desc"]} + "_key": { __one_of: ["asc", "desc"] }, + "_count": { __one_of: ["asc", "desc"] }, + "*": { __one_of: ["asc", "desc"] } }, - "keyed": {__one_of: [true, false]}, + "keyed": { __one_of: [true, false] }, "pre_zone": "-01:00", "post_zone": "-01:00", - "pre_zone_adjust_large_interval": {__one_of: [true, false]}, + "pre_zone_adjust_large_interval": { __one_of: [true, false] }, "factor": 1000, "pre_offset": "1d", "post_offset": "1d", @@ -230,18 +230,18 @@ var rules = { "geo_distance": { __template: { "field": "location", - "origin": {"lat": 52.3760, "lon": 4.894}, + "origin": { "lat": 52.3760, "lon": 4.894 }, "ranges": [ - {"from": 100, "to": 300}, + { "from": 100, "to": 300 }, ] }, "field": "{field}", - "origin": {"lat": 0.0, "lon": 0.0}, - "unit": {__one_of: ["mi", "km", "in", "yd", "m", "cm", "mm"]}, + "origin": { "lat": 0.0, "lon": 0.0 }, + "unit": { __one_of: ["mi", "km", "in", "yd", "m", "cm", "mm"] }, "ranges": [ - {"from": 50, "to": 100} + { "from": 50, "to": 100 } ], - "distance_type": {__one_of: ["arc", "sloppy_arc", "plane"]} + "distance_type": { __one_of: ["arc", "sloppy_arc", "plane"] } }, "geohash_grid": { @@ -250,7 +250,7 @@ var rules = { "precision": 3 }, "field": "{field}", - "precision": {__one_of: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]}, + "precision": { __one_of: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }, "size": 10, "shard_size": 10 }, @@ -269,7 +269,7 @@ var rules = { // populated by a global rule }, "compression": 100, - "method": {__one_of: ["hdr", "tdigest"]}, + "method": { __one_of: ["hdr", "tdigest"] }, missing: 0 }, "cardinality": { @@ -311,7 +311,7 @@ var rules = { field: "" }, field: "{field}", - wrap_longitude: {__one_of: [true, false]} + wrap_longitude: { __one_of: [true, false] } }, "top_hits": { __template: { @@ -324,7 +324,7 @@ var rules = { __scope_link: "_search.sort" }, highlight: {}, - explain: {__one_of: [true, false]}, + explain: { __one_of: [true, false] }, _source: { __template: "", __scope_link: "_search._source" @@ -333,7 +333,7 @@ var rules = { __scope_link: "_search.script_fields" }, docvalue_fields: ["{field}"], - version: {__one_of: [true, false]} + version: { __one_of: [true, false] } }, "percentile_ranks": { __template: { @@ -346,7 +346,7 @@ var rules = { // populated by a global rule }, "compression": 100, - "method": {__one_of: ["hdr", "tdigest"]}, + "method": { __one_of: ["hdr", "tdigest"] }, missing: 0 }, "sampler": { @@ -357,7 +357,7 @@ var rules = { }, "shard_size": 100, "max_docs_per_value": 3, - "execution_hint": {__one_of: ["map", "global_ordinals", "bytes_hash"]} + "execution_hint": { __one_of: ["map", "global_ordinals", "bytes_hash"] } }, "children": { __template: { @@ -378,9 +378,9 @@ var rules = { format: "", gap_policy: gap_policy, "window": 5, - model: {__one_of: ["simple", "linear", "ewma", "holt", "holt_winters"]}, + model: { __one_of: ["simple", "linear", "ewma", "holt", "holt_winters"] }, settings: { - type: {__one_of: ["add", "mult"]}, + type: { __one_of: ["add", "mult"] }, alpha: 0.5, beta: 0.5, gamma: 0.5, diff --git a/src/core_plugins/console/api_server/es_5_0/aliases.js b/src/core_plugins/console/api_server/es_5_0/aliases.js index 832a1ed8a3ae0..c17dee4aa0bd7 100644 --- a/src/core_plugins/console/api_server/es_5_0/aliases.js +++ b/src/core_plugins/console/api_server/es_5_0/aliases.js @@ -7,7 +7,7 @@ module.exports = function (api) { data_autocomplete_rules: { 'actions': { __template: [ - {'add': {'index': 'test1', 'alias': 'alias1'}} + { 'add': { 'index': 'test1', 'alias': 'alias1' } } ], __any_of: [ { diff --git a/src/core_plugins/console/api_server/es_5_0/cat.js b/src/core_plugins/console/api_server/es_5_0/cat.js index af8a496d63e4e..0da08cd066e0c 100644 --- a/src/core_plugins/console/api_server/es_5_0/cat.js +++ b/src/core_plugins/console/api_server/es_5_0/cat.js @@ -1,7 +1,7 @@ let _ = require("lodash"); function addSimpleCat(endpoint, api, params, patterns) { - var url_params = {"help": "__flag__", "v": "__flag__", "bytes": ["b"]}; + var url_params = { "help": "__flag__", "v": "__flag__", "bytes": ["b"] }; _.each(params || [], function (p) { if (_.isString(p)) { url_params[p] = "__flag__"; @@ -37,10 +37,10 @@ module.exports = function (api) { addSimpleCat('_cat/allocation', api, null, ['_cat/allocation', '_cat/allocation/{nodes}']); addSimpleCat('_cat/count', api); addSimpleCat('_cat/health', api, [ - {"ts": ["false", "true"]} + { "ts": ["false", "true"] } ]); addSimpleCat('_cat/indices', api, [ - {h: []}, + { h: [] }, "pri", ], ['_cat/indices', '_cat/indices/{indices}']); diff --git a/src/core_plugins/console/api_server/es_5_0/cluster.js b/src/core_plugins/console/api_server/es_5_0/cluster.js index a6519e81ed6e4..a29e45c6e1db2 100644 --- a/src/core_plugins/console/api_server/es_5_0/cluster.js +++ b/src/core_plugins/console/api_server/es_5_0/cluster.js @@ -38,11 +38,11 @@ module.exports = function (api) { persistent: { cluster: { routing: { - 'allocation.enable': {__one_of: ["all", "primaries", "new_primaries", "none"]}, - 'allocation.disk.threshold_enabled': {__one_of: [false, true]}, + 'allocation.enable': { __one_of: ["all", "primaries", "new_primaries", "none"] }, + 'allocation.disk.threshold_enabled': { __one_of: [false, true] }, 'allocation.disk.watermark.low': '85%', 'allocation.disk.watermark.high': '90%', - 'allocation.disk.include_relocations': {__one_of: [true, false]}, + 'allocation.disk.include_relocations': { __one_of: [true, false] }, 'allocation.disk.reroute_interval': '60s', 'allocation.exclude': { '_ip': "", @@ -68,11 +68,11 @@ module.exports = function (api) { 'values': [] } }, - 'allocation.allow_rebalance': {__one_of: ['always', 'indices_primaries_active', 'indices_all_active']}, + 'allocation.allow_rebalance': { __one_of: ['always', 'indices_primaries_active', 'indices_all_active'] }, 'allocation.cluster_concurrent_rebalance': 2, 'allocation.node_initial_primaries_recoveries': 4, 'allocation.node_concurrent_recoveries': 2, - 'allocation.same_shard.host': {__one_of: [false, true]} + 'allocation.same_shard.host': { __one_of: [false, true] } } }, indices: { @@ -121,7 +121,7 @@ module.exports = function (api) { index: "{index}", shard: 0, node: "{node}", - allow_primary: {__one_of: [true, false]} + allow_primary: { __one_of: [true, false] } }, allocate: { __template: { @@ -132,11 +132,11 @@ module.exports = function (api) { index: "{index}", shard: 0, node: "{node}", - allow_primary: {__one_of: [true, false]} + allow_primary: { __one_of: [true, false] } } } ], - dry_run: {__one_of: [true, false]} + dry_run: { __one_of: [true, false] } } }); }; diff --git a/src/core_plugins/console/api_server/es_5_0/document.js b/src/core_plugins/console/api_server/es_5_0/document.js index caf36cb33a5ac..47762ef5b757e 100644 --- a/src/core_plugins/console/api_server/es_5_0/document.js +++ b/src/core_plugins/console/api_server/es_5_0/document.js @@ -114,7 +114,7 @@ module.exports = function (api) { }, "doc": {}, "upsert": {}, - "scripted_upsert": {__one_of: [true, false]} + "scripted_upsert": { __one_of: [true, false] } } }); @@ -159,13 +159,13 @@ module.exports = function (api) { fields: [ "{field}" ], - offsets: {__one_of: [false, true]}, - payloads: {__one_of: [false, true]}, - positions: {__one_of: [false, true]}, - term_statistics: {__one_of: [true, false]}, - field_statistics: {__one_of: [false, true]}, + offsets: { __one_of: [false, true] }, + payloads: { __one_of: [false, true] }, + positions: { __one_of: [false, true] }, + term_statistics: { __one_of: [true, false] }, + field_statistics: { __one_of: [false, true] }, per_field_analyzer: { - __template: {"FIELD": ""}, + __template: { "FIELD": "" }, "{field}": "" }, routing: "", @@ -206,14 +206,14 @@ module.exports = function (api) { fields: [ "{field}" ], - offsets: {__one_of: [false, true]}, - payloads: {__one_of: [false, true]}, - positions: {__one_of: [false, true]}, - term_statistics: {__one_of: [true, false]}, - field_statistics: {__one_of: [false, true]}, - dfs: {__one_of: [true, false]}, + offsets: { __one_of: [false, true] }, + payloads: { __one_of: [false, true] }, + positions: { __one_of: [false, true] }, + term_statistics: { __one_of: [true, false] }, + field_statistics: { __one_of: [false, true] }, + dfs: { __one_of: [true, false] }, per_field_analyzer: { - __template: {"FIELD": ""}, + __template: { "FIELD": "" }, "{field}": "" }, routing: "", diff --git a/src/core_plugins/console/api_server/es_5_0/filter.js b/src/core_plugins/console/api_server/es_5_0/filter.js index 877c0495fc40a..bcaae01055144 100644 --- a/src/core_plugins/console/api_server/es_5_0/filter.js +++ b/src/core_plugins/console/api_server/es_5_0/filter.js @@ -260,7 +260,7 @@ filters.range = { lt: 20, time_zone: "+1:00", "format": "dd/MM/yyyy||yyyy", - execution: {__one_of: ["index", "fielddata"]} + execution: { __one_of: ["index", "fielddata"] } } }; diff --git a/src/core_plugins/console/api_server/es_5_0/indices.js b/src/core_plugins/console/api_server/es_5_0/indices.js index f65ee3d2fcc22..911ce48b950f5 100644 --- a/src/core_plugins/console/api_server/es_5_0/indices.js +++ b/src/core_plugins/console/api_server/es_5_0/indices.js @@ -108,7 +108,7 @@ module.exports = function (api) { tokenizer: "", char_filter: [], filter: [], - explain: {__one_of: [false, true]}, + explain: { __one_of: [false, true] }, attributes: [] } }); diff --git a/src/core_plugins/console/api_server/es_5_0/mappings.js b/src/core_plugins/console/api_server/es_5_0/mappings.js index 4bbfede64c5b9..93709de58657f 100644 --- a/src/core_plugins/console/api_server/es_5_0/mappings.js +++ b/src/core_plugins/console/api_server/es_5_0/mappings.js @@ -195,7 +195,7 @@ module.exports = function (api) { __scope_link: '_put_mapping.type.properties.field' } }, - copy_to: {__one_of: ['{field}', ['{field}']]}, + copy_to: { __one_of: ['{field}', ['{field}']] }, // nested include_in_parent: BOOLEAN, diff --git a/src/core_plugins/console/api_server/es_5_0/percolator.js b/src/core_plugins/console/api_server/es_5_0/percolator.js index 7f100f34511a8..100a0889a8ada 100644 --- a/src/core_plugins/console/api_server/es_5_0/percolator.js +++ b/src/core_plugins/console/api_server/es_5_0/percolator.js @@ -38,7 +38,7 @@ module.exports = function (api) { query: {}, filter: {}, size: 10, - track_scores: {__one_of: [true, false]}, + track_scores: { __one_of: [true, false] }, sort: "_score", aggs: {}, highlight: {} @@ -64,7 +64,7 @@ module.exports = function (api) { query: {}, filter: {}, size: 10, - track_scores: {__one_of: [true, false]}, + track_scores: { __one_of: [true, false] }, sort: "_score", aggs: {}, highlight: {} diff --git a/src/core_plugins/console/api_server/es_5_0/query.js b/src/core_plugins/console/api_server/es_5_0/query.js index 99e35f3a8110b..2b4d2ee48d7ba 100644 --- a/src/core_plugins/console/api_server/es_5_0/query.js +++ b/src/core_plugins/console/api_server/es_5_0/query.js @@ -120,7 +120,7 @@ module.exports = function (api) { __one_of: [true, false] }, tie_breaker: 0.0, - type: {__one_of: ['best_fields', 'most_fields', 'cross_fields', 'phrase', 'phrase_prefix']} + type: { __one_of: ['best_fields', 'most_fields', 'cross_fields', 'phrase', 'phrase_prefix'] } }, bool: { must: [ @@ -321,12 +321,12 @@ module.exports = function (api) { }, query: "", fields: ["{field}"], - default_operator: {__one_of: ["OR", "AND"]}, + default_operator: { __one_of: ["OR", "AND"] }, analyzer: "", flags: "OR|AND|PREFIX", - lowercase_expanded_terms: {__one_of: [true, false]}, + lowercase_expanded_terms: { __one_of: [true, false] }, locale: "ROOT", - lenient: {__one_of: [true, false]} + lenient: { __one_of: [true, false] } }, range: { __template: { @@ -606,8 +606,8 @@ module.exports = function (api) { ) ], boost: 1.0, - boost_mode: {__one_of: ["multiply", "replace", "sum", "avg", "max", "min"]}, - score_mode: {__one_of: ["multiply", "sum", "first", "avg", "max", "min"]}, + boost_mode: { __one_of: ["multiply", "replace", "sum", "avg", "max", "min"] }, + score_mode: { __one_of: ["multiply", "sum", "first", "avg", "max", "min"] }, max_boost: 10, min_score: 1.0 }, diff --git a/src/core_plugins/console/api_server/es_5_0/search.js b/src/core_plugins/console/api_server/es_5_0/search.js index db5efcf6b24ec..c2f1e7f72f6a2 100644 --- a/src/core_plugins/console/api_server/es_5_0/search.js +++ b/src/core_plugins/console/api_server/es_5_0/search.js @@ -112,9 +112,9 @@ module.exports = function (api) { "" ] }, - distance_type: {__one_of: ["sloppy_arc", "arc", "plane"]}, - sort_mode: {__one_of: ["min", "max", "avg"]}, - order: {__one_of: ["asc", "desc"]}, + distance_type: { __one_of: ["sloppy_arc", "arc", "plane"] }, + sort_mode: { __one_of: ["min", "max", "avg"] }, + order: { __one_of: ["asc", "desc"] }, unit: "km" } } @@ -173,7 +173,7 @@ module.exports = function (api) { }, stats: [''], timeout: "1s", - version: {__one_of: [true, false]} + version: { __one_of: [true, false] } } }); @@ -187,8 +187,8 @@ module.exports = function (api) { data_autocomplete_rules: { "template": { __one_of: [ - {__scope_link: "_search"}, - {__scope_link: "GLOBAL.script"} + { __scope_link: "_search" }, + { __scope_link: "GLOBAL.script" } ] }, "params": {} @@ -202,8 +202,8 @@ module.exports = function (api) { ], data_autocomplete_rules: { __one_of: [ - {"inline": {__scope_link: "_search"}}, - {__scope_link: "GLOBAL.script"} + { "inline": { __scope_link: "_search" } }, + { __scope_link: "GLOBAL.script" } ], "params": {} } diff --git a/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js b/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js index 4e681ea23cbd6..48dd04088e09c 100644 --- a/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js +++ b/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js @@ -9,7 +9,7 @@ module.exports = function (api) { }, data_autocomplete_rules: { indices: "*", - ignore_unavailable: {__one_of: [true, false]}, + ignore_unavailable: { __one_of: [true, false] }, include_global_state: false, rename_pattern: "index_(.+)", rename_replacement: "restored_index_$1" @@ -41,9 +41,9 @@ module.exports = function (api) { }, data_autocomplete_rules: { indices: "*", - ignore_unavailable: {__one_of: [true, false]}, - include_global_state: {__one_of: [true, false]}, - partial: {__one_of: [true, false]} + ignore_unavailable: { __one_of: [true, false] }, + include_global_state: { __one_of: [true, false] }, + partial: { __one_of: [true, false] } } }); @@ -57,36 +57,13 @@ module.exports = function (api) { }); - function getRepositoryType(context, editor) { - var iter = editor.iterForCurrentLoc(); - // for now just iterate back to the first "type" key - var t = iter.getCurrentToken(); - var type; - while (t && t.type.indexOf("url") < 0) { - if (t.type === 'variable' && t.value === '"type"') { - t = editor.parser.nextNonEmptyToken(iter); - if (!t || t.type !== "punctuation.colon") { - // weird place to be in, but safe choice.. - break; - } - t = editor.parser.nextNonEmptyToken(iter); - if (t && t.type === "string") { - type = t.value.replace(/"/g, ''); - } - break; - } - t = editor.parser.prevNonEmptyToken(iter); - } - return type; - } - api.addEndpointDescription('put_repository', { methods: ['PUT'], patterns: [ '_snapshot/{id}' ], data_autocomplete_rules: { - __template: {"type": ""}, + __template: { "type": "" }, "type": { __one_of: ["fs", "url", "s3", "hdfs"] @@ -101,7 +78,7 @@ module.exports = function (api) { location: "path" }, location: "path", - compress: {__one_of: [true, false]}, + compress: { __one_of: [true, false] }, concurrent_streams: 5, chunk_size: "10m", max_restore_bytes_per_sec: "20mb", @@ -129,7 +106,7 @@ module.exports = function (api) { base_path: "", concurrent_streams: 5, chunk_size: "10m", - compress: {__one_of: [true, false]} + compress: { __one_of: [true, false] } }, {// hdfs __condition: { @@ -140,10 +117,10 @@ module.exports = function (api) { }, uri: "", path: "some/path", - load_defaults: {__one_of: [true, false]}, + load_defaults: { __one_of: [true, false] }, conf_location: "cfg.xml", concurrent_streams: 5, - compress: {__one_of: [true, false]}, + compress: { __one_of: [true, false] }, chunk_size: "10m" } ] diff --git a/src/core_plugins/console/api_server/es_5_0/templates.js b/src/core_plugins/console/api_server/es_5_0/templates.js index 635256c3f6985..5646be3e4e252 100644 --- a/src/core_plugins/console/api_server/es_5_0/templates.js +++ b/src/core_plugins/console/api_server/es_5_0/templates.js @@ -19,9 +19,9 @@ module.exports = function (api) { ], data_autocomplete_rules: { template: 'index*', - warmers: {__scope_link: '_warmer'}, - mappings: {__scope_link: '_put_mapping'}, - settings: {__scope_link: '_put_settings'} + warmers: { __scope_link: '_warmer' }, + mappings: { __scope_link: '_put_mapping' }, + settings: { __scope_link: '_put_settings' } } }); }; diff --git a/src/core_plugins/console/index.js b/src/core_plugins/console/index.js index 3f1438ee915f5..9fa9cff9d7174 100644 --- a/src/core_plugins/console/index.js +++ b/src/core_plugins/console/index.js @@ -7,7 +7,6 @@ module.exports = function (kibana) { let modules = resolve(__dirname, 'public/webpackShims/'); let src = resolve(__dirname, 'public/src/'); let { existsSync } = require('fs'); - const { startsWith, endsWith } = require('lodash'); const apps = []; @@ -112,7 +111,7 @@ module.exports = function (kibana) { done(null, uri, filterHeaders(request.headers, requestHeadersWhitelist)) }, xforward: true, - onResponse(err, res, request, reply, settings, ttl) { + onResponse(err, res, request, reply) { if (err != null) { reply("Error connecting to '" + uri + "':\n\n" + err.message).type("text/plain").statusCode = 502; } else { @@ -151,7 +150,7 @@ module.exports = function (kibana) { method: ['GET', 'POST'], handler: function (req, reply) { let server = require('./api_server/server'); - let {sense_version, apis} = req.query; + let { sense_version, apis } = req.query; if (!apis) { reply(Boom.badRequest('"apis" is a required param.')); return; diff --git a/src/core_plugins/console/public/src/app.js b/src/core_plugins/console/public/src/app.js index aa3f098663279..4558fe41a83c4 100644 --- a/src/core_plugins/console/public/src/app.js +++ b/src/core_plugins/console/public/src/app.js @@ -1,10 +1,7 @@ var $ = require('jquery'); -let curl = require('./curl'); let history = require('./history'); let mappings = require('./mappings'); -let es = require('./es'); -let _ = require('lodash'); export default function init(input, output, sourceLocation = 'stored') { $(document.body).removeClass('fouc'); @@ -30,9 +27,9 @@ export default function init(input, output, sourceLocation = 'stored') { } } else if (/^https?:\/\//.test(sourceLocation)) { - var loadFrom = {url: sourceLocation, dataType: "text", kbnXsrfToken: false}; + var loadFrom = { url: sourceLocation, dataType: "text", kbnXsrfToken: false }; if (/https?:\/\/api.github.com/.test(sourceLocation)) { - loadFrom.headers = {Accept: "application/vnd.github.v3.raw"}; + loadFrom.headers = { Accept: "application/vnd.github.v3.raw" }; } $.ajax(loadFrom).done(function (data) { resetToValues(data); @@ -51,7 +48,7 @@ export default function init(input, output, sourceLocation = 'stored') { var timer; var saveDelay = 500; - input.getSession().on("change", function onChange(e) { + input.getSession().on("change", function onChange() { if (timer) { timer = clearTimeout(timer); } @@ -110,4 +107,4 @@ export default function init(input, output, sourceLocation = 'stored') { loadSavedState(); setupAutosave(); mappings.retrieveAutocompleteInfoFromServer(); -}; +} diff --git a/src/core_plugins/console/public/src/autocomplete.js b/src/core_plugins/console/public/src/autocomplete.js index 9eb83f4ad6574..d52087cb5d8b6 100644 --- a/src/core_plugins/console/public/src/autocomplete.js +++ b/src/core_plugins/console/public/src/autocomplete.js @@ -1,12 +1,9 @@ -let history = require('./history'); let kb = require('./kb'); -let mappings = require('./mappings'); let ace = require('ace'); let utils = require('./utils'); let autocomplete_engine = require('./autocomplete/engine'); let url_pattern_matcher = require('./autocomplete/url_pattern_matcher'); let _ = require('lodash'); -let ext_lang_tools = require('ace/ext-language_tools'); var AceRange = ace.require('ace/range').Range; @@ -76,23 +73,12 @@ module.exports = function (editor) { function addMetaToTermsList(list, meta, template) { return _.map(list, function (t) { if (typeof t !== "object") { - t = {name: t}; + t = { name: t }; } - return _.defaults(t, {meta: meta, template: template}); + return _.defaults(t, { meta: meta, template: template }); }); } - function termToFilterRegex(term, prefix, suffix) { - if (!prefix) { - prefix = ""; - } - if (!suffix) { - suffix = ""; - } - - return new RegExp(prefix + term.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + suffix, 'i'); - } - function applyTerm(term) { var session = editor.getSession(); @@ -165,13 +151,13 @@ module.exports = function (editor) { var nonEmptyToken = editor.parser.nextNonEmptyToken(tokenIter); switch (nonEmptyToken ? nonEmptyToken.type : "NOTOKEN") { case "paren.rparen": - newPos = {row: tokenIter.getCurrentTokenRow(), column: tokenIter.getCurrentTokenColumn()}; + newPos = { row: tokenIter.getCurrentTokenRow(), column: tokenIter.getCurrentTokenColumn() }; break; case "punctuation.colon": nonEmptyToken = editor.parser.nextNonEmptyToken(tokenIter); if ((nonEmptyToken || {}).type == "paren.lparen") { nonEmptyToken = editor.parser.nextNonEmptyToken(tokenIter); - newPos = {row: tokenIter.getCurrentTokenRow(), column: tokenIter.getCurrentTokenColumn()}; + newPos = { row: tokenIter.getCurrentTokenRow(), column: tokenIter.getCurrentTokenColumn() }; if (nonEmptyToken && nonEmptyToken.value.indexOf('"') === 0) { newPos.column++; } // don't stand on " @@ -180,7 +166,7 @@ module.exports = function (editor) { case "paren.lparen": case "punctuation.comma": tokenIter.stepForward(); - newPos = {row: tokenIter.getCurrentTokenRow(), column: tokenIter.getCurrentTokenColumn()}; + newPos = { row: tokenIter.getCurrentTokenRow(), column: tokenIter.getCurrentTokenColumn() }; break; } editor.moveCursorToPosition(newPos); @@ -320,11 +306,10 @@ module.exports = function (editor) { // - Nice token, broken before: {, "bla" var session = editor.getSession(); - var insertingRelativeToToken; context.updatedForToken = _.clone(session.getTokenAt(pos.row, pos.column)); if (!context.updatedForToken) { - context.updatedForToken = {value: "", start: pos.column}; + context.updatedForToken = { value: "", start: pos.column }; } // empty line var anchorToken = context.createdWithToken; @@ -373,7 +358,7 @@ module.exports = function (editor) { break; } - context.textBoxPosition = {row: context.rangeToReplace.start.row, column: context.rangeToReplace.start.column}; + context.textBoxPosition = { row: context.rangeToReplace.start.row, column: context.rangeToReplace.start.column }; switch (context.autoCompleteType) { case "path": @@ -511,9 +496,9 @@ module.exports = function (editor) { context.suffixToAdd = ""; } - function addMethodAutoCompleteSetToContext(context, pos) { + function addMethodAutoCompleteSetToContext(context) { context.autoCompleteSet = _.map(["GET", "PUT", "POST", "DELETE", "HEAD"], function (m, i) { - return {name: m, score: -i, meta: "method"} + return { name: m, score: -i, meta: "method" } }) } @@ -601,7 +586,7 @@ module.exports = function (editor) { function getCurrentMethodAndTokenPaths(pos) { var tokenIter = editor.iterForPosition(pos.row, pos.column); var startPos = pos; - var bodyTokenPath = [], last_var = "", first_scope = true, ret = {}; + var bodyTokenPath = [], ret = {}; var STATES = { looking_for_key: 0, // looking for a key but without jumping over anything but white space and colon. @@ -824,7 +809,7 @@ module.exports = function (editor) { LAST_EVALUATED_TOKEN = null; return; } - currentToken = {start: 0, value: ""}; // empty row + currentToken = { start: 0, value: "" }; // empty row } currentToken.row = pos.row; // extend token with row. Ace doesn't supply it by default @@ -870,7 +855,7 @@ module.exports = function (editor) { editor.execCommand("startAutocomplete"); }, 100); - function editorChangeListener(e) { + function editorChangeListener() { var cursor = editor.selection.lead; if (editor.__ace.completer && editor.__ace.completer.activated) { return; @@ -955,8 +940,7 @@ module.exports = function (editor) { // Hook into Ace // disable standard context based autocompletion. - ace.define('ace/autocomplete/text_completer', ['require', 'exports', 'module'], function (require, exports, - module) { + ace.define('ace/autocomplete/text_completer', ['require', 'exports', 'module'], function (require, exports) { exports.getCompletions = function (editor, session, pos, prefix, callback) { callback(null, []); } diff --git a/src/core_plugins/console/public/src/autocomplete/body_completer.js b/src/core_plugins/console/public/src/autocomplete/body_completer.js index a3891d320d787..82f3f233c16d3 100644 --- a/src/core_plugins/console/public/src/autocomplete/body_completer.js +++ b/src/core_plugins/console/public/src/autocomplete/body_completer.js @@ -1,5 +1,5 @@ -const _ = require('lodash'); -const engine = require('./engine'); +import _ from 'lodash'; +import engine from './engine'; function CompilingContext(endpoint_id, parametrizedComponentFactories) { this.parametrizedComponentFactories = parametrizedComponentFactories; @@ -97,7 +97,7 @@ function compileParametrizedValue(value, compilingContext, template) { } component = component(value, null, template); if (!_.isUndefined(template)) { - component = engine.wrapComponentWithDefaults(component, {template: template}); + component = engine.wrapComponentWithDefaults(component, { template: template }); } return component; @@ -145,7 +145,7 @@ function compileList(listRule, compilingContext) { } /** takes a compiled object and wraps in a {@link ConditionalProxy }*/ -function compileCondition(description, compiledObject, compilingContext) { +function compileCondition(description, compiledObject) { if (description.lines_regex) { return new ConditionalProxy(function (context, editor) { let lines = editor.getSession().getLines(context.requestStartRow, editor.getCursorPosition().row).join("\n"); @@ -169,7 +169,7 @@ function ObjectComponent(name, constants, patternsAndWildCards) { ObjectComponent.prototype = _.create( engine.AutocompleteComponent.prototype, - {'constructor': ObjectComponent}); + { 'constructor': ObjectComponent }); (function (cls) { @@ -244,7 +244,7 @@ function ScopeResolver(link, compilingContext) { ScopeResolver.prototype = _.create( engine.SharedComponent.prototype, - {'constructor': ScopeResolver}); + { 'constructor': ScopeResolver }); (function (cls) { @@ -316,7 +316,7 @@ function ConditionalProxy(predicate, delegate) { ConditionalProxy.prototype = _.create( engine.SharedComponent.prototype, - {'constructor': ConditionalProxy}); + { 'constructor': ConditionalProxy }); (function (cls) { @@ -345,16 +345,16 @@ function GlobalOnlyComponent(name) { GlobalOnlyComponent.prototype = _.create( engine.AutocompleteComponent.prototype, - {'constructor': ObjectComponent}); + { 'constructor': ObjectComponent }); (function (cls) { - cls.getTerms = function (context, editor) { + cls.getTerms = function () { return null; }; - cls.match = function (token, context, editor) { + cls.match = function (token, context) { var result = { next: [] }; diff --git a/src/core_plugins/console/public/src/autocomplete/engine.js b/src/core_plugins/console/public/src/autocomplete/engine.js index 31115d49cc0a0..dc88f6113d0e5 100644 --- a/src/core_plugins/console/public/src/autocomplete/engine.js +++ b/src/core_plugins/console/public/src/autocomplete/engine.js @@ -7,7 +7,7 @@ module.exports.AutocompleteComponent = function (name) { /** called to get the possible suggestions for tokens, when this object is at the end of * the resolving chain (and thus can suggest possible continuation paths) */ -module.exports.AutocompleteComponent.prototype.getTerms = function (context, editor) { +module.exports.AutocompleteComponent.prototype.getTerms = function () { return []; }; @@ -21,7 +21,7 @@ module.exports.AutocompleteComponent.prototype.getTerms = function (context, edi priority: optional priority to solve collisions between multiple paths. Min value is used across entire chain } */ -module.exports.AutocompleteComponent.prototype.match = function (token, context, editor) { +module.exports.AutocompleteComponent.prototype.match = function () { return { next: this.next }; @@ -39,7 +39,7 @@ function SharedComponent(name, parent) { SharedComponent.prototype = _.create( module.exports.AutocompleteComponent.prototype, - {'constructor': SharedComponent}); + { 'constructor': SharedComponent }); module.exports.SharedComponent = SharedComponent; @@ -68,7 +68,7 @@ function ListComponent(name, list, parent, multi_valued, allow_non_valid_values) this.allow_non_valid_values = _.isUndefined(allow_non_valid_values) ? false : allow_non_valid_values; } -ListComponent.prototype = _.create(SharedComponent.prototype, {"constructor": ListComponent}); +ListComponent.prototype = _.create(SharedComponent.prototype, { "constructor": ListComponent }); module.exports.ListComponent = ListComponent; @@ -88,16 +88,16 @@ module.exports.ListComponent = ListComponent; var meta = this.getDefaultTermMeta(); ret = _.map(ret, function (term) { if (_.isString(term)) { - term = {"name": term}; + term = { "name": term }; } - return _.defaults(term, {meta: meta}); + return _.defaults(term, { meta: meta }); }); } return ret; }; - cls.validateTokens = function (tokens, context, editor) { + cls.validateTokens = function (tokens) { if (!this.multi_valued && tokens.length > 1) { return false; } @@ -114,11 +114,11 @@ module.exports.ListComponent = ListComponent; return true; }; - cls.getContextKey = function (context, editor) { + cls.getContextKey = function () { return this.name; }; - cls.getDefaultTermMeta = function (context, editor) { + cls.getDefaultTermMeta = function () { return this.name; }; @@ -141,7 +141,7 @@ function SimpleParamComponent(name, parent) { SharedComponent.call(this, name, parent); } -SimpleParamComponent.prototype = _.create(SharedComponent.prototype, {"constructor": SimpleParamComponent}); +SimpleParamComponent.prototype = _.create(SharedComponent.prototype, { "constructor": SimpleParamComponent }); module.exports.SimpleParamComponent = SimpleParamComponent; (function (cls) { @@ -162,7 +162,7 @@ function ConstantComponent(name, parent, options) { this.options = options || [name]; } -ConstantComponent.prototype = _.create(SharedComponent.prototype, {"constructor": ConstantComponent}); +ConstantComponent.prototype = _.create(SharedComponent.prototype, { "constructor": ConstantComponent }); module.exports.ConstantComponent = ConstantComponent; (function (cls) { @@ -207,7 +207,7 @@ module.exports.wrapComponentWithDefaults = function (component, defaults) { } result = _.map(result, function (term) { if (!_.isObject(term)) { - term = {name: term}; + term = { name: term }; } return _.defaults(term, defaults); }, this); @@ -320,7 +320,7 @@ module.exports.populateContext = function (tokenPath, context, editor, includeAu _.each(ws.components, function (component) { _.each(component.getTerms(contextForState, editor), function (term) { if (!_.isObject(term)) { - term = {name: term}; + term = { name: term }; } autoCompleteSet.push(term); }); diff --git a/src/core_plugins/console/public/src/autocomplete/url_params.js b/src/core_plugins/console/public/src/autocomplete/url_params.js index 7a0b77151b60b..7e414c3c04b12 100644 --- a/src/core_plugins/console/public/src/autocomplete/url_params.js +++ b/src/core_plugins/console/public/src/autocomplete/url_params.js @@ -6,12 +6,12 @@ function ParamComponent(name, parent, description) { this.description = description; } -ParamComponent.prototype = _.create(engine.ConstantComponent.prototype, {"constructor": ParamComponent}); +ParamComponent.prototype = _.create(engine.ConstantComponent.prototype, { "constructor": ParamComponent }); module.exports.ParamComponent = ParamComponent; (function (cls) { cls.getTerms = function () { - var t = {name: this.name}; + var t = { name: this.name }; if (this.description === "__flag__") { t.meta = "flag" } @@ -37,7 +37,7 @@ function UrlParams(description, defaults) { description = _.clone(description || {}); _.defaults(description, defaults); _.each(description, function (p_description, param) { - var values, component; + var component; component = new ParamComponent(param, this.rootComponent, p_description); if (_.isArray(p_description)) { values = new engine.ListComponent(param, p_description, component); diff --git a/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js b/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js index 1ff1e136b13da..7a20b49d6d443 100644 --- a/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js +++ b/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js @@ -9,7 +9,7 @@ function AcceptEndpointComponent(endpoint, parent) { this.endpoint = endpoint } -AcceptEndpointComponent.prototype = _.create(engine.SharedComponent.prototype, {"constructor": AcceptEndpointComponent}); +AcceptEndpointComponent.prototype = _.create(engine.SharedComponent.prototype, { "constructor": AcceptEndpointComponent }); (function (cls) { diff --git a/src/core_plugins/console/public/src/curl.js b/src/core_plugins/console/public/src/curl.js index 7cfa4d282a6c2..881039fd869ef 100644 --- a/src/core_plugins/console/public/src/curl.js +++ b/src/core_plugins/console/public/src/curl.js @@ -1,217 +1,214 @@ -define(function () { - 'use strict'; +'use strict'; - function detectCURLinLine(line) { - // returns true if text matches a curl request - return line.match(/^\s*?curl\s+(-X[A-Z]+)?\s*['"]?.*?['"]?(\s*$|\s+?-d\s*?['"])/); +function detectCURLinLine(line) { + // returns true if text matches a curl request + return line.match(/^\s*?curl\s+(-X[A-Z]+)?\s*['"]?.*?['"]?(\s*$|\s+?-d\s*?['"])/); - } +} - function detectCURL(text) { - // returns true if text matches a curl request - if (!text) return false; - for (var line of text.split("\n")) { - if (detectCURLinLine(line)) { - return true; - } +function detectCURL(text) { + // returns true if text matches a curl request + if (!text) return false; + for (var line of text.split("\n")) { + if (detectCURLinLine(line)) { + return true; } - return false; + } + return false; +} + +function parseCURL(text) { + var state = 'NONE'; + var out = []; + var body = []; + var line = ''; + var lines = text.trim().split("\n"); + var matches; + + var EmptyLine = /^\s*$/; + var Comment = /^\s*(?:#|\/{2,})(.*)\n?$/; + var ExecutionComment = /^\s*#!/; + var ClosingSingleQuote = /^([^']*)'/; + var ClosingDoubleQuote = /^((?:[^\\"]|\\.)*)"/; + var EscapedQuotes = /^((?:[^\\"']|\\.)+)/; + + var LooksLikeCurl = /^\s*curl\s+/; + var CurlVerb = /-X ?(GET|HEAD|POST|PUT|DELETE)/; + + var HasProtocol = /[\s"']https?:\/\//; + var CurlRequestWithProto = /[\s"']https?:\/\/[^\/ ]+\/+([^\s"']+)/; + var CurlRequestWithoutProto = /[\s"'][^\/ ]+\/+([^\s"']+)/; + var CurlData = /^.+\s(--data|-d)\s*/; + var SenseLine = /^\s*(GET|HEAD|POST|PUT|DELETE)\s+\/?(.+)/; + + if (lines.length > 0 && ExecutionComment.test(lines[0])) { + lines.shift(); } - function parseCURL(text) { - var state = 'NONE'; - var out = []; - var body = []; - var line = ''; - var lines = text.trim().split("\n"); - var matches; - - var EmptyLine = /^\s*$/; - var Comment = /^\s*(?:#|\/{2,})(.*)\n?$/; - var ExecutionComment = /^\s*#!/; - var ClosingSingleQuote = /^([^']*)'/; - var ClosingDoubleQuote = /^((?:[^\\"]|\\.)*)"/; - var EscapedQuotes = /^((?:[^\\"']|\\.)+)/; - - var LooksLikeCurl = /^\s*curl\s+/; - var CurlVerb = /-X ?(GET|HEAD|POST|PUT|DELETE)/; + function nextLine() { + if (line.length > 0) { + return true; + } + if (lines.length == 0) { + return false; + } + line = lines.shift().replace(/[\r\n]+/g, "\n") + "\n"; + return true; + } - var HasProtocol = /[\s"']https?:\/\//; - var CurlRequestWithProto = /[\s"']https?:\/\/[^\/ ]+\/+([^\s"']+)/; - var CurlRequestWithoutProto = /[\s"'][^\/ ]+\/+([^\s"']+)/; - var CurlData = /^.+\s(--data|-d)\s*/; - var SenseLine = /^\s*(GET|HEAD|POST|PUT|DELETE)\s+\/?(.+)/; + function unescapeLastBodyEl() { + var str = body.pop().replace(/\\([\\"'])/g, "$1"); + body.push(str); + } - if (lines.length > 0 && ExecutionComment.test(lines[0])) { - lines.shift(); + // Is the next char a single or double quote? + // If so remove it + function detectQuote() { + if (line.substr(0, 1) == "'") { + line = line.substr(1); + state = 'SINGLE_QUOTE'; } - - function nextLine() { - if (line.length > 0) { - return true; - } - if (lines.length == 0) { - return false; - } - line = lines.shift().replace(/[\r\n]+/g, "\n") + "\n"; - return true; + else if (line.substr(0, 1) == '"') { + line = line.substr(1); + state = 'DOUBLE_QUOTE'; } - - function unescapeLastBodyEl() { - var str = body.pop().replace(/\\([\\"'])/g, "$1"); - body.push(str); + else { + state = 'UNQUOTED'; } + } - // Is the next char a single or double quote? - // If so remove it - function detectQuote() { - if (line.substr(0, 1) == "'") { - line = line.substr(1); - state = 'SINGLE_QUOTE'; - } - else if (line.substr(0, 1) == '"') { - line = line.substr(1); - state = 'DOUBLE_QUOTE'; - } - else { - state = 'UNQUOTED'; - } + // Body is finished - append to output with final LF + function addBodyToOut() { + if (body.length > 0) { + out.push(body.join("")); + body = []; } + state = 'LF'; + out.push("\n"); + } - // Body is finished - append to output with final LF - function addBodyToOut() { - if (body.length > 0) { - out.push(body.join("")); - body = []; - } - state = 'LF'; - out.push("\n"); - } - - // If the pattern matches, then the state is about to change, - // so add the capture to the body and detect the next state - // Otherwise add the whole line - function consumeMatching(pattern) { - var matches = line.match(pattern); - if (matches) { - body.push(matches[1]); - line = line.substr(matches[0].length); - detectQuote(); - } - else { - body.push(line); - line = ''; - } + // If the pattern matches, then the state is about to change, + // so add the capture to the body and detect the next state + // Otherwise add the whole line + function consumeMatching(pattern) { + var matches = line.match(pattern); + if (matches) { + body.push(matches[1]); + line = line.substr(matches[0].length); + detectQuote(); + } + else { + body.push(line); + line = ''; } + } - function parseCurlLine() { - var verb = 'GET'; - var request = ''; - var matches; - if (matches = line.match(CurlVerb)) { - verb = matches[1]; - } + function parseCurlLine() { + var verb = 'GET'; + var request = ''; + var matches; + if (matches = line.match(CurlVerb)) { + verb = matches[1]; + } - // JS regexen don't support possesive quantifiers, so - // we need two distinct patterns - var pattern = HasProtocol.test(line) - ? CurlRequestWithProto - : CurlRequestWithoutProto; + // JS regexen don't support possesive quantifiers, so + // we need two distinct patterns + var pattern = HasProtocol.test(line) + ? CurlRequestWithProto + : CurlRequestWithoutProto; - if (matches = line.match(pattern)) { - request = matches[1]; - } + if (matches = line.match(pattern)) { + request = matches[1]; + } - out.push(verb + ' /' + request + "\n"); + out.push(verb + ' /' + request + "\n"); - if (matches = line.match(CurlData)) { - line = line.substr(matches[0].length); - detectQuote(); - if (EmptyLine.test(line)) { - line = ''; - } - } - else { - state = 'NONE'; + if (matches = line.match(CurlData)) { + line = line.substr(matches[0].length); + detectQuote(); + if (EmptyLine.test(line)) { line = ''; - out.push(''); } } + else { + state = 'NONE'; + line = ''; + out.push(''); + } + } - while (nextLine()) { + while (nextLine()) { - if (state == 'SINGLE_QUOTE') { - consumeMatching(ClosingSingleQuote); - } + if (state == 'SINGLE_QUOTE') { + consumeMatching(ClosingSingleQuote); + } - else if (state == 'DOUBLE_QUOTE') { - consumeMatching(ClosingDoubleQuote); + else if (state == 'DOUBLE_QUOTE') { + consumeMatching(ClosingDoubleQuote); + unescapeLastBodyEl(); + } + + else if (state == 'UNQUOTED') { + consumeMatching(EscapedQuotes); + if (body.length) { unescapeLastBodyEl(); } - - else if (state == 'UNQUOTED') { - consumeMatching(EscapedQuotes); - if (body.length) { - unescapeLastBodyEl(); - } - if (state == 'UNQUOTED') { - addBodyToOut(); - line = '' - } + if (state == 'UNQUOTED') { + addBodyToOut(); + line = '' } + } - // the BODY state (used to match the body of a Sense request) - // can be terminated early if it encounters - // a comment or an empty line - else if (state == 'BODY') { - if (Comment.test(line) || EmptyLine.test(line)) { - addBodyToOut(); - } - else { - body.push(line); - line = ''; - } + // the BODY state (used to match the body of a Sense request) + // can be terminated early if it encounters + // a comment or an empty line + else if (state == 'BODY') { + if (Comment.test(line) || EmptyLine.test(line)) { + addBodyToOut(); } - - else if (EmptyLine.test(line)) { - if (state != 'LF') { - out.push("\n"); - state = 'LF'; - } + else { + body.push(line); line = ''; } + } - else if (matches = line.match(Comment)) { - out.push("#" + matches[1] + "\n"); - state = 'NONE'; - line = ''; + else if (EmptyLine.test(line)) { + if (state != 'LF') { + out.push("\n"); + state = 'LF'; } + line = ''; + } - else if (LooksLikeCurl.test(line)) { - parseCurlLine(); - } + else if (matches = line.match(Comment)) { + out.push("#" + matches[1] + "\n"); + state = 'NONE'; + line = ''; + } - else if (matches = line.match(SenseLine)) { - out.push(matches[1] + ' /' + matches[2] + "\n"); - line = ''; - state = 'BODY'; - } + else if (LooksLikeCurl.test(line)) { + parseCurlLine(); + } - // Nothing else matches, so output with a prefix of !!! for debugging purposes - else { - out.push('### ' + line); - line = ''; - } + else if (matches = line.match(SenseLine)) { + out.push(matches[1] + ' /' + matches[2] + "\n"); + line = ''; + state = 'BODY'; } - addBodyToOut(); - return out.join('').trim(); + // Nothing else matches, so output with a prefix of !!! for debugging purposes + else { + out.push('### ' + line); + line = ''; + } } + addBodyToOut(); + return out.join('').trim(); +} - return { - parseCURL: parseCURL, - detectCURL: detectCURL - }; -}); +export default { + parseCURL: parseCURL, + detectCURL: detectCURL +}; diff --git a/src/core_plugins/console/public/src/directives/sense_help_example.js b/src/core_plugins/console/public/src/directives/sense_help_example.js index 42bb30fcfecd7..a9bc22e81a79d 100644 --- a/src/core_plugins/console/public/src/directives/sense_help_example.js +++ b/src/core_plugins/console/public/src/directives/sense_help_example.js @@ -1,4 +1,4 @@ -const SenseEditor = require('../sense_editor/editor'); +import SenseEditor from '../sense_editor/editor'; const exampleText = require('raw!./helpExample.txt').trim(); import { useResizeCheckerProvider } from '../sense_editor_resize'; diff --git a/src/core_plugins/console/public/src/directives/sense_history.js b/src/core_plugins/console/public/src/directives/sense_history.js index 12c1063e3f2e2..d2796bf65333b 100644 --- a/src/core_plugins/console/public/src/directives/sense_history.js +++ b/src/core_plugins/console/public/src/directives/sense_history.js @@ -1,4 +1,6 @@ -var { assign, memoize } = require('lodash'); +var { + memoize +} = require('lodash'); let moment = require('moment'); var history = require('../history'); diff --git a/src/core_plugins/console/public/src/directives/sense_history_viewer.js b/src/core_plugins/console/public/src/directives/sense_history_viewer.js index 327b264ac6635..1d63b5c833fd6 100644 --- a/src/core_plugins/console/public/src/directives/sense_history_viewer.js +++ b/src/core_plugins/console/public/src/directives/sense_history_viewer.js @@ -1,4 +1,3 @@ -const history = require('../history'); let SenseEditor = require('../sense_editor/editor'); import { useResizeCheckerProvider } from '../sense_editor_resize'; diff --git a/src/core_plugins/console/public/src/directives/sense_settings.js b/src/core_plugins/console/public/src/directives/sense_settings.js index 72507467f8112..476dc0a013cd6 100644 --- a/src/core_plugins/console/public/src/directives/sense_settings.js +++ b/src/core_plugins/console/public/src/directives/sense_settings.js @@ -1,3 +1,4 @@ +import settings from '../settings'; require('ui/directives/input_focus'); require('ui/modules') @@ -8,8 +9,6 @@ require('ui/modules') template: require('./settings.html'), controllerAs: 'settings', controller: function ($scope, $element) { - const settings = require('../settings'); - this.vals = settings.getCurrentSettings(); this.apply = () => { this.vals = settings.updateSettings(this.vals); diff --git a/src/core_plugins/console/public/src/directives/sense_welcome.js b/src/core_plugins/console/public/src/directives/sense_welcome.js index 28db076e6d760..24ef382f78436 100644 --- a/src/core_plugins/console/public/src/directives/sense_welcome.js +++ b/src/core_plugins/console/public/src/directives/sense_welcome.js @@ -1,6 +1,6 @@ require('./sense_help_example'); -const storage = require('../storage'); +import storage from '../storage'; require('ui/modules') .get('app/sense') diff --git a/src/core_plugins/console/public/src/es.js b/src/core_plugins/console/public/src/es.js index be9fb725e4643..e49cee8434a5a 100644 --- a/src/core_plugins/console/public/src/es.js +++ b/src/core_plugins/console/public/src/es.js @@ -1,4 +1,3 @@ -let _ = require('lodash'); let $ = require('jquery'); let esVersion = []; @@ -7,7 +6,7 @@ module.exports.getVersion = function () { return esVersion; }; -module.exports.send = function (method, path, data, server, disable_auth_alert) { +module.exports.send = function (method, path, data) { var wrappedDfd = $.Deferred(); console.log("Calling " + path); @@ -15,9 +14,6 @@ module.exports.send = function (method, path, data, server, disable_auth_alert) method = "POST"; } - // delayed loading for circular references - var settings = require("./settings"); - let contentType; if (data) { try { diff --git a/src/core_plugins/console/public/src/history.js b/src/core_plugins/console/public/src/history.js index d0787f784a84f..205b0ab50377b 100644 --- a/src/core_plugins/console/public/src/history.js +++ b/src/core_plugins/console/public/src/history.js @@ -1,6 +1,5 @@ -const $ = require('jquery'); -const { uniq } = require('lodash'); -const storage = require('./storage'); +import $ from 'jquery'; +import storage from './storage'; const history = module.exports = { restoreFromHistory() { @@ -55,7 +54,7 @@ const history = module.exports = { return { time, content }; }, - clearHistory($el) { + clearHistory() { history .getHistoryKeys() .forEach(key => storage.delete(key)); diff --git a/src/core_plugins/console/public/src/input.js b/src/core_plugins/console/public/src/input.js index efd8a22c2c906..4e4a9f6a790e3 100644 --- a/src/core_plugins/console/public/src/input.js +++ b/src/core_plugins/console/public/src/input.js @@ -1,13 +1,9 @@ -let ace = require('ace'); let $ = require('jquery'); let ZeroClipboard = require('zeroclip'); -let ext_searchbox = require('ace/ext-searchbox'); let Autocomplete = require('./autocomplete'); -let mappings = require('./mappings'); let SenseEditor = require('./sense_editor/editor'); let settings = require('./settings'); let storage = require('./storage'); -let utils = require('./utils'); let es = require('./es'); let history = require('./history'); import uiModules from 'ui/modules'; @@ -24,37 +20,28 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output) { input.commands.addCommand({ name: 'auto indent request', - bindKey: {win: 'Ctrl-I', mac: 'Command-I'}, + bindKey: { win: 'Ctrl-I', mac: 'Command-I' }, exec: function () { input.autoIndent(); } }); input.commands.addCommand({ name: 'move to previous request start or end', - bindKey: {win: 'Ctrl-Up', mac: 'Command-Up'}, + bindKey: { win: 'Ctrl-Up', mac: 'Command-Up' }, exec: function () { input.moveToPreviousRequestEdge() } }); input.commands.addCommand({ name: 'move to next request start or end', - bindKey: {win: 'Ctrl-Down', mac: 'Command-Down'}, + bindKey: { win: 'Ctrl-Down', mac: 'Command-Down' }, exec: function () { input.moveToNextRequestEdge() } }); - /** - * COPY AS CURL - * - * Since the copy functionality is powered by a flash movie (via ZeroClipboard) - * the only way to trigger the copy is with a litteral mouseclick from the user. - * - * The original shortcut will now just open the menu and highlight the - * - */ - var zc = (function setupZeroClipboard() { + (function setupZeroClipboard() { var zc = new ZeroClipboard($copyAsCurlEl); // the ZeroClipboard instance zc.on('wrongflash noflash', function () { @@ -89,7 +76,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output) { }); return zc; - }()); + })(); /** * Setup the "send" shortcut @@ -224,7 +211,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output) { input.commands.addCommand({ name: 'send to elasticsearch', - bindKey: {win: 'Ctrl-Enter', mac: 'Command-Enter'}, + bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' }, exec: sendCurrentRequestToES }); @@ -242,8 +229,8 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output) { require('./input_resize')(input, output); return input; -}; +} export default function getInput() { return input; -}; +} diff --git a/src/core_plugins/console/public/src/input_resize.js b/src/core_plugins/console/public/src/input_resize.js index 83688cb4f9cf1..237ff81039e76 100644 --- a/src/core_plugins/console/public/src/input_resize.js +++ b/src/core_plugins/console/public/src/input_resize.js @@ -1,5 +1,5 @@ -const $ = require('jquery'); -const storage = require('./storage'); +import $ from 'jquery'; +import storage from './storage'; module.exports = function (input, output) { diff --git a/src/core_plugins/console/public/src/kb.js b/src/core_plugins/console/public/src/kb.js index b005d25f8f4da..190735c7c9a53 100644 --- a/src/core_plugins/console/public/src/kb.js +++ b/src/core_plugins/console/public/src/kb.js @@ -1,7 +1,6 @@ let $ = require('jquery'); let _ = require('lodash'); let mappings = require('./mappings'); -let es = require('./es'); let Api = require('./kb/api'); let autocomplete_engine = require('./autocomplete/engine'); @@ -17,7 +16,7 @@ function IndexAutocompleteComponent(name, parent, multi_valued) { IndexAutocompleteComponent.prototype = _.create( autocomplete_engine.ListComponent.prototype, - {'constructor': IndexAutocompleteComponent}); + { 'constructor': IndexAutocompleteComponent }); (function (cls) { cls.validateTokens = function (tokens) { @@ -47,7 +46,7 @@ function TypeAutocompleteComponent(name, parent, multi_valued) { TypeAutocompleteComponent.prototype = _.create( autocomplete_engine.ListComponent.prototype, - {'constructor': TypeAutocompleteComponent}); + { 'constructor': TypeAutocompleteComponent }); (function (cls) { cls.validateTokens = function (tokens) { @@ -69,7 +68,7 @@ TypeAutocompleteComponent.prototype = _.create( function FieldGenerator(context) { return _.map(mappings.getFields(context.indices, context.types), function (field) { - return {name: field.name, meta: field.type}; + return { name: field.name, meta: field.type }; }); } @@ -79,7 +78,7 @@ function FieldAutocompleteComponent(name, parent, multi_valued) { FieldAutocompleteComponent.prototype = _.create( autocomplete_engine.ListComponent.prototype, - {'constructor': FieldAutocompleteComponent}); + { 'constructor': FieldAutocompleteComponent }); (function (cls) { cls.validateTokens = function (tokens) { @@ -109,7 +108,7 @@ function IdAutocompleteComponent(name, parent, multi) { IdAutocompleteComponent.prototype = _.create( autocomplete_engine.SharedComponent.prototype, - {'constructor': IdAutocompleteComponent}); + { 'constructor': IdAutocompleteComponent }); (function (cls) { cls.match = function (token, context, editor) { @@ -134,47 +133,40 @@ IdAutocompleteComponent.prototype = _.create( var parametrizedComponentFactories = { - 'index': function (name, parent, endpoint) { + 'index': function (name, parent) { return new IndexAutocompleteComponent(name, parent, false); }, - 'indices': function (name, parent, endpoint) { + 'indices': function (name, parent) { return new IndexAutocompleteComponent(name, parent, true); }, - 'type': function (name, parent, endpoint) { + 'type': function (name, parent) { return new TypeAutocompleteComponent(name, parent, false); }, - 'types': function (name, parent, endpoint) { + 'types': function (name, parent) { return new TypeAutocompleteComponent(name, parent, true); }, - 'id': function (name, parent, endpoint) { + 'id': function (name, parent) { return new IdAutocompleteComponent(name, parent); }, - 'ids': function (name, parent, endpoint) { + 'ids': function (name, parent) { return new IdAutocompleteComponent(name, parent, true); }, - 'fields': function (name, parent, endpoint) { + 'fields': function (name, parent) { return new FieldAutocompleteComponent(name, parent, true); }, - 'field': function (name, parent, endpoint) { + 'field': function (name, parent) { return new FieldAutocompleteComponent(name, parent, false); }, - 'nodes': function (name, parent, endpoint) { + 'nodes': function (name, parent) { return new autocomplete_engine.ListComponent(name, ["_local", "_master", "data:true", "data:false", "master:true", "master:false"], parent) }, - 'node': function (name, parent, endpoint) { + 'node': function (name, parent) { return new autocomplete_engine.ListComponent(name, [], parent, false) } }; -function expandAliases(indices) { - if (indices && indices.length > 0) { - indices = mappings.expandAliases(indices); - } - return indices; -} - function getUnmatchedEndpointComponents() { return ACTIVE_API.getUnmatchedEndpointComponents(); } @@ -224,7 +216,7 @@ function setActiveApi(api) { dataType: "json", // disable automatic guessing } ).then( - function (data, textStatus, jqXHR) { + function (data) { setActiveApi(loadApisFromJson(data)); }, function (jqXHR) { diff --git a/src/core_plugins/console/public/src/mappings.js b/src/core_plugins/console/public/src/mappings.js index 82906c8f4fae8..020909c59fa61 100644 --- a/src/core_plugins/console/public/src/mappings.js +++ b/src/core_plugins/console/public/src/mappings.js @@ -1,6 +1,5 @@ let $ = require('jquery'); let _ = require('lodash'); -let utils = require('./utils'); let es = require('./es'); let settings = require('./settings'); @@ -89,7 +88,7 @@ function getTypes(indices) { } // filter what we need - $.each(type_dict, function (type, fields) { + $.each(type_dict, function (type) { ret.push(type); }); @@ -155,7 +154,7 @@ function getFieldNamesFromFieldMapping(field_name, field_mapping) { return applyPathSettings(nested_fields); } - var ret = {name: field_name, type: field_type}; + var ret = { name: field_name, type: field_type }; if (field_mapping["index_name"]) { ret.name = field_mapping["index_name"]; @@ -272,13 +271,6 @@ function retrieveAutocompleteInfoFromServer() { ; } -function autocomplete_retriever() { - retrieveAutocompleteInfoFromServer(); - setTimeout(function () { - autocomplete_retriever(); - }, 60000); -} - module.exports = _.assign(mappingObj, { getFields: getFields, getIndices: getIndices, diff --git a/src/core_plugins/console/public/src/output.js b/src/core_plugins/console/public/src/output.js index 21b9f498bc52a..34edee57d9856 100644 --- a/src/core_plugins/console/public/src/output.js +++ b/src/core_plugins/console/public/src/output.js @@ -1,8 +1,7 @@ let ace = require('ace'); -let $ = require('jquery'); let settings = require('./settings'); let OutputMode = require('./sense_editor/mode/output'); -const smartResize = require('./smart_resize'); +import smartResize from './smart_resize'; let output; export function initializeOutput($el) { @@ -41,7 +40,7 @@ export function initializeOutput($el) { session.toggleFold(false); } - session.insert({row: lastLine, column: 0}, "\n" + val); + session.insert({ row: lastLine, column: 0 }, "\n" + val); output.moveCursorTo(lastLine + 1, 0); if (typeof cb === 'function') { setTimeout(cb); @@ -65,8 +64,8 @@ export function initializeOutput($el) { } return output; -}; +} export default function getOutput() { return output; -}; +} diff --git a/src/core_plugins/console/public/src/sense_editor/editor.js b/src/core_plugins/console/public/src/sense_editor/editor.js index 184427fe335dc..934323dcab05e 100644 --- a/src/core_plugins/console/public/src/sense_editor/editor.js +++ b/src/core_plugins/console/public/src/sense_editor/editor.js @@ -8,11 +8,7 @@ let utils = require('../utils'); let es = require('../es'); import chrome from 'ui/chrome'; -const smartResize = require('../smart_resize'); - -function isInt(x) { - return !isNaN(parseInt(x, 10)); -} +import smartResize from '../smart_resize'; function createInstance($el) { var aceEditor = ace.edit($el[0]); @@ -560,11 +556,11 @@ function SenseEditor($el) { }); }; - editor.getSession().on('tokenizerUpdate', function (e) { + editor.getSession().on('tokenizerUpdate', function () { editor.highlightCurrentRequestsAndUpdateActionBar(); }); - editor.getSession().selection.on('changeCursor', function (e) { + editor.getSession().selection.on('changeCursor', function () { editor.highlightCurrentRequestsAndUpdateActionBar(); }); diff --git a/src/core_plugins/console/public/src/sense_editor/mode/input.js b/src/core_plugins/console/public/src/sense_editor/mode/input.js index 9b197b96740c2..02285f0ae2582 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/input.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/input.js @@ -1,6 +1,4 @@ -let ace = require('ace'); let acequire = require('acequire'); -let mode_json = require('ace/mode-json'); var oop = acequire("ace/lib/oop"); var TextMode = acequire("ace/mode/text").Mode; @@ -24,7 +22,7 @@ var Mode = function () { oop.inherits(Mode, TextMode); (function () { - this.getCompletions = function (editor, session, pos, prefix) { + this.getCompletions = function () { // autocomplete is done by the autocomplete module. return []; }; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js b/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js index da256594bfb45..cc4e229d07a39 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js @@ -14,8 +14,8 @@ var InputHighlightRules = function () { reg = reg.source; } return [ - {token: tokens.concat(["whitespace"]), regex: reg + "(\\s*)$", next: nextIfEOL}, - {token: tokens, regex: reg, next: normalNext} + { token: tokens.concat(["whitespace"]), regex: reg + "(\\s*)$", next: nextIfEOL }, + { token: tokens, regex: reg, next: normalNext } ]; } @@ -24,8 +24,8 @@ var InputHighlightRules = function () { /*jshint -W015 */ this.$rules = { "start": mergeTokens([ - {token: "comment", regex: /^#.*$/}, - {token: "paren.lparen", regex: "{", next: "json", push: true} + { token: "comment", regex: /^#.*$/ }, + { token: "paren.lparen", regex: "{", next: "json", push: true } ], addEOL(["method"], /([a-zA-Z]+)/, "start", "method_sep") , diff --git a/src/core_plugins/console/public/src/sense_editor/mode/output.js b/src/core_plugins/console/public/src/sense_editor/mode/output.js index d4edebc17745d..23186cf65f345 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/output.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/output.js @@ -1,7 +1,4 @@ let ace = require('ace'); -let acequire = require('acequire'); -let mode_json = require('ace/mode-json'); -let output_highlighting_rules = require('./output_highlight_rules'); var oop = ace.require("ace/lib/oop"); @@ -10,7 +7,7 @@ var HighlightRules = require("./output_highlight_rules").OutputJsonHighlightRule var MatchingBraceOutdent = ace.require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; var CstyleBehaviour = ace.require("ace/mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = ace.require("ace/mode/folding/cstyle").FoldMode; -var WorkerClient = ace.require("ace/worker/worker_client").WorkerClient; +ace.require("ace/worker/worker_client").WorkerClient; var AceTokenizer = ace.require("ace/tokenizer").Tokenizer; var Mode = function () { @@ -22,7 +19,7 @@ var Mode = function () { oop.inherits(Mode, JSONMode); (function () { - this.createWorker = function (session) { + this.createWorker = function () { return null; }; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js b/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js index 97b76cf71aaf9..b821774f772d1 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js @@ -1,5 +1,4 @@ let ace = require('ace'); -let ace_mode_json = require('ace/mode-json'); var oop = ace.require("ace/lib/oop"); var JsonHighlightRules = ace.require("ace/mode/json_highlight_rules").JsonHighlightRules; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/worker.js b/src/core_plugins/console/public/src/sense_editor/mode/worker.js index 4371f7ff14b8d..a2669a96d33b1 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/worker.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/worker.js @@ -7,7 +7,7 @@ window.console = function () { var msgs = Array.prototype.slice.call(arguments, 0); - window.postMessage({type: "log", data: msgs}); + window.postMessage({ type: "log", data: msgs }); }; window.console.error = window.console.warn = @@ -181,7 +181,7 @@ }; })(this);// https://github.com/kriskowal/es5-shim -define('ace/lib/oop', ['require', 'exports', 'module' ], function (require, exports, module) { +define('ace/lib/oop', ['require', 'exports', 'module' ], function (require, exports) { "use strict"; exports.inherits = function (ctor, superCtor) { @@ -208,7 +208,7 @@ define('ace/lib/oop', ['require', 'exports', 'module' ], function (require, expo }; }); -define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function (require, exports, module) { +define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function (require, exports) { "use strict"; var Document = require("../document").Document; @@ -258,7 +258,7 @@ define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'a }); define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', - 'ace/range', 'ace/anchor'], function (require, exports, module) { + 'ace/range', 'ace/anchor'], function (require, exports) { "use strict"; var oop = require("./lib/oop"); @@ -273,7 +273,7 @@ define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib } else if (Array.isArray(text)) { this._insertLines(0, text); } else { - this.insert({row: 0, column: 0}, text); + this.insert({ row: 0, column: 0 }, text); } }; @@ -283,7 +283,7 @@ define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib this.setValue = function (text) { var len = this.getLength(); this.remove(new Range(0, 0, len, this.getLine(len - 1).length)); - this.insert({row: 0, column: 0}, text); + this.insert({ row: 0, column: 0 }, text); }; this.getValue = function () { return this.getAllLines().join(this.getNewLineCharacter()); @@ -386,12 +386,12 @@ define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib }; this.insertLines = function (row, lines) { if (row >= this.getLength()) - return this.insert({row: row, column: 0}, "\n" + lines.join("\n")); + return this.insert({ row: row, column: 0 }, "\n" + lines.join("\n")); return this._insertLines(Math.max(row, 0), lines); }; this._insertLines = function (row, lines) { if (lines.length == 0) - return {row: row, column: 0}; + return { row: row, column: 0 }; var end; if (lines.length > 0xFFFF) { end = this._insertLines(row, lines.slice(0xFFFF)); @@ -596,9 +596,9 @@ define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib for (var i = startRow || 0, l = lines.length; i < l; i++) { index -= lines[i].length + newlineLength; if (index < 0) - return {row: i, column: index + lines[i].length + newlineLength}; + return { row: i, column: index + lines[i].length + newlineLength }; } - return {row: l - 1, column: lines[l - 1].length}; + return { row: l - 1, column: lines[l - 1].length }; }; this.positionToIndex = function (pos, startRow) { var lines = this.$lines || this.getAllLines(); @@ -616,7 +616,7 @@ define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib exports.Document = Document; }); -define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function (require, exports, module) { +define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function (require, exports) { "use strict"; var EventEmitter = {}; @@ -680,7 +680,7 @@ define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function (req EventEmitter.setDefaultHandler = function (eventName, callback) { var handlers = this._defaultHandlers if (!handlers) - handlers = this._defaultHandlers = {_disabled_: {}}; + handlers = this._defaultHandlers = { _disabled_: {} }; if (handlers[eventName]) { var old = handlers[eventName]; @@ -701,7 +701,6 @@ define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function (req var disabled = handlers._disabled_[eventName]; if (handlers[eventName] == callback) { - var old = handlers[eventName]; if (disabled) this.setDefaultHandler(eventName, disabled.pop()); } else if (disabled) { @@ -746,7 +745,7 @@ define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function (req }); -define('ace/range', ['require', 'exports', 'module' ], function (require, exports, module) { +define('ace/range', ['require', 'exports', 'module' ], function (require, exports) { "use strict"; var comparePoints = function (p1, p2) { @@ -918,14 +917,14 @@ define('ace/range', ['require', 'exports', 'module' ], function (require, export this.clipRows = function (firstRow, lastRow) { var start, end; if (this.end.row > lastRow) - end = {row: lastRow + 1, column: 0}; + end = { row: lastRow + 1, column: 0 }; else if (this.end.row < firstRow) - end = {row: firstRow, column: 0}; + end = { row: firstRow, column: 0 }; if (this.start.row > lastRow) - start = {row: lastRow + 1, column: 0}; + start = { row: lastRow + 1, column: 0 }; else if (this.start.row < firstRow) - start = {row: firstRow, column: 0}; + start = { row: firstRow, column: 0 }; return Range.fromPoints(start || this.start, end || this.end); }; @@ -935,9 +934,9 @@ define('ace/range', ['require', 'exports', 'module' ], function (require, export if (cmp == 0) return this; else if (cmp == -1) - start = {row: row, column: column}; + start = { row: row, column: column }; else - end = {row: row, column: column}; + end = { row: row, column: column }; return Range.fromPoints(start || this.start, end || this.end); }; @@ -987,7 +986,7 @@ define('ace/range', ['require', 'exports', 'module' ], function (require, export exports.Range = Range; }); -define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function (require, exports, module) { +define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function (require, exports) { "use strict"; var oop = require("./lib/oop"); @@ -1134,7 +1133,7 @@ define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/e }); -define('ace/lib/lang', ['require', 'exports', 'module' ], function (require, exports, module) { +define('ace/lib/lang', ['require', 'exports', 'module' ], function (require, exports) { "use strict"; exports.stringReverse = function (string) { @@ -1318,7 +1317,7 @@ define('ace/lib/lang', ['require', 'exports', 'module' ], function (require, exp }); -define("sense_editor/mode/worker_parser", ['require', 'exports', 'module' ], function (require, exports, module) { +define("sense_editor/mode/worker_parser", ['require', 'exports', 'module' ], function () { "use strict"; var at, // The index of the current character @@ -1337,7 +1336,7 @@ define("sense_editor/mode/worker_parser", ['require', 'exports', 'module' ], fun text, annotate = function (type, text) { - annos.push({type: type, text: text, at: at}); + annos.push({ type: type, text: text, at: at }); }, error = function (m) { @@ -1621,7 +1620,7 @@ define("sense_editor/mode/worker_parser", ['require', 'exports', 'module' ], fun request = function () { white(); - var meth = method(); + method(); strictWhite(); url(); strictWhite(); // advance to one new line @@ -1641,7 +1640,6 @@ define("sense_editor/mode/worker_parser", ['require', 'exports', 'module' ], fun newLine(); strictWhite(); } - }, comment = function () { @@ -1711,13 +1709,13 @@ define("sense_editor/mode/worker_parser", ['require', 'exports', 'module' ], fun } } return reviver.call(holder, key, value); - })({'': result}, '') : result; + })({ '': result }, '') : result; }; }); define("sense_editor/mode/worker", ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', - 'sense_editor/mode/worker_parser'], function (require, exports, module) { + 'sense_editor/mode/worker_parser'], function (require, exports) { "use strict"; @@ -1764,7 +1762,7 @@ define("sense_editor/mode/worker", ['require', 'exports', 'module' , 'ace/lib/oo var nl = this.doc.getNewLineCharacter().length; if (!len) { - return { row: 0, column: 0}; + return { row: 0, column: 0 }; } var lineStart = 0, line; diff --git a/src/core_plugins/console/public/src/sense_editor/theme-sense-dark.js b/src/core_plugins/console/public/src/sense_editor/theme-sense-dark.js index bf25de1cceee9..ac43d964f54c1 100644 --- a/src/core_plugins/console/public/src/sense_editor/theme-sense-dark.js +++ b/src/core_plugins/console/public/src/sense_editor/theme-sense-dark.js @@ -1,7 +1,7 @@ let ace = require('ace'); ace.define("ace/theme/sense-dark", ['require', 'exports', 'module'], - function (require, exports, module) { + function (require, exports) { exports.isDark = true; exports.cssClass = "ace-sense-dark"; exports.cssText = ".ace-sense-dark .ace_gutter {\ diff --git a/src/core_plugins/console/public/src/settings.js b/src/core_plugins/console/public/src/settings.js index 85f6713185f4f..7e5c2064e5d36 100644 --- a/src/core_plugins/console/public/src/settings.js +++ b/src/core_plugins/console/public/src/settings.js @@ -1,6 +1,4 @@ -let $ = require('jquery'); -let es = require('./es'); -const storage = require('./storage'); +import storage from './storage'; import getInput from './input' import getOutput from './output' @@ -25,12 +23,6 @@ function setWrapMode(mode) { return true; } -function setBasicAuth(mode) { - storage.set('basic_auth', mode); - applyCurrentSettings(); - return true; -} - export function getAutocomplete() { return storage.get('autocomplete_settings', { fields: true, indices: true }); } @@ -59,7 +51,7 @@ export function getCurrentSettings() { }; } -export function updateSettings({ fontSize, wrapMode, autocomplete}) { +export function updateSettings({ fontSize, wrapMode, autocomplete }) { setFontSize(fontSize); setWrapMode(wrapMode); setAutocomplete(autocomplete); diff --git a/src/core_plugins/console/public/src/storage.js b/src/core_plugins/console/public/src/storage.js index c23a11f1d9f90..ede67a5eaeae1 100644 --- a/src/core_plugins/console/public/src/storage.js +++ b/src/core_plugins/console/public/src/storage.js @@ -1,4 +1,4 @@ -const { transform, keys, startsWith } = require('lodash'); +import { transform, keys, startsWith } from 'lodash'; class Storage { constructor(engine, prefix) { diff --git a/src/core_plugins/console/public/tests/src/curl_parsing_tests.js b/src/core_plugins/console/public/tests/src/curl_parsing_tests.js index 6eb35df9b1c98..bed751d6a7cbe 100644 --- a/src/core_plugins/console/public/tests/src/curl_parsing_tests.js +++ b/src/core_plugins/console/public/tests/src/curl_parsing_tests.js @@ -2,7 +2,12 @@ let _ = require('lodash'); let curl = require('../../src/curl'); let curlTests = require('raw!./curl_parsing_tests.txt'); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + test, + module, + ok, + equal +} = QUnit; module("CURL"); diff --git a/src/core_plugins/console/public/tests/src/editor_tests.js b/src/core_plugins/console/public/tests/src/editor_tests.js index f73d1e5038c14..aa897d14fc0dc 100644 --- a/src/core_plugins/console/public/tests/src/editor_tests.js +++ b/src/core_plugins/console/public/tests/src/editor_tests.js @@ -1,10 +1,15 @@ let ace = require('ace'); -let es = require('../../src/es'); let input = require('../../src/input'); let editor_input1 = require('raw!./editor_input1.txt'); var aceRange = ace.require("ace/range"); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + module, + asyncTest, + deepEqual, + equal, + start +} = QUnit; module("Editor", { @@ -272,7 +277,7 @@ function multi_req_test(name, editor_input, range, expected) { } multi_req_test("mid body to mid body", editor_input1, - {start: {row: 12}, end: {row: 17}}, [{ + { start: { row: 12 }, end: { row: 17 } }, [{ method: "PUT", url: "index_1/type1/1", data: { @@ -287,7 +292,7 @@ multi_req_test("mid body to mid body", editor_input1, }]); multi_req_test("single request start to end", editor_input1, - {start: {row: 10}, end: {row: 13}}, [{ + { start: { row: 10 }, end: { row: 13 } }, [{ method: "PUT", url: "index_1/type1/1", data: { @@ -296,7 +301,7 @@ multi_req_test("single request start to end", editor_input1, }]); multi_req_test("start to end, with comment", editor_input1, - {start: {row: 6}, end: {row: 13}}, [{ + { start: { row: 6 }, end: { row: 13 } }, [{ method: "GET", url: "_stats?level=shards", data: null @@ -310,7 +315,7 @@ multi_req_test("start to end, with comment", editor_input1, }]); multi_req_test("before start to after end, with comments", editor_input1, - {start: {row: 4}, end: {row: 14}}, [{ + { start: { row: 4 }, end: { row: 14 } }, [{ method: "GET", url: "_stats?level=shards", data: null @@ -324,13 +329,13 @@ multi_req_test("before start to after end, with comments", editor_input1, }]); multi_req_test("between requests", editor_input1, - {start: {row: 21}, end: {row: 22}}, []); + { start: { row: 21 }, end: { row: 22 } }, []); multi_req_test("between requests - with comment", editor_input1, - {start: {row: 20}, end: {row: 22}}, []); + { start: { row: 20 }, end: { row: 22 } }, []); multi_req_test("between requests - before comment", editor_input1, - {start: {row: 19}, end: {row: 22}}, []); + { start: { row: 19 }, end: { row: 22 } }, []); function multi_req_copy_as_curl_test(name, editor_input, range, expected) { @@ -344,7 +349,7 @@ function multi_req_copy_as_curl_test(name, editor_input, range, expected) { multi_req_copy_as_curl_test("start to end, with comment", editor_input1, - {start: {row: 6}, end: {row: 13}}, ` + { start: { row: 6 }, end: { row: 13 } }, ` curl -XGET "http://localhost:9200/_stats?level=shards" #in between comment diff --git a/src/core_plugins/console/public/tests/src/integration_tests.js b/src/core_plugins/console/public/tests/src/integration_tests.js index aea330f7371d3..8d23bbedf7df3 100644 --- a/src/core_plugins/console/public/tests/src/integration_tests.js +++ b/src/core_plugins/console/public/tests/src/integration_tests.js @@ -3,7 +3,14 @@ let kb = require('../../src/kb'); let mappings = require('../../src/mappings'); let $ = require('jquery'); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + module, + ok, + asyncTest, + deepEqual, + equal, + start +} = QUnit; module("Integration", { setup: function () { @@ -96,7 +103,7 @@ function process_context_test(data, mapping, kb_schemes, request_line, test) { if (test["autoCompleteSet"]) { var expected_terms = _.map(test["autoCompleteSet"], function (t) { if (typeof t !== "object") { - t = {"name": t}; + t = { "name": t }; } return t; }); @@ -173,13 +180,13 @@ var SEARCH_KB = { "_search" ], data_autocomplete_rules: { - query: {match_all: {}, term: {"{field}": {__template: {"f": 1}}}}, + query: { match_all: {}, term: { "{field}": { __template: { "f": 1 } } } }, size: {}, facets: { __template: { "FIELD": {} }, - "*": {terms: {field: "{field}"}} + "*": { terms: { field: "{field}" } } } } } @@ -190,16 +197,16 @@ var MAPPING = { "index1": { "type1.1": { "properties": { - "field1.1.1": {"type": "string"}, - "field1.1.2": {"type": "string"} + "field1.1.1": { "type": "string" }, + "field1.1.2": { "type": "string" } } } }, "index2": { "type2.1": { "properties": { - "field2.1.1": {"type": "string"}, - "field2.1.2": {"type": "string"} + "field2.1.1": { "type": "string" }, + "field2.1.2": { "type": "string" } } } } @@ -213,12 +220,12 @@ context_tests( [ { name: "Empty doc", - cursor: {row: 0, column: 1}, + cursor: { row: 0, column: 1 }, initialValue: "", addTemplate: true, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 0, column: 1}, end: {row: 0, column: 1}}, + rangeToReplace: { start: { row: 0, column: 1 }, end: { row: 0, column: 1 } }, autoCompleteSet: ["facets", "query", "size"] } ] @@ -232,7 +239,7 @@ context_tests( [ { name: "Missing KB", - cursor: {row: 0, column: 1}, + cursor: { row: 0, column: 1 }, no_context: true } ] @@ -257,7 +264,7 @@ context_tests( [ { name: "Missing KB - global auto complete", - cursor: {row: 2, column: 5}, + cursor: { row: 2, column: 5 }, autoCompleteSet: ["t1"] } ] @@ -277,37 +284,37 @@ context_tests( [ { name: "existing dictionary key, no template", - cursor: {row: 1, column: 6}, + cursor: { row: 1, column: 6 }, initialValue: "query", addTemplate: false, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 1, column: 3}, end: {row: 1, column: 10}}, + rangeToReplace: { start: { row: 1, column: 3 }, end: { row: 1, column: 10 } }, autoCompleteSet: ["facets", "query", "size"] }, { name: "existing inner dictionary key", - cursor: {row: 2, column: 7}, + cursor: { row: 2, column: 7 }, initialValue: "field", addTemplate: false, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 2, column: 6}, end: {row: 2, column: 13}}, + rangeToReplace: { start: { row: 2, column: 6 }, end: { row: 2, column: 13 } }, autoCompleteSet: ["match_all", "term"] }, { name: "existing dictionary key, yes template", - cursor: {row: 4, column: 7}, + cursor: { row: 4, column: 7 }, initialValue: "facets", addTemplate: true, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 4, column: 3}, end: {row: 4, column: 15}}, + rangeToReplace: { start: { row: 4, column: 3 }, end: { row: 4, column: 15 } }, autoCompleteSet: ["facets", "query", "size"] }, { name: "ignoring meta keys", - cursor: {row: 4, column: 14}, + cursor: { row: 4, column: 14 }, no_context: true } ] @@ -327,42 +334,42 @@ context_tests( [ { name: "trailing comma, end of line", - cursor: {row: 4, column: 16}, + cursor: { row: 4, column: 16 }, initialValue: "", addTemplate: true, prefixToAdd: "", suffixToAdd: ", ", - rangeToReplace: {start: {row: 4, column: 16}, end: {row: 4, column: 16}}, + rangeToReplace: { start: { row: 4, column: 16 }, end: { row: 4, column: 16 } }, autoCompleteSet: ["facets", "query", "size"] }, { name: "trailing comma, beginning of line", - cursor: {row: 5, column: 1}, + cursor: { row: 5, column: 1 }, initialValue: "", addTemplate: true, prefixToAdd: "", suffixToAdd: ", ", - rangeToReplace: {start: {row: 5, column: 1}, end: {row: 5, column: 1}}, + rangeToReplace: { start: { row: 5, column: 1 }, end: { row: 5, column: 1 } }, autoCompleteSet: ["facets", "query", "size"] }, { name: "prefix comma, beginning of line", - cursor: {row: 6, column: 0}, + cursor: { row: 6, column: 0 }, initialValue: "", addTemplate: true, prefixToAdd: ", ", suffixToAdd: "", - rangeToReplace: {start: {row: 6, column: 0}, end: {row: 6, column: 0}}, + rangeToReplace: { start: { row: 6, column: 0 }, end: { row: 6, column: 0 } }, autoCompleteSet: ["facets", "query", "size"] }, { name: "prefix comma, end of line", - cursor: {row: 5, column: 14}, + cursor: { row: 5, column: 14 }, initialValue: "", addTemplate: true, prefixToAdd: ", ", suffixToAdd: "", - rangeToReplace: {start: {row: 5, column: 14}, end: {row: 5, column: 14}}, + rangeToReplace: { start: { row: 5, column: 14 }, end: { row: 5, column: 14 } }, autoCompleteSet: ["facets", "query", "size"] } @@ -385,11 +392,11 @@ context_tests( "_test" ], data_autocomplete_rules: { - object: {bla: 1}, + object: { bla: 1 }, array: [1], - value_one_of: {__one_of: [1, 2]}, + value_one_of: { __one_of: [1, 2] }, value: 3, - "*": {__one_of: [4, 5]} + "*": { __one_of: [4, 5] } } } } @@ -398,31 +405,31 @@ context_tests( [ { name: "not matching object when { is not opened", - cursor: {row: 1, column: 12}, + cursor: { row: 1, column: 12 }, initialValue: "", autoCompleteSet: ["{"] }, { name: "not matching array when [ is not opened", - cursor: {row: 2, column: 12}, + cursor: { row: 2, column: 12 }, initialValue: "", autoCompleteSet: ["["] }, { name: "matching value with one_of", - cursor: {row: 3, column: 19}, + cursor: { row: 3, column: 19 }, initialValue: "", autoCompleteSet: [1, 2] }, { name: "matching value", - cursor: {row: 4, column: 12}, + cursor: { row: 4, column: 12 }, initialValue: "", autoCompleteSet: [3] }, { name: "matching any value with one_of", - cursor: {row: 5, column: 21}, + cursor: { row: 5, column: 21 }, initialValue: "", autoCompleteSet: [4, 5] } @@ -445,14 +452,14 @@ context_tests( [ { name: "* matching everything", - cursor: {row: 5, column: 15}, + cursor: { row: 5, column: 15 }, initialValue: "", addTemplate: true, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 5, column: 15}, end: {row: 5, column: 15}}, + rangeToReplace: { start: { row: 5, column: 15 }, end: { row: 5, column: 15 } }, autoCompleteSet: [ - {name: "terms", meta: "API"} + { name: "terms", meta: "API" } ] } ] @@ -479,17 +486,17 @@ context_tests( [ { name: "{index} matching", - cursor: {row: 1, column: 15}, + cursor: { row: 1, column: 15 }, autoCompleteSet: [ - {name: "index1", meta: "index"}, - {name: "index2", meta: "index"} + { name: "index1", meta: "index" }, + { name: "index2", meta: "index" } ] } ] ); function tt(term, template, meta) { - term = {name: term, template: template}; + term = { name: term, template: template }; if (meta) { term.meta = meta; } @@ -514,8 +521,8 @@ context_tests( array: ["a", "b"], number: 1, object: {}, - fixed: {__template: {"a": 1}}, - oneof: {__one_of: ["o1", "o2"]} + fixed: { __template: { "a": 1 } }, + oneof: { __one_of: ["o1", "o2"] } } } } @@ -524,14 +531,14 @@ context_tests( [ { name: "Templates 1", - cursor: {row: 1, column: 0}, + cursor: { row: 1, column: 0 }, autoCompleteSet: [ - tt("array", []), tt("fixed", {a: 1}), tt("number", 1), tt("object", {}), tt("oneof", "o1") + tt("array", []), tt("fixed", { a: 1 }), tt("number", 1), tt("object", {}), tt("oneof", "o1") ] }, { name: "Templates - one off", - cursor: {row: 4, column: 12}, + cursor: { row: 4, column: 12 }, autoCompleteSet: [tt("o1"), tt("o2")] } ] @@ -561,7 +568,7 @@ context_tests( lines_regex: "other" }, "no_match": {} - }, {"always": {}}] + }, { "always": {} }] } } } @@ -571,7 +578,7 @@ context_tests( [ { name: "Conditionals", - cursor: {row: 2, column: 15}, + cursor: { row: 2, column: 15 }, autoCompleteSet: [ tt("always", {}), tt("match", {}) ] @@ -605,18 +612,18 @@ context_tests( "_endpoint" ], data_autocomplete_rules: { - any_of_numbers: {__template: [1, 2], __any_of: [1, 2, 3]}, + any_of_numbers: { __template: [1, 2], __any_of: [1, 2, 3] }, any_of_obj: { __template: [ - {c: 1} + { c: 1 } ], __any_of: [ - {a: 1, b: 2}, - {c: 1} + { a: 1, b: 2 }, + { c: 1 } ] }, any_of_mixed: { __any_of: [ - {a: 1}, + { a: 1 }, 3 ] } @@ -628,37 +635,37 @@ context_tests( [ { name: "Any of - templates", - cursor: {row: 1, column: 0}, + cursor: { row: 1, column: 0 }, autoCompleteSet: [ tt("any_of_mixed", []), tt("any_of_numbers", [1, 2]), tt("any_of_obj", [ - {c: 1} + { c: 1 } ]) ] }, { name: "Any of - numbers", - cursor: {row: 2, column: 2}, + cursor: { row: 2, column: 2 }, autoCompleteSet: [1, 2, 3] }, { name: "Any of - object", - cursor: {row: 6, column: 2}, + cursor: { row: 6, column: 2 }, autoCompleteSet: [ tt("a", 1), tt("b", 2), tt("c", 1) ] }, { name: "Any of - mixed - obj", - cursor: {row: 11, column: 2}, + cursor: { row: 11, column: 2 }, autoCompleteSet: [ tt("a", 1) ] }, { name: "Any of - mixed - both", - cursor: {row: 13, column: 2}, + cursor: { row: 13, column: 2 }, autoCompleteSet: [ tt("{"), tt(3) ] @@ -683,7 +690,7 @@ context_tests( [ { name: "Empty string as default", - cursor: {row: 0, column: 1}, + cursor: { row: 0, column: 1 }, autoCompleteSet: [tt("query", "")] } ] @@ -765,7 +772,7 @@ context_tests( [ { name: "Relative scope link test", - cursor: {row: 2, column: 12}, + cursor: { row: 2, column: 12 }, autoCompleteSet: [ tt("b", {}), tt("c", {}), tt("d", {}), tt("e", {}), tt("f", [ {} @@ -774,37 +781,37 @@ context_tests( }, { name: "External scope link test", - cursor: {row: 3, column: 12}, + cursor: { row: 3, column: 12 }, autoCompleteSet: [tt("t2", 1)] }, { name: "Global scope link test", - cursor: {row: 4, column: 12}, + cursor: { row: 4, column: 12 }, autoCompleteSet: [tt("t1", 2), tt("t1a", {})] }, { name: "Global scope link with an internal scope link", - cursor: {row: 5, column: 17}, + cursor: { row: 5, column: 17 }, autoCompleteSet: [tt("t1", 2), tt("t1a", {})] }, { name: "Entire endpoint scope link test", - cursor: {row: 7, column: 12}, + cursor: { row: 7, column: 12 }, autoCompleteSet: [tt("target", {})] }, { name: "A scope link within an array", - cursor: {row: 9, column: 10}, + cursor: { row: 9, column: 10 }, autoCompleteSet: [tt("t2", 1)] }, { name: "A function based scope link", - cursor: {row: 11, column: 12}, + cursor: { row: 11, column: 12 }, autoCompleteSet: [tt("a", 1), tt("b", 2)] }, { name: "A global scope link with wrong link", - cursor: {row: 12, column: 12}, + cursor: { row: 12, column: 12 }, assertThrows: /broken/ } @@ -834,7 +841,7 @@ context_tests( [ { name: "Top level scope link", - cursor: {row: 0, column: 1}, + cursor: { row: 0, column: 1 }, autoCompleteSet: [ tt("t1", 2) ] @@ -862,7 +869,7 @@ context_tests( [ { name: "Path after empty object", - cursor: {row: 1, column: 10}, + cursor: { row: 1, column: 10 }, autoCompleteSet: ["a", "b"] } ] @@ -878,8 +885,8 @@ context_tests( [ { name: "Replace an empty string", - cursor: {row: 1, column: 4}, - rangeToReplace: {start: {row: 1, column: 3}, end: {row: 1, column: 9}} + cursor: { row: 1, column: 4 }, + rangeToReplace: { start: { row: 1, column: 3 }, end: { row: 1, column: 9 } } } ] ); @@ -899,7 +906,7 @@ context_tests( patterns: ["_endpoint"], data_autocomplete_rules: { "a": [ - {b: 1} + { b: 1 } ] } } @@ -909,12 +916,12 @@ context_tests( [ { name: "List of objects - internal autocomplete", - cursor: {row: 3, column: 10}, + cursor: { row: 3, column: 10 }, autoCompleteSet: ["b"] }, { name: "List of objects - external template", - cursor: {row: 0, column: 1}, + cursor: { row: 0, column: 1 }, autoCompleteSet: [tt("a", [ {} ])] @@ -944,15 +951,15 @@ context_tests( [ { name: "Field completion as scope", - cursor: {row: 3, column: 10}, - autoCompleteSet: [tt("field1.1.1", {"f": 1}, "string"), tt("field1.1.2", {"f": 1}, "string")] + cursor: { row: 3, column: 10 }, + autoCompleteSet: [tt("field1.1.1", { "f": 1 }, "string"), tt("field1.1.2", { "f": 1 }, "string")] }, { name: "Field completion as value", - cursor: {row: 9, column: 23}, + cursor: { row: 9, column: 23 }, autoCompleteSet: [ - {name: "field1.1.1", meta: "string"}, - {name: "field1.1.2", meta: "string"} + { name: "field1.1.1", meta: "string" }, + { name: "field1.1.2", meta: "string" } ] } ] @@ -967,7 +974,7 @@ context_tests( [ { name: "initial doc start", - cursor: {row: 1, column: 0}, + cursor: { row: 1, column: 0 }, autoCompleteSet: ["{"], prefixToAdd: "", suffixToAdd: "" @@ -988,14 +995,14 @@ context_tests( [ { name: "Cursor rows after request end", - cursor: {row: 4, column: 0}, + cursor: { row: 4, column: 0 }, autoCompleteSet: ["GET", "PUT", "POST", "DELETE", "HEAD"], prefixToAdd: "", suffixToAdd: " " }, { name: "Cursor just after request end", - cursor: {row: 2, column: 1}, + cursor: { row: 2, column: 1 }, no_context: true } @@ -1033,7 +1040,7 @@ context_tests( [ { name: "Endpoints with slashes - no slash", - cursor: {row: 0, column: 8}, + cursor: { row: 0, column: 8 }, autoCompleteSet: ["_cluster/nodes/stats", "_cluster/stats", "_search", "index1", "index2"], prefixToAdd: "", suffixToAdd: "" @@ -1049,21 +1056,21 @@ context_tests( [ { name: "Endpoints with slashes - before slash", - cursor: {row: 0, column: 7}, + cursor: { row: 0, column: 7 }, autoCompleteSet: ["_cluster/nodes/stats", "_cluster/stats", "_search", "index1", "index2"], prefixToAdd: "", suffixToAdd: "" }, { name: "Endpoints with slashes - on slash", - cursor: {row: 0, column: 12}, + cursor: { row: 0, column: 12 }, autoCompleteSet: ["_cluster/nodes/stats", "_cluster/stats", "_search", "index1", "index2"], prefixToAdd: "", suffixToAdd: "" }, { name: "Endpoints with slashes - after slash", - cursor: {row: 0, column: 13}, + cursor: { row: 0, column: 13 }, autoCompleteSet: ["nodes/stats", "stats"], prefixToAdd: "", suffixToAdd: "" @@ -1079,10 +1086,10 @@ context_tests( [ { name: "Endpoints with slashes - after slash", - cursor: {row: 0, column: 14}, + cursor: { row: 0, column: 14 }, autoCompleteSet: [ - {name: "nodes/stats", meta: "endpoint"}, - {name: "stats", meta: "endpoint"} + { name: "nodes/stats", meta: "endpoint" }, + { name: "stats", meta: "endpoint" } ], prefixToAdd: "", suffixToAdd: "", @@ -1099,7 +1106,7 @@ context_tests( [ { name: "Endpoints with two slashes", - cursor: {row: 0, column: 20}, + cursor: { row: 0, column: 20 }, autoCompleteSet: ["stats"], prefixToAdd: "", suffixToAdd: "", @@ -1116,13 +1123,13 @@ context_tests( [ { name: "Immediately after space + method", - cursor: {row: 0, column: 4}, + cursor: { row: 0, column: 4 }, autoCompleteSet: [ - {name: "_cluster/nodes/stats", meta: "endpoint"}, - {name: "_cluster/stats", meta: "endpoint"}, - {name: "_search", meta: "endpoint"}, - {name: "index1", meta: "index"}, - {name: "index2", meta: "index"} + { name: "_cluster/nodes/stats", meta: "endpoint" }, + { name: "_cluster/stats", meta: "endpoint" }, + { name: "_search", meta: "endpoint" }, + { name: "index1", meta: "index" }, + { name: "index2", meta: "index" } ], prefixToAdd: "", suffixToAdd: "", @@ -1139,13 +1146,13 @@ context_tests( [ { name: "Endpoints by subpart", - cursor: {row: 0, column: 6}, + cursor: { row: 0, column: 6 }, autoCompleteSet: [ - {name: "_cluster/nodes/stats", meta: "endpoint"}, - {name: "_cluster/stats", meta: "endpoint"}, - {name: "_search", meta: "endpoint"}, - {name: "index1", meta: "index"}, - {name: "index2", meta: "index"} + { name: "_cluster/nodes/stats", meta: "endpoint" }, + { name: "_cluster/stats", meta: "endpoint" }, + { name: "_search", meta: "endpoint" }, + { name: "index1", meta: "index" }, + { name: "index2", meta: "index" } ], prefixToAdd: "", suffixToAdd: "", @@ -1162,13 +1169,13 @@ context_tests( [ { name: "Endpoints by subpart", - cursor: {row: 0, column: 7}, + cursor: { row: 0, column: 7 }, autoCompleteSet: [ - {name: "_cluster/nodes/stats", meta: "endpoint"}, - {name: "_cluster/stats", meta: "endpoint"}, - {name: "_search", meta: "endpoint"}, - {name: "index1", meta: "index"}, - {name: "index2", meta: "index"} + { name: "_cluster/nodes/stats", meta: "endpoint" }, + { name: "_cluster/stats", meta: "endpoint" }, + { name: "_search", meta: "endpoint" }, + { name: "index1", meta: "index" }, + { name: "index2", meta: "index" } ], prefixToAdd: "", suffixToAdd: "", @@ -1186,13 +1193,13 @@ context_tests( [ { name: "Params just after ?", - cursor: {row: 0, column: 12}, + cursor: { row: 0, column: 12 }, autoCompleteSet: [ - {name: "filter_path", meta: "param", "insert_value": "filter_path="}, - {name: "format", meta: "param", "insert_value": "format="}, - {name: "pretty", meta: "flag"}, - {name: "scroll", meta: "param", "insert_value": "scroll="}, - {name: "search_type", meta: "param", "insert_value": "search_type="}, + { name: "filter_path", meta: "param", "insert_value": "filter_path=" }, + { name: "format", meta: "param", "insert_value": "format=" }, + { name: "pretty", meta: "flag" }, + { name: "scroll", meta: "param", "insert_value": "scroll=" }, + { name: "search_type", meta: "param", "insert_value": "search_type=" }, ], prefixToAdd: "", suffixToAdd: "" @@ -1208,10 +1215,10 @@ context_tests( [ { name: "Params values", - cursor: {row: 0, column: 19}, + cursor: { row: 0, column: 19 }, autoCompleteSet: [ - {name: "json", meta: "format"}, - {name: "yaml", meta: "format"} + { name: "json", meta: "format" }, + { name: "yaml", meta: "format" } ], prefixToAdd: "", suffixToAdd: "" @@ -1227,13 +1234,13 @@ context_tests( [ { name: "Params after amp", - cursor: {row: 0, column: 24}, + cursor: { row: 0, column: 24 }, autoCompleteSet: [ - {name: "filter_path", meta: "param", "insert_value": "filter_path="}, - {name: "format", meta: "param", "insert_value": "format="}, - {name: "pretty", meta: "flag"}, - {name: "scroll", meta: "param", "insert_value": "scroll="}, - {name: "search_type", meta: "param", "insert_value": "search_type="}, + { name: "filter_path", meta: "param", "insert_value": "filter_path=" }, + { name: "format", meta: "param", "insert_value": "format=" }, + { name: "pretty", meta: "flag" }, + { name: "scroll", meta: "param", "insert_value": "scroll=" }, + { name: "search_type", meta: "param", "insert_value": "search_type=" }, ], prefixToAdd: "", suffixToAdd: "" @@ -1249,17 +1256,17 @@ context_tests( [ { name: "Params on existing param", - cursor: {row: 0, column: 26}, + cursor: { row: 0, column: 26 }, rangeToReplace: { - start: {row: 0, column: 24}, - end: {row: 0, column: 30} + start: { row: 0, column: 24 }, + end: { row: 0, column: 30 } }, autoCompleteSet: [ - {name: "filter_path", meta: "param", "insert_value": "filter_path="}, - {name: "format", meta: "param", "insert_value": "format="}, - {name: "pretty", meta: "flag"}, - {name: "scroll", meta: "param", "insert_value": "scroll="}, - {name: "search_type", meta: "param", "insert_value": "search_type="}, + { name: "filter_path", meta: "param", "insert_value": "filter_path=" }, + { name: "format", meta: "param", "insert_value": "format=" }, + { name: "pretty", meta: "flag" }, + { name: "scroll", meta: "param", "insert_value": "scroll=" }, + { name: "search_type", meta: "param", "insert_value": "search_type=" }, ], prefixToAdd: "", suffixToAdd: "" @@ -1275,14 +1282,14 @@ context_tests( [ { name: "Params on existing value", - cursor: {row: 0, column: 37}, + cursor: { row: 0, column: 37 }, rangeToReplace: { - start: {row: 0, column: 36}, - end: {row: 0, column: 39} + start: { row: 0, column: 36 }, + end: { row: 0, column: 39 } }, autoCompleteSet: [ - {name: "count", meta: "search_type"}, - {name: "query_then_fetch", meta: "search_type"}, + { name: "count", meta: "search_type" }, + { name: "query_then_fetch", meta: "search_type" }, ], prefixToAdd: "", suffixToAdd: "" @@ -1297,14 +1304,14 @@ context_tests( [ { name: "Params on just after = with existing value", - cursor: {row: 0, column: 36}, + cursor: { row: 0, column: 36 }, rangeToReplace: { - start: {row: 0, column: 36}, - end: {row: 0, column: 36} + start: { row: 0, column: 36 }, + end: { row: 0, column: 36 } }, autoCompleteSet: [ - {name: "count", meta: "search_type"}, - {name: "query_then_fetch", meta: "search_type"}, + { name: "count", meta: "search_type" }, + { name: "query_then_fetch", meta: "search_type" }, ], prefixToAdd: "", suffixToAdd: "" @@ -1327,32 +1334,32 @@ context_tests( [ { name: "fullurl - existing dictionary key, no template", - cursor: {row: 1, column: 6}, + cursor: { row: 1, column: 6 }, initialValue: "query", addTemplate: false, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 1, column: 3}, end: {row: 1, column: 10}}, + rangeToReplace: { start: { row: 1, column: 3 }, end: { row: 1, column: 10 } }, autoCompleteSet: ["facets", "query", "size"] }, { name: "fullurl - existing inner dictionary key", - cursor: {row: 2, column: 7}, + cursor: { row: 2, column: 7 }, initialValue: "field", addTemplate: false, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 2, column: 6}, end: {row: 2, column: 13}}, + rangeToReplace: { start: { row: 2, column: 6 }, end: { row: 2, column: 13 } }, autoCompleteSet: ["match_all", "term"] }, { name: "fullurl - existing dictionary key, yes template", - cursor: {row: 4, column: 7}, + cursor: { row: 4, column: 7 }, initialValue: "facets", addTemplate: true, prefixToAdd: "", suffixToAdd: "", - rangeToReplace: {start: {row: 4, column: 3}, end: {row: 4, column: 15}}, + rangeToReplace: { start: { row: 4, column: 3 }, end: { row: 4, column: 15 } }, autoCompleteSet: ["facets", "query", "size"] } ] diff --git a/src/core_plugins/console/public/tests/src/kb_tests.js b/src/core_plugins/console/public/tests/src/kb_tests.js index f9a51bbbb6b19..0959213896932 100644 --- a/src/core_plugins/console/public/tests/src/kb_tests.js +++ b/src/core_plugins/console/public/tests/src/kb_tests.js @@ -2,7 +2,11 @@ let kb = require('../../src/kb'); let mappings = require('../../src/mappings'); let autocomplete_engine = require('../../src/autocomplete/engine'); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + test, + module, + deepEqual +} = QUnit; module("Knowledge base", { setup: function () { @@ -19,8 +23,8 @@ var MAPPING = { "index1": { "type1.1": { "properties": { - "field1.1.1": {"type": "string"}, - "field1.1.2": {"type": "long"} + "field1.1.1": { "type": "string" }, + "field1.1.2": { "type": "long" } } }, "type1.2": { @@ -30,8 +34,8 @@ var MAPPING = { "index2": { "type2.1": { "properties": { - "field2.1.1": {"type": "string"}, - "field2.1.2": {"type": "string"} + "field2.1.1": { "type": "string" }, + "field2.1.2": { "type": "string" } } } } @@ -42,13 +46,13 @@ function testUrlContext(tokenPath, otherTokenValues, expectedContext) { if (expectedContext.autoCompleteSet) { expectedContext.autoCompleteSet = _.map(expectedContext.autoCompleteSet, function (t) { if (_.isString(t)) { - t = {name: t} + t = { name: t } } return t; }) } - var context = {otherTokenValues: otherTokenValues}; + var context = { otherTokenValues: otherTokenValues }; autocomplete_engine.populateContext(tokenPath, context, null, expectedContext.autoCompleteSet, kb.getTopLevelUrlCompleteComponents() ); @@ -62,7 +66,7 @@ function testUrlContext(tokenPath, otherTokenValues, expectedContext) { function norm(t) { if (_.isString(t)) { - return {name: t}; + return { name: t }; } return t; } @@ -78,11 +82,11 @@ function testUrlContext(tokenPath, otherTokenValues, expectedContext) { } function t(term) { - return {name: term, meta: "type"}; + return { name: term, meta: "type" }; } function i(term) { - return {name: term, meta: "index"}; + return { name: term, meta: "index" }; } function index_test(name, tokenPath, otherTokenValues, expectedContext) { @@ -93,7 +97,7 @@ function index_test(name, tokenPath, otherTokenValues, expectedContext) { _multi_indices: { patterns: ["{indices}/_multi_indices"] }, - _single_index: {patterns: ["{index}/_single_index"]}, + _single_index: { patterns: ["{index}/_single_index"] }, _no_index: { // testing default patters // patterns: ["_no_index"] @@ -110,22 +114,22 @@ function index_test(name, tokenPath, otherTokenValues, expectedContext) { } index_test("Index integration 1", [], [], - {autoCompleteSet: ["_no_index", i("index1"), i("index2")]} + { autoCompleteSet: ["_no_index", i("index1"), i("index2")] } ); index_test("Index integration 2", [], ["index1"], // still return _no_index as index1 is not committed to yet. - {autoCompleteSet: ["_no_index", i("index2")]} + { autoCompleteSet: ["_no_index", i("index2")] } ); index_test("Index integration 2", ["index1"], [], - {indices: ["index1"], autoCompleteSet: ["_multi_indices", "_single_index"]} + { indices: ["index1"], autoCompleteSet: ["_multi_indices", "_single_index"] } ); index_test("Index integration 2", [ ["index1", "index2"] ], [], - {indices: ["index1", "index2"], autoCompleteSet: ["_multi_indices"]} + { indices: ["index1", "index2"], autoCompleteSet: ["_multi_indices"] } ); function type_test(name, tokenPath, otherTokenValues, expectedContext) { @@ -133,9 +137,9 @@ function type_test(name, tokenPath, otherTokenValues, expectedContext) { var test_api = kb._test.loadApisFromJson({ "type_test": { endpoints: { - _multi_types: {patterns: ["{indices}/{types}/_multi_types"]}, - _single_type: {patterns: ["{indices}/{type}/_single_type"]}, - _no_types: {patterns: ["{indices}/_no_types"]} + _multi_types: { patterns: ["{indices}/{types}/_multi_types"] }, + _single_type: { patterns: ["{indices}/{type}/_single_type"] }, + _no_types: { patterns: ["{indices}/_no_types"] } } } }, kb._test.globalUrlComponentFactories); @@ -149,24 +153,24 @@ function type_test(name, tokenPath, otherTokenValues, expectedContext) { } type_test("Type integration 1", ["index1"], [], - {indices: ["index1"], autoCompleteSet: ["_no_types", t("type1.1"), t("type1.2")]} + { indices: ["index1"], autoCompleteSet: ["_no_types", t("type1.1"), t("type1.2")] } ); type_test("Type integration 2", ["index1"], ["type1.2"], // we are not yet comitted to type1.2, so _no_types is returned - {indices: ["index1"], autoCompleteSet: ["_no_types", t("type1.1")]} + { indices: ["index1"], autoCompleteSet: ["_no_types", t("type1.1")] } ); type_test("Type integration 3", ["index2"], [], - {indices: ["index2"], autoCompleteSet: ["_no_types", t("type2.1")]} + { indices: ["index2"], autoCompleteSet: ["_no_types", t("type2.1")] } ); type_test("Type integration 4", ["index1", "type1.2"], [], - {indices: ["index1"], types: ["type1.2"], autoCompleteSet: ["_multi_types", "_single_type"]} + { indices: ["index1"], types: ["type1.2"], autoCompleteSet: ["_multi_types", "_single_type"] } ); type_test("Type integration 5", [ ["index1", "index2"], ["type1.2", "type1.1"] ], [], - {indices: ["index1", "index2"], types: ["type1.2", "type1.1"], autoCompleteSet: ["_multi_types"]} + { indices: ["index1", "index2"], types: ["type1.2", "type1.1"], autoCompleteSet: ["_multi_types"] } ); diff --git a/src/core_plugins/console/public/tests/src/mapping_tests.js b/src/core_plugins/console/public/tests/src/mapping_tests.js index cd79c6f3d4c54..fa1ecbe6a82a9 100644 --- a/src/core_plugins/console/public/tests/src/mapping_tests.js +++ b/src/core_plugins/console/public/tests/src/mapping_tests.js @@ -1,6 +1,10 @@ let mappings = require('../../src/mappings'); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + test, + module, + deepEqual +} = QUnit; module("Mappings", { setup: function () { @@ -22,7 +26,7 @@ function fc(f1, f2) { } function f(name, type) { - return {name: name, type: type || "string"}; + return { name: name, type: type || "string" }; } test("Multi fields", function () { @@ -34,16 +38,16 @@ test("Multi fields", function () { "type": "multi_field", "path": "just_name", "fields": { - "first_name": {"type": "string", "index": "analyzed"}, - "any_name": {"type": "string", "index": "analyzed"} + "first_name": { "type": "string", "index": "analyzed" }, + "any_name": { "type": "string", "index": "analyzed" } } }, "last_name": { "type": "multi_field", "path": "just_name", "fields": { - "last_name": {"type": "string", "index": "analyzed"}, - "any_name": {"type": "string", "index": "analyzed"} + "last_name": { "type": "string", "index": "analyzed" }, + "any_name": { "type": "string", "index": "analyzed" } } } } @@ -64,13 +68,13 @@ test("Multi fields 1.0 style", function () { "type": "string", "index": "analyzed", "path": "just_name", "fields": { - "any_name": {"type": "string", "index": "analyzed"} + "any_name": { "type": "string", "index": "analyzed" } } }, "last_name": { "type": "string", "index": "no", "fields": { - "raw": {"type": "string", "index": "analyzed"} + "raw": { "type": "string", "index": "analyzed" } } } } @@ -132,14 +136,14 @@ QUnit.test("Nested fields", function () { "properties": { "name": { "properties": { - "first_name": {"type": "string"}, - "last_name": {"type": "string"} + "first_name": { "type": "string" }, + "last_name": { "type": "string" } } }, - "sid": {"type": "string", "index": "not_analyzed"} + "sid": { "type": "string", "index": "not_analyzed" } } }, - "message": {"type": "string"} + "message": { "type": "string" } } } } @@ -161,10 +165,10 @@ test("Enabled fields", function () { "type": "object", "enabled": false }, - "sid": {"type": "string", "index": "not_analyzed"} + "sid": { "type": "string", "index": "not_analyzed" } } }, - "message": {"type": "string"} + "message": { "type": "string" } } } } @@ -184,16 +188,16 @@ test("Path tests", function () { "type": "object", "path": "just_name", "properties": { - "first1": {"type": "string"}, - "last1": {"type": "string", "index_name": "i_last_1"} + "first1": { "type": "string" }, + "last1": { "type": "string", "index_name": "i_last_1" } } }, "name2": { "type": "object", "path": "full", "properties": { - "first2": {"type": "string"}, - "last2": {"type": "string", "index_name": "i_last_2"} + "first2": { "type": "string" }, + "last2": { "type": "string", "index_name": "i_last_2" } } } } @@ -210,7 +214,7 @@ test("Use index_name tests", function () { "index": { "person": { "properties": { - "last1": {"type": "string", "index_name": "i_last_1"} + "last1": { "type": "string", "index_name": "i_last_1" } } } } @@ -244,14 +248,14 @@ test("Aliases", function () { "test_index1": { "type1": { "properties": { - "last1": {"type": "string", "index_name": "i_last_1"} + "last1": { "type": "string", "index_name": "i_last_1" } } } }, "test_index2": { "type2": { "properties": { - "last1": {"type": "string", "index_name": "i_last_1"} + "last1": { "type": "string", "index_name": "i_last_1" } } } } diff --git a/src/core_plugins/console/public/tests/src/tokenization_tests.js b/src/core_plugins/console/public/tests/src/tokenization_tests.js index 5162609d9dd9a..bcd6a55ca5269 100644 --- a/src/core_plugins/console/public/tests/src/tokenization_tests.js +++ b/src/core_plugins/console/public/tests/src/tokenization_tests.js @@ -1,9 +1,13 @@ let ace = require('ace'); -let $ = require('jquery'); let input = require('../../src/input'); var token_iterator = ace.require("ace/token_iterator"); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + module, + asyncTest, + deepEqual, + start +} = QUnit; module("Tokenization", { setup: function () { @@ -24,7 +28,7 @@ function tokensAsList() { t = input.parser.nextNonEmptyToken(iter); } while (t) { - ret.push({value: t.value, type: t.type}); + ret.push({ value: t.value, type: t.type }); t = input.parser.nextNonEmptyToken(iter); } @@ -51,7 +55,7 @@ function token_test(token_list, prefix, data) { var tokens = tokensAsList(); var normTokenList = []; for (var i = 0; i < token_list.length; i++) { - normTokenList.push({type: token_list[i++], value: token_list[i]}); + normTokenList.push({ type: token_list[i++], value: token_list[i] }); } deepEqual(tokens, normTokenList, "Doc:\n" + data); diff --git a/src/core_plugins/console/public/tests/src/url_autocomplete_tests.js b/src/core_plugins/console/public/tests/src/url_autocomplete_tests.js index e6f63c2a4398a..1db6035921faf 100644 --- a/src/core_plugins/console/public/tests/src/url_autocomplete_tests.js +++ b/src/core_plugins/console/public/tests/src/url_autocomplete_tests.js @@ -2,7 +2,11 @@ let _ = require('lodash'); let url_pattern_matcher = require('../../src/autocomplete/url_pattern_matcher'); let autocomplete_engine = require('../../src/autocomplete/engine'); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + test, + module, + deepEqual +} = QUnit; module("Url autocomplete"); @@ -32,7 +36,7 @@ function patterns_test(name, endpoints, tokenPath, expectedContext, globalUrlCom if (expectedContext.autoCompleteSet) { expectedContext.autoCompleteSet = _.map(expectedContext.autoCompleteSet, function (t) { if (_.isString(t)) { - t = {name: t} + t = { name: t } } return t; }); @@ -63,7 +67,7 @@ function patterns_test(name, endpoints, tokenPath, expectedContext, globalUrlCom function t(name, meta) { if (meta) { - return {name: name, meta: meta}; + return { name: name, meta: meta }; } return name; } @@ -79,14 +83,14 @@ function t(name, meta) { patterns_test("simple single path - completion", endpoints, "a/b$", - {endpoint: "1"} + { endpoint: "1" } ); patterns_test("simple single path - completion, with auto complete", endpoints, "a/b", - {autoCompleteSet: []} + { autoCompleteSet: [] } ); patterns_test("simple single path - partial, without auto complete", @@ -98,13 +102,13 @@ function t(name, meta) { patterns_test("simple single path - partial, with auto complete", endpoints, "a", - {autoCompleteSet: ["b"]} + { autoCompleteSet: ["b"] } ); patterns_test("simple single path - partial, with auto complete", endpoints, [], - {autoCompleteSet: ["a/b"]} + { autoCompleteSet: ["a/b"] } ); patterns_test("simple single path - different path", @@ -132,31 +136,31 @@ function t(name, meta) { patterns_test("shared path - completion 1", endpoints, "a/b$", - {endpoint: "1"} + { endpoint: "1" } ); patterns_test("shared path - completion 2", endpoints, "a/c$", - {endpoint: "2"} + { endpoint: "2" } ); patterns_test("shared path - completion 1 with param", endpoints, "a/b/v$", - {endpoint: "1", p: "v"} + { endpoint: "1", p: "v" } ); patterns_test("shared path - partial, with auto complete", endpoints, "a", - {autoCompleteSet: ["b", "c"]} + { autoCompleteSet: ["b", "c"] } ); patterns_test("shared path - partial, with auto complete of param, no options", endpoints, "a/b", - {autoCompleteSet: []} + { autoCompleteSet: [] } ); patterns_test("shared path - partial, without auto complete", @@ -168,7 +172,7 @@ function t(name, meta) { patterns_test("shared path - different path - with auto complete", endpoints, "a/e", - {autoCompleteSet: []} + { autoCompleteSet: [] } ); patterns_test("shared path - different path - without auto complete", @@ -198,25 +202,25 @@ function t(name, meta) { patterns_test("option testing - completion 1", endpoints, "a/a$", - {endpoint: "1", p: ["a"]} + { endpoint: "1", p: ["a"] } ); patterns_test("option testing - completion 2", endpoints, "a/b$", - {endpoint: "1", p: ["b"]} + { endpoint: "1", p: ["b"] } ); patterns_test("option testing - completion 3", endpoints, "a/b,a$", - {endpoint: "1", p: ["b", "a"]} + { endpoint: "1", p: ["b", "a"] } ); patterns_test("option testing - completion 4", endpoints, "a/c$", - {endpoint: "2"} + { endpoint: "2" } ); patterns_test("option testing - completion 5", @@ -228,7 +232,7 @@ function t(name, meta) { patterns_test("option testing - partial, with auto complete", endpoints, "a", - {autoCompleteSet: [t("a", "p"), t("b", "p"), "c"]} + { autoCompleteSet: [t("a", "p"), t("b", "p"), "c"] } ); patterns_test("option testing - partial, without auto complete", @@ -241,7 +245,7 @@ function t(name, meta) { patterns_test("option testing - different path - with auto complete", endpoints, "a/e", - {autoCompleteSet: []} + { autoCompleteSet: [] } ); @@ -284,14 +288,14 @@ function t(name, meta) { patterns_test("global parameters testing - completion 1", endpoints, "a/a$", - {endpoint: "1", p: ["a"]}, + { endpoint: "1", p: ["a"] }, globalFactories ); patterns_test("global parameters testing - completion 2", endpoints, "b/g1$", - {endpoint: "2", p: ["g1"]}, + { endpoint: "2", p: ["g1"] }, globalFactories ); @@ -299,27 +303,27 @@ function t(name, meta) { patterns_test("global parameters testing - partial, with auto complete", endpoints, "a", - {autoCompleteSet: [t("a", "p"), t("b", "p")]}, + { autoCompleteSet: [t("a", "p"), t("b", "p")] }, globalFactories ); patterns_test("global parameters testing - partial, with auto complete 2", endpoints, "b", - {autoCompleteSet: [t("g1", "p"), t("g2", "p"), t("la", "l"), t("lb", "l")]}, + { autoCompleteSet: [t("g1", "p"), t("g2", "p"), t("la", "l"), t("lb", "l")] }, globalFactories ); patterns_test("Non valid token acceptance - partial, with auto complete 1", endpoints, "b/la", - {autoCompleteSet: ["c"], "l": ["la"]}, + { autoCompleteSet: ["c"], "l": ["la"] }, globalFactories ); patterns_test("Non valid token acceptance - partial, with auto complete 2", endpoints, "b/non_valid", - {autoCompleteSet: ["c"], "l": ["non_valid"]}, + { autoCompleteSet: ["c"], "l": ["non_valid"] }, globalFactories ); @@ -336,25 +340,25 @@ function t(name, meta) { patterns_test("look ahead - autocomplete before param 1", endpoints, "a", - {autoCompleteSet: ["b"]} + { autoCompleteSet: ["b"] } ); patterns_test("look ahead - autocomplete before param 2", endpoints, [], - {autoCompleteSet: ["a/b"]} + { autoCompleteSet: ["a/b"] } ); patterns_test("look ahead - autocomplete after param 1", endpoints, "a/b/v", - {autoCompleteSet: ["c/e"], "p": "v"} + { autoCompleteSet: ["c/e"], "p": "v" } ); patterns_test("look ahead - autocomplete after param 2", endpoints, "a/b/v/c", - {autoCompleteSet: ["e"], "p": "v"} + { autoCompleteSet: ["e"], "p": "v" } ); })(); @@ -380,7 +384,7 @@ function t(name, meta) { patterns_test("Competing endpoints - priority 1", e, "a/b$", - {method: "GET", endpoint: "1_param", "p": "b"} + { method: "GET", endpoint: "1_param", "p": "b" } ); e = _.cloneDeep(endpoints); e["1_param"].priority = 1; @@ -388,7 +392,7 @@ function t(name, meta) { patterns_test("Competing endpoints - priority 2", e, "a/b$", - {method: "GET", endpoint: "2_explicit"} + { method: "GET", endpoint: "2_explicit" } ); e = _.cloneDeep(endpoints); @@ -396,7 +400,7 @@ function t(name, meta) { patterns_test("Competing endpoints - priority 3", e, "a/b$", - {method: "GET", endpoint: "2_explicit"} + { method: "GET", endpoint: "2_explicit" } ); })(); @@ -431,44 +435,44 @@ function t(name, meta) { patterns_test("Competing endpoint - sub url of another - auto complete", endpoints, "a", - {method: "GET", autoCompleteSet: ["b"]} + { method: "GET", autoCompleteSet: ["b"] } ); patterns_test("Competing endpoint - sub url of another, complete 1", endpoints, "a$", - {method: "GET", endpoint: "1_GET"} + { method: "GET", endpoint: "1_GET" } ); patterns_test("Competing endpoint - sub url of another, complete 2", endpoints, "a$", - {method: "PUT", endpoint: "1_PUT"} + { method: "PUT", endpoint: "1_PUT" } ); patterns_test("Competing endpoint - sub url of another, complete 3", endpoints, "a$", - {method: "DELETE"} + { method: "DELETE" } ); patterns_test("Competing endpoint - extension of another, complete 1, auto complete", endpoints, "a/b$", - {method: "PUT", autoCompleteSet: []} + { method: "PUT", autoCompleteSet: [] } ); patterns_test("Competing endpoint - extension of another, complete 1", endpoints, "a/b$", - {method: "GET", endpoint: "2_GET"} + { method: "GET", endpoint: "2_GET" } ); patterns_test("Competing endpoint - extension of another, complete 1", endpoints, "a/b$", - {method: "DELETE", endpoint: "2_DELETE"} + { method: "DELETE", endpoint: "2_DELETE" } ); patterns_test("Competing endpoint - extension of another, complete 1", endpoints, "a/b$", - {method: "PUT"} + { method: "PUT" } ); })(); diff --git a/src/core_plugins/console/public/tests/src/url_params_tests.js b/src/core_plugins/console/public/tests/src/url_params_tests.js index a529e67b42b2f..b4a1490d20728 100644 --- a/src/core_plugins/console/public/tests/src/url_params_tests.js +++ b/src/core_plugins/console/public/tests/src/url_params_tests.js @@ -2,7 +2,11 @@ let _ = require('lodash'); let url_params = require('../../src/autocomplete/url_params'); let autocomplete_engine = require('../../src/autocomplete/engine'); -var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit; +var { + test, + module, + deepEqual +} = QUnit; module("Url params"); @@ -23,7 +27,7 @@ function param_test(name, description, tokenPath, expectedContext, globalParams) if (expectedContext.autoCompleteSet) { expectedContext.autoCompleteSet = _.map(expectedContext.autoCompleteSet, function (t) { if (_.isString(t)) { - t = {name: t} + t = { name: t } } return t; }); @@ -49,14 +53,14 @@ function param_test(name, description, tokenPath, expectedContext, globalParams) function t(name, meta, insert_value) { var r = name; if (meta) { - r = {name: name, meta: meta}; + r = { name: name, meta: meta }; if (meta === "param" && !insert_value) { insert_value = name + "="; } } if (insert_value) { if (_.isString(r)) { - r = {name: name} + r = { name: name } } r.insert_value = insert_value; } @@ -71,19 +75,19 @@ function t(name, meta, insert_value) { param_test("settings params", params, "a/1", - {"a": ["1"]} + { "a": ["1"] } ); param_test("autocomplete top level", params, [], - {autoCompleteSet: [t("a", "param"), t("b", "flag")]} + { autoCompleteSet: [t("a", "param"), t("b", "flag")] } ); param_test("autocomplete top level, with defaults", params, [], - {autoCompleteSet: [t("a", "param"), t("b", "flag"), t("c", "param")]}, + { autoCompleteSet: [t("a", "param"), t("b", "flag"), t("c", "param")] }, { "c": [2] } @@ -92,13 +96,13 @@ function t(name, meta, insert_value) { param_test("autocomplete values", params, "a", - {autoCompleteSet: [t("1", "a"), t("2", "a")]} + { autoCompleteSet: [t("1", "a"), t("2", "a")] } ); param_test("autocomplete values flag", params, "b", - {autoCompleteSet: [t("true", "b"), t("false", "b")]} + { autoCompleteSet: [t("true", "b"), t("false", "b")] } ); diff --git a/src/core_plugins/console/public/tests/webpackShims/qunit-1.10.0.js b/src/core_plugins/console/public/tests/webpackShims/qunit-1.10.0.js index 002d5f5a7eaeb..4014c1f469522 100644 --- a/src/core_plugins/console/public/tests/webpackShims/qunit-1.10.0.js +++ b/src/core_plugins/console/public/tests/webpackShims/qunit-1.10.0.js @@ -1202,7 +1202,7 @@ function extractStacktrace(e, offset) { offset = offset === undefined ? 3 : offset; - var stack, include, i, regex; + var stack, include, i; if (e.stacktrace) { // Opera @@ -1309,7 +1309,7 @@ } } - function checkPollution(name) { + function checkPollution() { var newGlobals, deletedGlobals, old = config.pollution; diff --git a/src/core_plugins/console/server/__tests__/wildcard_matcher.js b/src/core_plugins/console/server/__tests__/wildcard_matcher.js index 8ef3131891a83..32dac21e31476 100644 --- a/src/core_plugins/console/server/__tests__/wildcard_matcher.js +++ b/src/core_plugins/console/server/__tests__/wildcard_matcher.js @@ -1,6 +1,3 @@ -/* eslint-env mocha */ -import expect from 'expect.js' - import { WildcardMatcher } from '../wildcard_matcher' function should(candidate, ...constructorArgs) { diff --git a/src/core_plugins/console/server/proxy_config.js b/src/core_plugins/console/server/proxy_config.js index 455784df2d125..3e96d1750fd7b 100644 --- a/src/core_plugins/console/server/proxy_config.js +++ b/src/core_plugins/console/server/proxy_config.js @@ -1,15 +1,10 @@ -import { memoize, values } from 'lodash' +import { values } from 'lodash' import { format as formatUrl } from 'url' import { Agent as HttpsAgent } from 'https' import { readFileSync } from 'fs' import { WildcardMatcher } from './wildcard_matcher' -const makeHttpsAgent = memoize( - opts => new HttpsAgent(opts), - opts => JSON.stringify(opts) -) - export class ProxyConfig { constructor(config) { config = Object.assign({}, config); diff --git a/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js b/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js index 05ce703ab2de6..fccc8bfde707c 100644 --- a/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js +++ b/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js @@ -2,13 +2,13 @@ import visDebugSpyPanelTemplate from 'plugins/dev_mode/vis_debug_spy_panel.html' // register the spy mode or it won't show up in the spys require('ui/registry/spy_modes').register(VisDetailsSpyProvider); -function VisDetailsSpyProvider(Notifier, $filter, $rootScope, config) { +function VisDetailsSpyProvider() { return { name: 'debug', display: 'Debug', template: visDebugSpyPanelTemplate, order: 5, - link: function ($scope, $el) { + link: function ($scope) { $scope.$watch('vis.getEnabledState() | json', function (json) { $scope.visStateJson = json; }); diff --git a/src/core_plugins/elasticsearch/index.js b/src/core_plugins/elasticsearch/index.js index 46cce51c73d59..391323aad4569 100644 --- a/src/core_plugins/elasticsearch/index.js +++ b/src/core_plugins/elasticsearch/index.js @@ -46,7 +46,7 @@ module.exports = function ({ Plugin }) { } }, - init(server, options) { + init(server) { const kibanaIndex = server.config().get('kibana.index'); // Expose the client to the server diff --git a/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js b/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js index 74d43816d8384..06600e5f8d605 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js @@ -12,7 +12,6 @@ describe('plugins/elasticsearch', () => { const KIBANA_VERSION = '5.1.0'; let server; - let plugin; beforeEach(function () { server = { diff --git a/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js b/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js index d8b76e14d7d45..d2c98858815b9 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js @@ -1,5 +1,4 @@ import expect from 'expect.js'; -import sinon from 'sinon'; import isEsCompatibleWithKibana from '../is_es_compatible_with_kibana'; diff --git a/src/core_plugins/elasticsearch/lib/__tests__/is_upgradeable.js b/src/core_plugins/elasticsearch/lib/__tests__/is_upgradeable.js index 0e9b064393d15..400990a9b8265 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/is_upgradeable.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/is_upgradeable.js @@ -1,6 +1,5 @@ import _ from 'lodash'; import expect from 'expect.js'; -import sinon from 'sinon'; import isUpgradeable from '../is_upgradeable'; import pkg from '../../../../utils/package_json'; @@ -8,7 +7,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) { @@ -44,7 +43,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, @@ -58,7 +57,7 @@ describe('plugins/elasticsearch', function () { }); it('should handle _id of @@version', function () { - let doc = { + const doc = { '_index': '.kibana', '_type': 'config', '_id': '@@version', diff --git a/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js b/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js index 0859ae8640b3f..a3f93ba1897e9 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js @@ -1,7 +1,6 @@ import expect from 'expect.js'; import mapUri from '../map_uri'; import { get, defaults } from 'lodash'; -import sinon from 'sinon'; describe('plugins/elasticsearch', function () { describe('lib/map_uri', function () { @@ -47,7 +46,7 @@ describe('plugins/elasticsearch', function () { it('sends configured custom headers even if the same named header exists in request', function () { const server = stubServer({ 'elasticsearch.requestHeadersWhitelist': ['x-my-custom-header'], - 'elasticsearch.customHeaders': {'x-my-custom-header': 'asconfigured'} + 'elasticsearch.customHeaders': { 'x-my-custom-header': 'asconfigured' } }); mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) { @@ -97,7 +96,7 @@ describe('plugins/elasticsearch', function () { request.path = '/elasticsearch/es/path'; const server = stubServer(); - mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) { + mapUri(server)(request, function (err, upstreamUri) { expect(err).to.be(null); expect(upstreamUri).to.be('http://localhost:9200/es/path'); }); @@ -107,7 +106,7 @@ describe('plugins/elasticsearch', function () { request.path = '/elasticsearch/index/type'; const server = stubServer({ 'elasticsearch.url': 'https://localhost:9200/base-path' }); - mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) { + mapUri(server)(request, function (err, upstreamUri) { expect(err).to.be(null); expect(upstreamUri).to.be('https://localhost:9200/base-path/index/type'); }); @@ -118,7 +117,7 @@ describe('plugins/elasticsearch', function () { request.query = { foo: 'bar' }; const server = stubServer({ 'elasticsearch.url': 'https://localhost:9200/?base=query' }); - mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) { + mapUri(server)(request, function (err, upstreamUri) { expect(err).to.be(null); expect(upstreamUri).to.be('https://localhost:9200/*?foo=bar&base=query'); }); @@ -129,7 +128,7 @@ describe('plugins/elasticsearch', function () { request.query = { _: Date.now() }; const server = stubServer(); - mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) { + mapUri(server)(request, function (err, upstreamUri) { expect(err).to.be(null); expect(upstreamUri).to.be('http://localhost:9200/*'); }); diff --git a/src/core_plugins/elasticsearch/lib/__tests__/routes.js b/src/core_plugins/elasticsearch/lib/__tests__/routes.js index 9bc60d809ccb9..46e519dd4ded4 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/routes.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/routes.js @@ -1,4 +1,3 @@ -import expect from 'expect.js'; import { format } from 'util'; import * as kbnTestServer from '../../../../../test/utils/kbn_server'; @@ -94,13 +93,13 @@ describe('plugins/elasticsearch', function () { testRoute({ method: 'POST', url: '/elasticsearch/.kibana/__kibanaQueryValidator/_validate/query?explain=true&ignore_unavailable=true', - payload: {query: {query_string: {analyze_wildcard: true, query: '*'}}} + payload: { query: { query_string: { analyze_wildcard: true, query: '*' } } } }); testRoute({ method: 'POST', url: '/elasticsearch/_mget', - payload: {docs: [{_index: '.kibana', _type: 'index-pattern', _id: '[logstash-]YYYY.MM.DD'}]} + payload: { docs: [{ _index: '.kibana', _type: 'index-pattern', _id: '[logstash-]YYYY.MM.DD' }] } }); testRoute({ diff --git a/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js b/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js index 0bed49f4d4c1c..2ee97b53d5474 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js @@ -1,5 +1,4 @@ import expect from 'expect.js'; -import sinon from 'sinon'; import setHeaders from '../set_headers'; describe('plugins/elasticsearch', function () { diff --git a/src/core_plugins/elasticsearch/lib/__tests__/upgrade_config.js b/src/core_plugins/elasticsearch/lib/__tests__/upgrade_config.js index 96e744c11ac10..39d627c9800e5 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/upgrade_config.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/upgrade_config.js @@ -1,4 +1,3 @@ -import _ from 'lodash'; import Promise from 'bluebird'; import sinon from 'sinon'; import expect from 'expect.js'; @@ -10,7 +9,6 @@ describe('plugins/elasticsearch', function () { let get; let server; let client; - let config; let upgrade; beforeEach(function () { @@ -46,7 +44,7 @@ describe('plugins/elasticsearch', function () { }); it('should resolve buildNum to pkg.buildNum config', function () { - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { sinon.assert.calledOnce(client.create); const params = client.create.args[0][0]; expect(params.body).to.have.property('buildNum', get('pkg.buildNum')); @@ -54,7 +52,7 @@ describe('plugins/elasticsearch', function () { }); it('should resolve version to pkg.version config', function () { - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { const params = client.create.args[0][0]; expect(params).to.have.property('id', get('pkg.version')); }); @@ -69,14 +67,14 @@ describe('plugins/elasticsearch', function () { }); it('should resolve buildNum to pkg.buildNum config', function () { - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { const params = client.create.args[0][0]; expect(params.body).to.have.property('buildNum', get('pkg.buildNum')); }); }); it('should resolve version to pkg.version config', function () { - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { const params = client.create.args[0][0]; expect(params).to.have.property('id', get('pkg.version')); }); @@ -95,7 +93,7 @@ describe('plugins/elasticsearch', function () { get.withArgs('pkg.buildNum').returns(9833); client.create.returns(Promise.resolve()); const response = { hits: { hits: [ { _id: '4.0.1-alpha3' }, { _id: '4.0.1-beta1' }, { _id: '4.0.0-SNAPSHOT1' } ] } }; - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { sinon.assert.calledOnce(client.create); const params = client.create.args[0][0]; expect(params).to.have.property('body'); @@ -110,7 +108,7 @@ describe('plugins/elasticsearch', function () { get.withArgs('pkg.buildNum').returns(5801); client.create.returns(Promise.resolve()); const response = { hits: { hits: [ { _id: '4.0.0', _source: { buildNum: 1 } } ] } }; - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { sinon.assert.calledOnce(client.create); const params = client.create.args[0][0]; expect(params).to.have.property('body'); @@ -125,7 +123,7 @@ describe('plugins/elasticsearch', function () { get.withArgs('pkg.buildNum').returns(5801); client.create.returns(Promise.resolve()); const response = { hits: { hits: [ { _id: '4.0.0', _source: { buildNum: 1 } } ] } }; - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { sinon.assert.calledOnce(server.log); expect(server.log.args[0][0]).to.eql(['plugin', 'elasticsearch']); const msg = server.log.args[0][1]; @@ -139,13 +137,12 @@ describe('plugins/elasticsearch', function () { get.withArgs('pkg.buildNum').returns(5801); client.create.returns(Promise.resolve()); const response = { hits: { hits: [ { _id: '4.0.0', _source: { buildNum: 1, defaultIndex: 'logstash-*' } } ] } }; - return upgrade(response).then(function (resp) { + return upgrade(response).then(function () { sinon.assert.calledOnce(client.create); const params = client.create.args[0][0]; expect(params).to.have.property('body'); expect(params.body).to.have.property('defaultIndex', 'logstash-*'); }); }); - }); }); diff --git a/src/core_plugins/elasticsearch/lib/check_es_version.js b/src/core_plugins/elasticsearch/lib/check_es_version.js index b9eddd0e0f249..a3570af0472fe 100644 --- a/src/core_plugins/elasticsearch/lib/check_es_version.js +++ b/src/core_plugins/elasticsearch/lib/check_es_version.js @@ -76,7 +76,7 @@ module.exports = function checkEsVersion(server, kibanaVersion) { if (incompatibleNodes.length) { const incompatibleNodeNames = getHumanizedNodeNames(incompatibleNodes); throw new Error( - `This version of Kibana requires Elasticsearch v` + + 'This version of Kibana requires Elasticsearch v' + `${kibanaVersion} on all nodes. I found ` + `the following incompatible nodes in your cluster: ${incompatibleNodeNames.join(',')}` ); diff --git a/src/core_plugins/elasticsearch/lib/create_kibana_index.js b/src/core_plugins/elasticsearch/lib/create_kibana_index.js index 54e48658dee79..d02cd0a2f8003 100644 --- a/src/core_plugins/elasticsearch/lib/create_kibana_index.js +++ b/src/core_plugins/elasticsearch/lib/create_kibana_index.js @@ -1,4 +1,3 @@ -import { format } from 'util'; import { mappings } from './kibana_index_mappings'; module.exports = function (server) { diff --git a/src/core_plugins/elasticsearch/lib/create_proxy.js b/src/core_plugins/elasticsearch/lib/create_proxy.js index 068712ca9c70f..a4bea6847b9fd 100644 --- a/src/core_plugins/elasticsearch/lib/create_proxy.js +++ b/src/core_plugins/elasticsearch/lib/create_proxy.js @@ -1,6 +1,5 @@ import createAgent from './create_agent'; import mapUri from './map_uri'; -import { resolve } from 'url'; import { assign } from 'lodash'; function createProxy(server, method, route, config) { @@ -39,7 +38,7 @@ function createProxy(server, method, route, config) { assign(options.config, config); server.route(options); -}; +} createProxy.createPath = function createPath(path) { const pre = '/elasticsearch'; diff --git a/src/core_plugins/elasticsearch/lib/expose_client.js b/src/core_plugins/elasticsearch/lib/expose_client.js index a1748e54ebbeb..8caeb03f29cdc 100644 --- a/src/core_plugins/elasticsearch/lib/expose_client.js +++ b/src/core_plugins/elasticsearch/lib/expose_client.js @@ -41,7 +41,6 @@ module.exports = function (server) { const uri = url.parse(options.url); - let authorization; if (options.auth && options.username && options.password) { uri.auth = util.format('%s:%s', options.username, options.password); } diff --git a/src/core_plugins/elasticsearch/lib/filter_headers.js b/src/core_plugins/elasticsearch/lib/filter_headers.js index 285b45f560697..891306fd260c2 100644 --- a/src/core_plugins/elasticsearch/lib/filter_headers.js +++ b/src/core_plugins/elasticsearch/lib/filter_headers.js @@ -1,7 +1,6 @@ import _ from 'lodash'; export default function (originalHeaders, headersToKeep) { - const normalizeHeader = function (header) { if (!header) { return ''; @@ -13,10 +12,5 @@ export default function (originalHeaders, headersToKeep) { // Normalize list of headers we want to allow in upstream request const headersToKeepNormalized = headersToKeep.map(normalizeHeader); - // Normalize original headers in request - const originalHeadersNormalized = _.mapKeys(originalHeaders, function (headerValue, headerName) { - return normalizeHeader(headerName); - }); - return _.pick(originalHeaders, headersToKeepNormalized); } diff --git a/src/core_plugins/elasticsearch/lib/get_basic_auth_realm.js b/src/core_plugins/elasticsearch/lib/get_basic_auth_realm.js index 9a9c183def983..11646439fad3b 100644 --- a/src/core_plugins/elasticsearch/lib/get_basic_auth_realm.js +++ b/src/core_plugins/elasticsearch/lib/get_basic_auth_realm.js @@ -4,4 +4,4 @@ export default function getBasicAuthRealm(message) { const parts = message.match(/Basic\ realm=\\"(.*)\\"/); if (parts && parts.length === 2) return parts[1]; else return null; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/core_plugins/elasticsearch/lib/health_check.js b/src/core_plugins/elasticsearch/lib/health_check.js index 4f1555893d871..76f20f515d466 100644 --- a/src/core_plugins/elasticsearch/lib/health_check.js +++ b/src/core_plugins/elasticsearch/lib/health_check.js @@ -1,7 +1,6 @@ import _ from 'lodash'; import Promise from 'bluebird'; import elasticsearch from 'elasticsearch'; -import exposeClient from './expose_client'; import migrateConfig from './migrate_config'; import createKibanaIndex from './create_kibana_index'; import checkEsVersion from './check_es_version'; diff --git a/src/core_plugins/elasticsearch/lib/map_uri.js b/src/core_plugins/elasticsearch/lib/map_uri.js index daaf9b73c9633..76fe47b18a449 100644 --- a/src/core_plugins/elasticsearch/lib/map_uri.js +++ b/src/core_plugins/elasticsearch/lib/map_uri.js @@ -1,9 +1,9 @@ import { defaults, omit, trimLeft, trimRight } from 'lodash'; -import { parse as parseUrl, format as formatUrl, resolve } from 'url'; +import { parse as parseUrl, format as formatUrl } from 'url'; import filterHeaders from './filter_headers'; import setHeaders from './set_headers'; -export default function mapUri(server, prefix) { +export default function mapUri(server) { const config = server.config(); function joinPaths(pathA, pathB) { @@ -45,4 +45,4 @@ export default function mapUri(server, prefix) { const mappedUrl = formatUrl(mappedUrlComponents); done(null, mappedUrl, mappedHeaders); }; -}; +} diff --git a/src/core_plugins/elasticsearch/lib/upgrade_config.js b/src/core_plugins/elasticsearch/lib/upgrade_config.js index 9050767d969ac..8fd4609daa64d 100644 --- a/src/core_plugins/elasticsearch/lib/upgrade_config.js +++ b/src/core_plugins/elasticsearch/lib/upgrade_config.js @@ -1,11 +1,8 @@ import Promise from 'bluebird'; import isUpgradeable from './is_upgradeable'; import _ from 'lodash'; -import { format } from 'util'; module.exports = function (server) { - const MAX_INTEGER = Math.pow(2, 53) - 1; - const client = server.plugins.elasticsearch.client; const config = server.config(); @@ -19,8 +16,6 @@ module.exports = function (server) { } return function (response) { - const newConfig = {}; - // Check to see if there are any doc. If not then we set the build number and id if (response.hits.hits.length === 0) { return createNewConfig(); diff --git a/src/core_plugins/kbn_doc_views/index.js b/src/core_plugins/kbn_doc_views/index.js index 7f94a42489d31..47af2971d166d 100644 --- a/src/core_plugins/kbn_doc_views/index.js +++ b/src/core_plugins/kbn_doc_views/index.js @@ -10,4 +10,4 @@ export default function (kibana) { }); -}; +} diff --git a/src/core_plugins/kbn_doc_views/public/__tests__/doc_views.js b/src/core_plugins/kbn_doc_views/public/__tests__/doc_views.js index c931996d53a22..89e67a658b72e 100644 --- a/src/core_plugins/kbn_doc_views/public/__tests__/doc_views.js +++ b/src/core_plugins/kbn_doc_views/public/__tests__/doc_views.js @@ -3,7 +3,6 @@ import _ from 'lodash'; import sinon from 'auto-release-sinon'; import expect from 'expect.js'; import ngMock from 'ng_mock'; -import $ from 'jquery'; import 'ui/render_directive'; import 'plugins/kbn_doc_views/views/table'; import docViewsRegistry from 'ui/registry/doc_views'; @@ -16,9 +15,9 @@ const hit = { '_source': { 'extension': 'html', 'bytes': 100, - 'area': [{lat: 7, lon: 7}], + 'area': [{ lat: 7, lon: 7 }], 'noMapping': 'hasNoMapping', - 'objectArray': [{foo: true}, {bar: false}], + 'objectArray': [{ foo: true }, { bar: false }], '_underscore': 1 } }; @@ -78,7 +77,6 @@ describe('docViews', function () { initView(docViews.byName.Table); }); it('should have a row for each field', function () { - const rows = $elem.find('tr'); expect($elem.find('tr').length).to.be(_.keys(flattened).length); }); diff --git a/src/core_plugins/kbn_doc_views/public/views/json.js b/src/core_plugins/kbn_doc_views/public/views/json.js index 120935e4b9cde..8415da47fd5e6 100644 --- a/src/core_plugins/kbn_doc_views/public/views/json.js +++ b/src/core_plugins/kbn_doc_views/public/views/json.js @@ -1,4 +1,3 @@ -import _ from 'lodash'; import angular from 'angular'; import 'ace'; import docViewsRegistry from 'ui/registry/doc_views'; diff --git a/src/core_plugins/kbn_doc_views/public/views/table.js b/src/core_plugins/kbn_doc_views/public/views/table.js index af201f39c3539..fef633e5827ec 100644 --- a/src/core_plugins/kbn_doc_views/public/views/table.js +++ b/src/core_plugins/kbn_doc_views/public/views/table.js @@ -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'; }; } diff --git a/src/core_plugins/kbn_vislib_vis_types/index.js b/src/core_plugins/kbn_vislib_vis_types/index.js index 0f7e42cfbf556..b74e5a4cf56c7 100644 --- a/src/core_plugins/kbn_vislib_vis_types/index.js +++ b/src/core_plugins/kbn_vislib_vis_types/index.js @@ -10,4 +10,4 @@ export default function (kibana) { }); -}; +} diff --git a/src/core_plugins/kbn_vislib_vis_types/public/area.js b/src/core_plugins/kbn_vislib_vis_types/public/area.js index 8ba764e50a6d8..8968b2d532c2f 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/area.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/area.js @@ -71,4 +71,4 @@ export default function HistogramVisType(Private) { } ]) }); -}; +} diff --git a/src/core_plugins/kbn_vislib_vis_types/public/controls/line_interpolation_option.js b/src/core_plugins/kbn_vislib_vis_types/public/controls/line_interpolation_option.js index a62607f67e307..2159713cf1937 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/controls/line_interpolation_option.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/controls/line_interpolation_option.js @@ -1,10 +1,8 @@ -import _ from 'lodash'; -import $ from 'jquery'; import uiModules from 'ui/modules'; import lineInterpolationOptionTemplate from 'plugins/kbn_vislib_vis_types/controls/line_interpolation_option.html'; const module = uiModules.get('kibana'); -module.directive('lineInterpolationOption', function ($parse, $compile) { +module.directive('lineInterpolationOption', function () { return { restrict: 'E', template: lineInterpolationOptionTemplate, diff --git a/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series_options.js b/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series_options.js index 653d3afd5c755..88b92f760b07c 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series_options.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/controls/point_series_options.js @@ -1,11 +1,9 @@ -import _ from 'lodash'; -import $ from 'jquery'; import 'ui/directives/inequality'; import uiModules from 'ui/modules'; import pointSeriesOptionsTemplate from 'plugins/kbn_vislib_vis_types/controls/point_series_options.html'; const module = uiModules.get('kibana'); -module.directive('pointSeriesOptions', function ($parse, $compile) { +module.directive('pointSeriesOptions', function () { return { restrict: 'E', template: pointSeriesOptionsTemplate, diff --git a/src/core_plugins/kbn_vislib_vis_types/public/controls/vislib_basic_options.js b/src/core_plugins/kbn_vislib_vis_types/public/controls/vislib_basic_options.js index fd7f7b9eaa8e0..4f160429e9493 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/controls/vislib_basic_options.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/controls/vislib_basic_options.js @@ -1,10 +1,8 @@ -import _ from 'lodash'; -import $ from 'jquery'; import uiModules from 'ui/modules'; import vislibBasicOptionsTemplate from 'plugins/kbn_vislib_vis_types/controls/vislib_basic_options.html'; const module = uiModules.get('kibana'); -module.directive('vislibBasicOptions', function ($parse, $compile) { +module.directive('vislibBasicOptions', function () { return { restrict: 'E', template: vislibBasicOptionsTemplate, diff --git a/src/core_plugins/kbn_vislib_vis_types/public/histogram.js b/src/core_plugins/kbn_vislib_vis_types/public/histogram.js index 40099fe4c7bf0..23a08e3e98d51 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/histogram.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/histogram.js @@ -67,4 +67,4 @@ export default function HistogramVisType(Private) { } ]) }); -}; +} diff --git a/src/core_plugins/kbn_vislib_vis_types/public/line.js b/src/core_plugins/kbn_vislib_vis_types/public/line.js index 0c7830da74583..f292dade6788d 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/line.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/line.js @@ -77,4 +77,4 @@ export default function HistogramVisType(Private) { } ]) }); -}; +} diff --git a/src/core_plugins/kbn_vislib_vis_types/public/pie.js b/src/core_plugins/kbn_vislib_vis_types/public/pie.js index 170178cf1d153..64a2242fbe7bb 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/pie.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/pie.js @@ -57,4 +57,4 @@ export default function HistogramVisType(Private) { } ]) }); -}; +} diff --git a/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js b/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js index 8c2e18ed3e2b5..7c43770184638 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js @@ -43,7 +43,7 @@ export default function TileMapVisType(Private, getAppState, courier, config) { const pushFilter = Private(FilterBarPushFilterProvider)(getAppState()); const indexPatternName = agg.vis.indexPattern.id; const field = agg.fieldName(); - const filter = {geo_bounding_box: {}}; + const filter = { geo_bounding_box: {} }; filter.geo_bounding_box[field] = event.bounds; pushFilter(filter, false, indexPatternName); @@ -98,4 +98,4 @@ export default function TileMapVisType(Private, getAppState, courier, config) { } ]) }); -}; +} diff --git a/src/core_plugins/kibana/common/lib/__tests__/convert_pattern_and_ingest_name.js b/src/core_plugins/kibana/common/lib/__tests__/convert_pattern_and_ingest_name.js index 97dea17fc5bfe..38e3c751ad2a9 100644 --- a/src/core_plugins/kibana/common/lib/__tests__/convert_pattern_and_ingest_name.js +++ b/src/core_plugins/kibana/common/lib/__tests__/convert_pattern_and_ingest_name.js @@ -1,5 +1,5 @@ import expect from 'expect.js'; -import {patternToIngest, ingestToPattern} from '../convert_pattern_and_ingest_name'; +import { patternToIngest, ingestToPattern } from '../convert_pattern_and_ingest_name'; describe('convertPatternAndTemplateName', function () { diff --git a/src/core_plugins/kibana/index.js b/src/core_plugins/kibana/index.js index 85bc26a855046..512d33eeb7751 100644 --- a/src/core_plugins/kibana/index.js +++ b/src/core_plugins/kibana/index.js @@ -38,8 +38,8 @@ module.exports = function (kibana) { 'docViews' ], - injectVars: function (server, options) { - let config = server.config(); + injectVars: function (server) { + const config = server.config(); return { kbnDefaultAppId: config.get('kibana.defaultAppId'), tilemap: config.get('tilemap') @@ -105,7 +105,7 @@ module.exports = function (kibana) { } }, - init: function (server, options) { + init: function (server) { // uuid manageUuid(server); // routes diff --git a/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_panels.js b/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_panels.js index 0611c8eba587a..acc48c7fffa94 100644 --- a/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_panels.js +++ b/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_panels.js @@ -36,7 +36,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); }); @@ -45,9 +45,9 @@ 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"}]`; + dash.panelsJSON = '[{"col":3,"id":"foo1","row":1,"size_x":2,"size_y":2,"type":"visualization"}]'; compile(dash); }); expect($scope.state.panels.length).to.be(1); @@ -55,7 +55,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"}, diff --git a/src/core_plugins/kibana/public/dashboard/components/panel/lib/load_panel.js b/src/core_plugins/kibana/public/dashboard/components/panel/lib/load_panel.js index 54e12f3fd4d7e..bc2744a70d8a1 100644 --- a/src/core_plugins/kibana/public/dashboard/components/panel/lib/load_panel.js +++ b/src/core_plugins/kibana/public/dashboard/components/panel/lib/load_panel.js @@ -1,4 +1,3 @@ -import _ from 'lodash'; import PluginsKibanaDashboardComponentsPanelLibVisualizationProvider from 'plugins/kibana/dashboard/components/panel/lib/visualization'; import PluginsKibanaDashboardComponentsPanelLibSearchProvider from 'plugins/kibana/dashboard/components/panel/lib/search'; export default function loadPanelFunction(Private) { // Inject services here @@ -15,4 +14,4 @@ export default function loadPanelFunction(Private) { // Inject services here } }; -}; +} diff --git a/src/core_plugins/kibana/public/dashboard/components/panel/lib/search.js b/src/core_plugins/kibana/public/dashboard/components/panel/lib/search.js index e0d7a914b2f4f..eca3f43f24ffc 100644 --- a/src/core_plugins/kibana/public/dashboard/components/panel/lib/search.js +++ b/src/core_plugins/kibana/public/dashboard/components/panel/lib/search.js @@ -1,4 +1,4 @@ -export default function searchLoader(savedSearches, Private) { // Inject services here +export default function searchLoader(savedSearches) { // Inject services here return function (panel, $scope) { // Function parameters here return savedSearches.get(panel.id) .then(function (savedSearch) { @@ -21,4 +21,4 @@ export default function searchLoader(savedSearches, Private) { // Inject service }; }); }; -}; +} diff --git a/src/core_plugins/kibana/public/dashboard/components/panel/lib/visualization.js b/src/core_plugins/kibana/public/dashboard/components/panel/lib/visualization.js index 87b04bc1cb535..3c47e4d253feb 100644 --- a/src/core_plugins/kibana/public/dashboard/components/panel/lib/visualization.js +++ b/src/core_plugins/kibana/public/dashboard/components/panel/lib/visualization.js @@ -20,4 +20,4 @@ export default function visualizationLoader(savedVisualizations, Private) { // I }; }); }; -}; +} diff --git a/src/core_plugins/kibana/public/dashboard/components/panel/panel.js b/src/core_plugins/kibana/public/dashboard/components/panel/panel.js index 5cdf1a8469dfa..2737bd3e43fbd 100644 --- a/src/core_plugins/kibana/public/dashboard/components/panel/panel.js +++ b/src/core_plugins/kibana/public/dashboard/components/panel/panel.js @@ -1,11 +1,8 @@ -import moment from 'moment'; -import $ from 'jquery'; import _ from 'lodash'; import 'ui/visualize'; import 'ui/doc_table'; import PluginsKibanaDashboardComponentsPanelLibLoadPanelProvider from 'plugins/kibana/dashboard/components/panel/lib/load_panel'; import FilterManagerProvider from 'ui/filter_manager'; -import UtilsBrushEventProvider from 'ui/utils/brush_event'; import uiModules from 'ui/modules'; import panelTemplate from 'plugins/kibana/dashboard/components/panel/panel.html'; uiModules @@ -13,7 +10,6 @@ uiModules .directive('dashboardPanel', function (savedVisualizations, savedSearches, Notifier, Private, $injector) { const loadPanel = Private(PluginsKibanaDashboardComponentsPanelLibLoadPanelProvider); const filterManager = Private(FilterManagerProvider); - const notify = new Notifier(); const services = require('plugins/kibana/management/saved_object_registry').all().map(function (serviceObj) { const service = $injector.get(serviceObj.service); @@ -24,8 +20,6 @@ uiModules }); - const brushEvent = Private(UtilsBrushEventProvider); - const getPanelId = function (panel) { return ['P', panel.panelIndex].join('-'); }; @@ -34,7 +28,7 @@ uiModules restrict: 'E', template: panelTemplate, requires: '^dashboardGrid', - link: function ($scope, $el) { + link: function ($scope) { // using $scope inheritance, panels are available in AppState const $state = $scope.state; diff --git a/src/core_plugins/kibana/public/dashboard/directives/grid.js b/src/core_plugins/kibana/public/dashboard/directives/grid.js index ef4ea724aab88..1b3cab8bbd19a 100644 --- a/src/core_plugins/kibana/public/dashboard/directives/grid.js +++ b/src/core_plugins/kibana/public/dashboard/directives/grid.js @@ -16,7 +16,6 @@ app.directive('dashboardGrid', function ($compile, Notifier) { $el = $('