Skip to content

Commit f9690a6

Browse files
elastic-jasperspalger
authored andcommitted
Upgrade eslint (#9449)
Backports PR #9357 **Commit 1:** upgrade eslint, all related deps, and config files * Original sha: 054e798 * Authored by spalger <email@spalger.com> on 2016-08-24T23:39:11Z * Committed by spalger <spalger@users.noreply.github.com> on 2016-12-02T23:04:20Z **Commit 2:** replace gruntify-eslint with basic eslint-cli wrapper * Original sha: 71732e7 * Authored by spalger <email@spalger.com> on 2016-09-02T21:33:02Z * Committed by spalger <spalger@users.noreply.github.com> on 2016-12-02T23:41:36Z **Commit 3:** arrow-IIFEs must be invoked outside of the parens * Original sha: b05662c * Authored by spalger <email@spalger.com> on 2016-08-25T17:47:57Z * Committed by spalger <spalger@users.noreply.github.com> on 2016-12-02T23:41:40Z **Commit 4:** move import statements before their use * Original sha: 3572ab8 * Authored by spalger <email@spalger.com> on 2016-08-25T17:48:30Z * Committed by spalger <spalger@users.noreply.github.com> on 2016-12-02T23:41:40Z **Commit 5:** reindent to satisfy new indentation check algorithm * Original sha: b31dae1 * Authored by spalger <email@spalger.com> on 2016-08-25T17:49:47Z * Committed by spalger <spalger@users.noreply.github.com> on 2016-12-02T23:41:58Z **Commit 6:** place missing semicolon * Original sha: 7b39475 * Authored by spalger <email@spalger.com> on 2016-09-06T22:27:10Z * Committed by spalger <spalger@users.noreply.github.com> on 2016-12-02T23:42:04Z **Commit 7:** ignore copy-pasted decode geohash code * Original sha: 3c02df9 * Authored by spalger <email@spalger.com> on 2016-09-10T01:49:42Z * Committed by spalger <spalger@users.noreply.github.com> on 2016-12-02T23:42:04Z **Commit 8:** Merge branch 'master' of github.com:elastic/kibana into upgrade/eslint-try2 * Original sha: 1224b18 * Authored by spalger <spalger@users.noreply.github.com> on 2016-12-10T04:14:32Z **Commit 9:** [grunt/eslint] fix argument spacing * Original sha: 6fa2c6c * Authored by spalger <spalger@users.noreply.github.com> on 2016-12-10T04:22:42Z **Commit 10:** [gurnt/eslint] add comment about contents of report * Original sha: 71834ca * Authored by spalger <spalger@users.noreply.github.com> on 2016-12-10T07:59:11Z **Commit 11:** Merge branch 'master' of github.com:elastic/kibana into upgrade/eslint-try2 * Original sha: 76e77a7 * Authored by spalger <spalger@users.noreply.github.com> on 2016-12-12T20:17:05Z **Commit 12:** [grunt/tasks] use `export default` * Original sha: 803c0da * Authored by spalger <spalger@users.noreply.github.com> on 2016-12-12T20:19:27Z
1 parent 3aea8e2 commit f9690a6

File tree

14 files changed

+164
-172
lines changed

14 files changed

+164
-172
lines changed

.eslintignore

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
/optimize
2+
/src/fixtures/vislib/mock_data
3+
/src/ui/public/angular-bootstrap
4+
/test/fixtures/scenarios
5+
/src/core_plugins/console/public/webpackShims
6+
/src/core_plugins/console/public/tests/webpackShims
17
/src/core_plugins/timelion/bower_components
28
/src/core_plugins/timelion/vendor_components
3-
test/fixtures/scenarios
4-
optimize
5-
test/fixtures/scenarios
9+
/src/ui/public/utils/decode_geo_hash.js

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
---
22
extends: '@elastic/kibana'
3+
rules:
4+
no-unused-vars: off
5+
no-var: off
6+
prefer-const: off
7+
no-extra-semi: off
8+
quotes: off

Gruntfile.js

-12
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ module.exports = function (grunt) {
3838
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= package.author.company %>;' +
3939
' Licensed <%= package.license %> */\n'
4040
},
41-
42-
lintThese: [
43-
'Gruntfile.js',
44-
'<%= root %>/tasks/**/*.js',
45-
'<%= root %>/test/**/*.js',
46-
'<%= src %>/**/*.js',
47-
'!<%= src %>/ui/public/angular-bootstrap/**/*.js',
48-
'!<%= src %>/core_plugins/timelion/bower_components/**/*.js',
49-
'!<%= src %>/core_plugins/timelion/vendor_components/**/*.js',
50-
'!<%= src %>/fixtures/**/*.js',
51-
'!<%= root %>/test/fixtures/scenarios/**/*.js'
52-
]
5341
};
5442

5543
grunt.config.merge(config);

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@
165165
"wreck": "6.2.0"
166166
},
167167
"devDependencies": {
168-
"@elastic/eslint-config-kibana": "0.0.3",
168+
"@elastic/eslint-config-kibana": "0.2.1",
169169
"angular-mocks": "1.4.7",
170170
"auto-release-sinon": "1.0.3",
171-
"babel-eslint": "4.1.8",
171+
"babel-eslint": "6.1.2",
172172
"chai": "3.5.0",
173173
"cheerio": "0.22.0",
174174
"chokidar": "1.6.0",
175175
"chromedriver": "2.24.1",
176176
"elasticdump": "2.1.1",
177-
"eslint": "1.10.3",
178-
"eslint-plugin-mocha": "1.1.0",
177+
"eslint": "3.11.1",
178+
"eslint-plugin-mocha": "4.7.0",
179179
"event-stream": "3.3.2",
180180
"expect.js": "0.3.1",
181181
"faker": "1.1.0",
@@ -189,7 +189,6 @@
189189
"grunt-karma": "2.0.0",
190190
"grunt-run": "0.6.0",
191191
"grunt-simple-mocha": "0.4.0",
192-
"gruntify-eslint": "1.0.1",
193192
"gulp-sourcemaps": "1.7.3",
194193
"handlebars": "4.0.5",
195194
"husky": "0.8.1",

src/cli/cluster/__tests__/_mock_cluster_fork.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class MockClusterFork extends EventEmitter {
2424
dead = true;
2525
this.emit('exit');
2626
cluster.emit('exit', this, this.exitCode || 0);
27-
}());
27+
})();
2828
}),
2929
},
3030
isDead: sinon.spy(() => dead),
@@ -39,6 +39,6 @@ export default class MockClusterFork extends EventEmitter {
3939
await wait();
4040
dead = false;
4141
this.emit('online');
42-
}());
42+
})();
4343
}
4444
}

src/cli/cluster/cluster_manager.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,16 @@ module.exports = class ClusterManager {
8686
const chokidar = require('chokidar');
8787
const fromRoot = require('../../utils/from_root');
8888

89-
const watchPaths = uniq(
90-
[
91-
fromRoot('src/core_plugins'),
92-
fromRoot('src/server'),
93-
fromRoot('src/ui'),
94-
fromRoot('src/utils'),
95-
fromRoot('config'),
96-
...extraPaths
97-
]
98-
.map(path => resolve(path))
99-
);
100-
101-
this.watcher = chokidar.watch(watchPaths, {
89+
const watchPaths = [
90+
fromRoot('src/core_plugins'),
91+
fromRoot('src/server'),
92+
fromRoot('src/ui'),
93+
fromRoot('src/utils'),
94+
fromRoot('config'),
95+
...extraPaths
96+
].map(path => resolve(path));
97+
98+
this.watcher = chokidar.watch(uniq(watchPaths), {
10299
cwd: fromRoot('.'),
103100
ignored: /[\\\/](\..*|node_modules|bower_components|public|__tests__)[\\\/]/
104101
});

src/core_plugins/console/.eslintrc

+31-29
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
---
22

33
root: true
4-
extends: '@elastic/kibana'
4+
extends: '../../../.eslintrc'
55

66
rules:
7-
block-scoped-var: [0]
8-
camelcase: [0]
9-
curly: [0]
10-
dot-location: [0]
11-
dot-notation: [0]
12-
eqeqeq: [0]
13-
guard-for-in: [0]
14-
indent: [0]
15-
max-len: [0]
16-
new-cap: [0]
17-
no-caller: [0]
18-
no-empty: [0]
19-
no-extend-native: [0]
20-
no-loop-func: [0]
21-
no-multi-str: [0]
22-
no-nested-ternary: [0]
23-
no-proto: [0]
24-
no-sequences: [0]
25-
no-undef: [0]
26-
no-use-before-define: [0]
27-
one-var: [0]
28-
quotes: [0]
29-
space-before-blocks: [0]
30-
space-in-parens: [0]
31-
space-infix-ops: [0]
32-
semi: [0]
33-
strict: [0]
34-
wrap-iife: [0]
7+
block-scoped-var: off
8+
camelcase: off
9+
curly: off
10+
dot-location: off
11+
dot-notation: off
12+
eqeqeq: off
13+
guard-for-in: off
14+
indent: off
15+
max-len: off
16+
new-cap: off
17+
no-caller: off
18+
no-empty: off
19+
no-extend-native: off
20+
no-loop-func: off
21+
no-multi-str: off
22+
no-nested-ternary: off
23+
no-proto: off
24+
no-sequences: off
25+
no-undef: off
26+
no-use-before-define: off
27+
one-var: off
28+
quotes: off
29+
space-before-blocks: off
30+
space-in-parens: off
31+
space-infix-ops: off
32+
semi: off
33+
strict: off
34+
wrap-iife: off
35+
no-var: off
36+
prefer-const: off

src/core_plugins/timelion/.eslintrc

-68
This file was deleted.

src/fixtures/mock_ui_state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export default {
1010
},
1111
on: _.noop,
1212
off: _.noop
13-
}
13+
};

src/ui/ui_bundle_collection.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const rimraf = promisify(require('rimraf'));
2-
const mkdirp = promisify(require('mkdirp'));
3-
const unlink = promisify(require('fs').unlink);
4-
const readdir = promisify(require('fs').readdir);
5-
61
import UiBundle from './ui_bundle';
72
import appEntryTemplate from './app_entry_template';
83
import { readFileSync as readSync } from 'fs';
94
import { pull, transform, pluck } from 'lodash';
105
import { promisify } from 'bluebird';
116
import { makeRe } from 'minimatch';
127

8+
const rimraf = promisify(require('rimraf'));
9+
const mkdirp = promisify(require('mkdirp'));
10+
const unlink = promisify(require('fs').unlink);
11+
const readdir = promisify(require('fs').readdir);
12+
1313
class UiBundleCollection {
1414
constructor(bundlerEnv, filter) {
1515
this.each = [];

tasks/config/eslint.js

+30-27
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
var resolve = require('path').resolve;
1+
import { resolve } from 'path';
2+
export default grunt => ({
3+
options: {
4+
paths: [
5+
'Gruntfile.js',
6+
'bin',
7+
'config',
8+
'src',
9+
'tasks',
10+
'test',
11+
'utilities',
12+
],
13+
},
214

3-
module.exports = function (grunt) {
4-
return {
5-
// just lint the source dir
6-
source: {
7-
options: {
8-
cache: resolve(grunt.config.get('root'), '.eslint.fixSource.cache')
9-
},
15+
source: {
16+
options: {
17+
cache: resolve(grunt.config.get('root'), '.eslint.fixSource.cache')
18+
}
19+
},
1020

11-
files: {
12-
src: '<%= lintThese %>'
13-
}
14-
},
21+
fixSource: {
22+
options: {
23+
cache: resolve(grunt.config.get('root'), '.eslint.fixSource.cache'),
24+
fix: true
25+
}
26+
},
1527

16-
// lint the source and fix any fixable errors
17-
fixSource: {
18-
options: {
19-
cache: resolve(grunt.config.get('root'), '.eslint.fixSource.cache'),
20-
fix: true
21-
},
22-
23-
files: {
24-
src: '<%= lintThese %>'
25-
}
26-
},
27-
28-
staged: {}
29-
};
30-
};
28+
staged: {
29+
options: {
30+
paths: null // overridden by lintStagedFiles task
31+
}
32+
}
33+
});

tasks/eslint.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { CLIEngine } from 'eslint';
2+
3+
const OPTION_DEFAULTS = {
4+
paths: null,
5+
cache: null,
6+
fix: false
7+
};
8+
9+
export default grunt => {
10+
grunt.registerMultiTask('eslint', function () {
11+
const options = this.options(OPTION_DEFAULTS);
12+
13+
if (!options.paths) {
14+
grunt.fatal(new Error('No eslint.options.paths specified'));
15+
return;
16+
}
17+
18+
const cli = new CLIEngine({
19+
cache: options.cache,
20+
fix: options.fix,
21+
cwd: grunt.config.get('root'),
22+
});
23+
24+
// report includes an entire list of files checked and the
25+
// fixes, errors, and warning for each.
26+
const report = cli.executeOnFiles(options.paths);
27+
28+
// output fixes to disk
29+
if (options.fix) {
30+
CLIEngine.outputFixes(report);
31+
}
32+
33+
// log the formatted linting report
34+
const formatter = cli.getFormatter();
35+
36+
const errTypes = [];
37+
if (report.errorCount > 0) errTypes.push('errors');
38+
if (report.warningCount > 0) errTypes.push('warning');
39+
if (!errTypes.length) return;
40+
41+
grunt.log.write(formatter(report.results));
42+
grunt.fatal(`eslint ${errTypes.join(' & ')}`);
43+
});
44+
};

0 commit comments

Comments
 (0)