Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Upgrade eslint #8101

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
edf93df
upgrade eslint, all related deps, and config files
Aug 24, 2016
70cb9d4
replace gruntify-eslint with basic eslint-cli wrapper
Sep 2, 2016
fdac53f
arrow-IIFEs must be invoked outside of the parens
Aug 25, 2016
c157202
move import statements before their use
Aug 25, 2016
c10b260
reindent to satisfy new indentation check algorithm
Aug 25, 2016
514551c
place missing semicolon
Sep 6, 2016
76e3a4b
apply unwrap-simple-amd jscodeshift
Nov 4, 2016
b7d3f95
ignore copy-pasted decode geohash code
Sep 10, 2016
ce7e1f6
re-enable no-var rule
Nov 4, 2016
e804e7a
`eslint --fix` with no-var enabled
Nov 4, 2016
82d2f3b
re-enable prefer-const rule
Nov 4, 2016
2496836
`eslint --fix` with prefer-const enabled
Nov 4, 2016
566545c
re-enable no-extra-semi rule
Nov 4, 2016
cc8865f
`eslint --fix` with no-extra-semi enabled
Nov 4, 2016
ab42f22
manually fix no-var violations that are not auto-fixable
Nov 4, 2016
a4d2d96
fix prefer-const violations that are not auto-fixable
Sep 6, 2016
8e8b96f
manually fix prefer-const violations that are not auto-fixable
Nov 4, 2016
59e1448
re-enable quotes rule
Nov 4, 2016
714629b
`eslint --fix` with quotes enabled
Nov 4, 2016
63b2edd
re-enable no-unused-vars rule
Nov 4, 2016
16b0177
unused-vars :: apply remove-unused-basic-vars jscodeshift
Nov 4, 2016
9ec67d9
unused-vars :: apply remove-unused-function-arguments jscodeshift
Nov 4, 2016
ad9ae73
unused-vars :: apply remove-unused-basic-requires jscodeshift
Nov 4, 2016
70e69f4
unused-vars :: apply require-to-import jscodeshift
Nov 4, 2016
3aa3c10
unused-vars :: apply remove-unused-imports jscodeshift
Nov 4, 2016
1a4bd37
unused-vars :: finish of with mostly manual work and remove-unused-as…
Nov 4, 2016
ab5dd59
enable `object-curly-spacing` rule
Nov 4, 2016
9a780c0
`eslint --fix` with object-curly-spacing enabled
Nov 4, 2016
bc6ee09
work around a line length overflow after adding spaces
Nov 4, 2016
df6d4aa
enable no-global-assign rule
Nov 4, 2016
b98128f
manually fix no-global-assign violations
Nov 4, 2016
937bdff
revert es module conversion where necessary
Nov 8, 2016
05b8c74
fix removal of unused var
Nov 8, 2016
039cef5
Merge branch 'master' of github.com:elastic/kibana into upgrade/eslint
Nov 8, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 7 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
---
extends: '@elastic/kibana'
rules:
object-curly-spacing: [error, always]
no-global-assign: [error]
12 changes: 0 additions & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const camelCase = require('lodash').camelCase;
require('babel/register')(require('./src/optimize/babel_options').node);

module.exports = function (grunt) {
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ program

program
.command('*', null, { noHelp: true })
.action(function (cmd, options) {
.action(function (cmd) {
program.error(`unknown command ${cmd}`);
});

Expand Down
4 changes: 2 additions & 2 deletions src/cli/cluster/__tests__/_mock_cluster_fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -39,6 +39,6 @@ export default class MockClusterFork extends EventEmitter {
await wait();
dead = false;
this.emit('online');
}());
})();
}
}
3 changes: 1 addition & 2 deletions src/cli/cluster/__tests__/cluster_manager.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
7 changes: 2 additions & 5 deletions src/cli/cluster/__tests__/worker.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions src/cli/cluster/base_path_proxy.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
36 changes: 15 additions & 21 deletions src/cli/cluster/cluster_manager.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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__)[\\\/]/
});
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 7 additions & 8 deletions src/cli/cluster/worker.js
Original file line number Diff line number Diff line change
@@ -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;
};

Expand All @@ -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)
Expand Down Expand Up @@ -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}"`;
}, '');
Expand Down
13 changes: 6 additions & 7 deletions src/cli/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 "--"`);
}
Expand All @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/cli/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = function (command, spaces) {
return command.outputHelp();
}

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

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

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

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

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

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

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

function humanReadableArgName(arg) {
let nameOutput = arg.name + (arg.variadic === true ? '...' : '');
const nameOutput = arg.name + (arg.variadic === true ? '...' : '');
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
}
3 changes: 1 addition & 2 deletions src/cli/log.js
Original file line number Diff line number Diff line change
@@ -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));
});

Expand Down
2 changes: 1 addition & 1 deletion src/cli/serve/__tests__/read_yaml_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading