Skip to content

Commit

Permalink
[eslint] enable no undef (#10825)
Browse files Browse the repository at this point in the history
* [codeshift] add proper ignore comments

* [codeshift] apply require-to-import transform

* [codeshift/fixup] remove duplicate imports

* [eslint] upgrade config for react "unused" support

* [codeshift] apply remove-unused-imports transform

* [codeshift] apply remove-unused-basic-requires transform

* [codeshift] apply remove-unused-function-arguments transform

* [lintroller] fix argument list spacing

* [codeshift] apply remove-unused-basic-bars transform

* [codeshift/fixup] fixup unused basic var removals

* manually apply remove-unused-assignments transform

* [codeshift] reapply remove-unused-imports transform

* [codeshift] reapply remove-unused-function-arguments transform

* [eslint] autofix param spacing

* manually fix remaining no-undef errors

* use more descriptive file ignore pattern

* add eslint-plugin-react peerDependency

* replace values that looked unused in tests

* remove // kibana-jscodeshift-no-babel comment

* remove import statements from code required by api tests

* Remove '// kibana-jscodeshift-ignore' comments

* address review feedback

* remove remnant of removed if condition
  • Loading branch information
spalger authored Mar 22, 2017
1 parent 8f51ec6 commit d8d6552
Show file tree
Hide file tree
Showing 789 changed files with 997 additions and 2,240 deletions.
2 changes: 0 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
---
extends: '@elastic/kibana'
rules:
no-unused-vars: off
1 change: 0 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const camelCase = require('lodash').camelCase;
require('./src/optimize/babel/register');

module.exports = function (grunt) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"wreck": "6.2.0"
},
"devDependencies": {
"@elastic/eslint-config-kibana": "0.3.0",
"@elastic/eslint-config-kibana": "0.4.0",
"angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3",
"babel-eslint": "6.1.2",
Expand All @@ -213,6 +213,7 @@
"eslint": "3.11.1",
"eslint-plugin-babel": "4.0.0",
"eslint-plugin-mocha": "4.7.0",
"eslint-plugin-react": "6.10.3",
"event-stream": "3.3.2",
"expect.js": "0.3.1",
"faker": "1.1.0",
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
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
5 changes: 1 addition & 4 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 @@ -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
3 changes: 1 addition & 2 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 { map, merge, sample } from 'lodash';
import { map, sample } from 'lodash';
import { format as formatUrl } from 'url';
import { map as promiseMap, fromNode } from 'bluebird';
import { Agent as HttpsAgent } from 'https';
Expand All @@ -11,7 +11,6 @@ import setupConnection from '../../server/http/setup_connection';
import registerHapiPlugins from '../../server/http/register_hapi_plugins';
import setupLogging from '../../server/logging';
import { transformDeprecations } from '../../server/config/transform_deprecations';
import { DEV_SSL_CERT_PATH } from '../dev_ssl';

const alphabet = 'abcdefghijklmnopqrztuvwxyz'.split('');

Expand Down
9 changes: 3 additions & 6 deletions src/cli/cluster/cluster_manager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
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';
Expand Down Expand Up @@ -124,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
1 change: 0 additions & 1 deletion src/cli/cluster/worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from 'lodash';
import cluster from 'cluster';
import { resolve } from 'path';
import { EventEmitter } from 'events';

import { BinderFor, fromRoot } from '../../utils';
Expand Down
1 change: 0 additions & 1 deletion 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
1 change: 0 additions & 1 deletion src/cli/log.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash';
import ansicolors from 'ansicolors';

const log = _.restParam(function (color, label, rest1) {
console.log.apply(console, [color(` ${_.trim(label)} `)].concat(rest1));
Expand Down
3 changes: 1 addition & 2 deletions src/cli/serve/__tests__/read_yaml_config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import expect from 'expect.js';
import { join, relative, resolve } from 'path';
import readYamlConfig from '../read_yaml_config';
import sinon from 'auto-release-sinon';

function fixture(name) {
return resolve(__dirname, 'fixtures', name);
Expand All @@ -11,7 +10,7 @@ describe('cli/serve/read_yaml_config', function () {
it('reads a single config file', function () {
const config = readYamlConfig(fixture('one.yml'));

expect(readYamlConfig(fixture('one.yml'))).to.eql({
expect(config).to.eql({
foo: 1,
bar: true,
});
Expand Down
4 changes: 2 additions & 2 deletions src/cli/serve/__tests__/reload_logging_config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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';
Expand Down Expand Up @@ -33,7 +33,7 @@ describe(`Server logging configuration`, function () {

let asserted = false;
let json = Infinity;
const conf = setLoggingJson(true);
setLoggingJson(true);
const child = spawn(cli, [`--config`, testConfigFile]);

child.on('error', err => {
Expand Down
2 changes: 0 additions & 2 deletions src/cli/serve/read_yaml_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { readFileSync as read } from 'fs';
import { safeLoad } from 'js-yaml';


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

export function merge(sources) {
return transform(sources, (merged, source) => {
forOwn(source, function apply(val, key) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ program

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

Expand Down
21 changes: 4 additions & 17 deletions src/cli_plugin/install/__tests__/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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);
});
});
Expand All @@ -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);
});
});
Expand All @@ -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();
Expand All @@ -133,7 +121,6 @@ describe('kibana cli', function () {

expect(cleanArtifacts).withArgs(settings).to.not.throwError();
});

});

});
Expand Down
10 changes: 5 additions & 5 deletions src/cli_plugin/install/__tests__/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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'
Expand Down Expand Up @@ -174,7 +174,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'
})
Expand Down Expand Up @@ -204,7 +204,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'
})
Expand Down Expand Up @@ -233,7 +233,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'
})
Expand Down
6 changes: 3 additions & 3 deletions src/cli_plugin/install/__tests__/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand All @@ -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) => {
Expand Down
2 changes: 0 additions & 2 deletions src/cli_plugin/install/__tests__/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -87,7 +86,6 @@ describe('kibana cli', function () {
});

});

});

});
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/__tests__/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('plugin folder rename', function () {
});

return renamePlugin('/foo/bar', '/bar/foo')
.then(function (err) {
.then(function () {
expect(renameStub.callCount).to.be(1);
})
.catch(function () {
Expand Down
3 changes: 1 addition & 2 deletions src/cli_plugin/install/__tests__/settings.js
Original file line number Diff line number Diff line change
@@ -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 () {

Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/__tests__/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('kibana cli', function () {
workingPath: testWorkingPath,
tempArchiveFile: tempArchiveFilePath,
plugin: 'test-plugin',
setPlugin: function (plugin) {}
setPlugin: function () {}
};

function shouldReject() {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function _isWindows() {
return /^win/.test(process.platform);
}

export function _getFilePath(filePath, sourceUrl) {
export function _getFilePath(filePath) {
const decodedPath = decodeURI(filePath);
const prefixedDrive = /^\/[a-zA-Z]:/.test(decodedPath);
if (_isWindows() && prefixedDrive) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/downloaders/file.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Progress from '../progress';
import { createWriteStream, createReadStream, unlinkSync, statSync } from 'fs';
import { createWriteStream, createReadStream, statSync } from 'fs';

function openSourceFile({ sourcePath }) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_plugin/install/downloaders/http.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/cli_plugin/install/index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Loading

0 comments on commit d8d6552

Please sign in to comment.