Skip to content

Commit 02de55d

Browse files
jscs in zeppelin-web
1 parent 90a7e51 commit 02de55d

File tree

31 files changed

+3102
-3070
lines changed

31 files changed

+3102
-3070
lines changed

zeppelin-web/.jscsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"preset": "google",
3+
"maximumLineLength": {
4+
"value": 120,
5+
"allExcept": [
6+
"comments",
7+
"regex"
8+
]
9+
}
10+
}

zeppelin-web/Gruntfile.js

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// use this if you want to recursively match all subfolders:
2525
// 'test/spec/**/*.js'
2626

27-
module.exports = function (grunt) {
27+
module.exports = function(grunt) {
2828

2929
// Load grunt tasks automatically
3030
require('load-grunt-tasks')(grunt);
@@ -161,7 +161,7 @@ module.exports = function (grunt) {
161161
livereload: {
162162
options: {
163163
open: true,
164-
middleware: function (connect) {
164+
middleware: function(connect) {
165165
return [
166166
connect.static('.tmp'),
167167
connect().use(
@@ -176,7 +176,7 @@ module.exports = function (grunt) {
176176
test: {
177177
options: {
178178
port: 9001,
179-
middleware: function (connect) {
179+
middleware: function(connect) {
180180
return [
181181
connect.static('.tmp'),
182182
connect.static('test'),
@@ -197,10 +197,30 @@ module.exports = function (grunt) {
197197
}
198198
},
199199

200+
jscs: {
201+
options: {
202+
config: '.jscsrc',
203+
esnext: true, // If you use ES6 http://jscs.info/overview.html#esnext
204+
verbose: true, // If you need output with rule names http://jscs.info/overview.html#verbose
205+
requireCurlyBraces: ['if']
206+
},
207+
all: {
208+
src: [
209+
'Gruntfile.js',
210+
'<%= yeoman.app %>/app/**/*.js',
211+
'<%= yeoman.app %>/components/**/*.js'
212+
]
213+
},
214+
test: {
215+
src: ['test/spec/{,*/}*.js']
216+
}
217+
},
218+
200219
// Make sure code styles are up to par and there are no obvious mistakes
201220
jshint: {
202221
options: {
203222
jshintrc: '.jshintrc',
223+
reporterOutput: '',
204224
reporter: require('jshint-stylish')
205225
},
206226
all: {
@@ -253,27 +273,26 @@ module.exports = function (grunt) {
253273

254274
// Automatically inject Bower components into the app
255275
wiredep: {
256-
options: {
257-
},
276+
options: {},
258277
app: {
259278
src: ['<%= yeoman.app %>/index.html'],
260-
ignorePath: /\.\.\//
279+
ignorePath: /\.\.\//
261280
},
262281
test: {
263282
devDependencies: true,
264283
src: '<%= karma.unit.configFile %>',
265-
ignorePath: /\.\.\//,
266-
fileTypes:{
284+
ignorePath: /\.\.\//,
285+
fileTypes: {
267286
js: {
268287
block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
269-
detect: {
270-
js: /'(.*\.js)'/gi
271-
},
272-
replace: {
273-
js: '\'{{filePath}}\','
274-
}
288+
detect: {
289+
js: /'(.*\.js)'/gi
290+
},
291+
replace: {
292+
js: '\'{{filePath}}\','
275293
}
276294
}
295+
}
277296
}
278297
},
279298

@@ -301,7 +320,7 @@ module.exports = function (grunt) {
301320
html: ['<%= yeoman.dist %>/{,*/}*.html'],
302321
css: ['<%= yeoman.dist %>/styles/*.css'],
303322
options: {
304-
assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/assets']
323+
assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/assets']
305324
}
306325
},
307326

@@ -393,12 +412,12 @@ module.exports = function (grunt) {
393412
]
394413
}, {
395414
// copy fonts
396-
expand : true,
415+
expand: true,
397416
cwd: '<%= yeoman.app %>',
398417
dest: '<%= yeoman.dist %>',
399418
src: ['fonts/**/*.{eot,svg,ttf,woff}']
400419
}, {
401-
expand : true,
420+
expand: true,
402421
cwd: '<%= yeoman.app %>',
403422
dest: '<%= yeoman.dist %>',
404423
src: ['app/**/*.html', 'components/**/*.html']
@@ -456,8 +475,7 @@ module.exports = function (grunt) {
456475
}
457476
});
458477

459-
460-
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
478+
grunt.registerTask('serve', 'Compile then start a connect web server', function(target) {
461479
if (target === 'dist') {
462480
return grunt.task.run(['build', 'connect:dist:keepalive']);
463481
}
@@ -472,7 +490,7 @@ module.exports = function (grunt) {
472490
]);
473491
});
474492

475-
grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
493+
grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function(target) {
476494
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
477495
grunt.task.run(['serve:' + target]);
478496
});
@@ -487,6 +505,7 @@ module.exports = function (grunt) {
487505
]);
488506

489507
grunt.registerTask('build', [
508+
'newer:jscs',
490509
'jshint:all',
491510
'clean:dist',
492511
'wiredep',

zeppelin-web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"grunt-svgmin": "^0.4.0",
3131
"grunt-usemin": "^2.1.1",
3232
"grunt-wiredep": "~2.0.0",
33+
"grunt-jscs": "^2.1.0",
3334
"jshint-stylish": "^0.2.0",
3435
"karma": "~0.12.23",
3536
"karma-coverage": "^0.5.1",

zeppelin-web/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<exclude>.gitignore</exclude>
6060
<exclude>.bowerrc</exclude>
6161
<exclude>.editorconfig</exclude>
62+
<exclude>.jscsrc</exclude>
6263
<exclude>.jshintrc</exclude>
6364
<exclude>.tmp/**</exclude>
6465
<exclude>**/.settings/*</exclude>

zeppelin-web/src/app/app.js

Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -16,103 +16,101 @@
1616
*/
1717
'use strict';
1818
(function() {
19-
var zeppelinWebApp = angular.module('zeppelinWebApp', [
20-
'ngCookies',
21-
'ngAnimate',
22-
'ngRoute',
23-
'ngSanitize',
24-
'angular-websocket',
25-
'ui.ace',
26-
'ui.bootstrap',
27-
'as.sortable',
28-
'ngTouch',
29-
'ngDragDrop',
30-
'angular.filter',
31-
'monospaced.elastic',
32-
'puElasticInput',
33-
'xeditable',
34-
'ngToast',
35-
'focus-if',
36-
'ngResource'
37-
])
19+
var zeppelinWebApp = angular.module('zeppelinWebApp', [
20+
'ngCookies',
21+
'ngAnimate',
22+
'ngRoute',
23+
'ngSanitize',
24+
'angular-websocket',
25+
'ui.ace',
26+
'ui.bootstrap',
27+
'as.sortable',
28+
'ngTouch',
29+
'ngDragDrop',
30+
'angular.filter',
31+
'monospaced.elastic',
32+
'puElasticInput',
33+
'xeditable',
34+
'ngToast',
35+
'focus-if',
36+
'ngResource'
37+
])
3838
.filter('breakFilter', function() {
39-
return function (text) {
40-
if (!!text) {
41-
return text.replace(/\n/g, '<br />');
42-
}
43-
};
39+
return function(text) {
40+
if (!!text) {
41+
return text.replace(/\n/g, '<br />');
42+
}
43+
};
4444
})
45-
.config(function ($httpProvider, $routeProvider, ngToastProvider) {
46-
// withCredentials when running locally via grunt
47-
$httpProvider.defaults.withCredentials = true;
45+
.config(function($httpProvider, $routeProvider, ngToastProvider) {
46+
// withCredentials when running locally via grunt
47+
$httpProvider.defaults.withCredentials = true;
4848

49-
$routeProvider
49+
$routeProvider
5050
.when('/', {
51-
templateUrl: 'app/home/home.html'
51+
templateUrl: 'app/home/home.html'
5252
})
5353
.when('/notebook/:noteId', {
54-
templateUrl: 'app/notebook/notebook.html',
55-
controller: 'NotebookCtrl'
54+
templateUrl: 'app/notebook/notebook.html',
55+
controller: 'NotebookCtrl'
5656
})
5757
.when('/notebook/:noteId/paragraph?=:paragraphId', {
58-
templateUrl: 'app/notebook/notebook.html',
59-
controller: 'NotebookCtrl'
58+
templateUrl: 'app/notebook/notebook.html',
59+
controller: 'NotebookCtrl'
6060
})
6161
.when('/notebook/:noteId/paragraph/:paragraphId?', {
62-
templateUrl: 'app/notebook/notebook.html',
63-
controller: 'NotebookCtrl'
62+
templateUrl: 'app/notebook/notebook.html',
63+
controller: 'NotebookCtrl'
6464
})
6565
.when('/interpreter', {
66-
templateUrl: 'app/interpreter/interpreter.html',
67-
controller: 'InterpreterCtrl'
66+
templateUrl: 'app/interpreter/interpreter.html',
67+
controller: 'InterpreterCtrl'
6868
})
6969
.when('/credential', {
70-
templateUrl: 'app/credential/credential.html',
71-
controller: 'CredentialCtrl'
70+
templateUrl: 'app/credential/credential.html',
71+
controller: 'CredentialCtrl'
7272
})
7373
.when('/configuration', {
7474
templateUrl: 'app/configuration/configuration.html',
7575
controller: 'ConfigurationCtrl'
7676
})
7777
.when('/search/:searchTerm', {
78-
templateUrl: 'app/search/result-list.html',
79-
controller: 'SearchResultCtrl'
78+
templateUrl: 'app/search/result-list.html',
79+
controller: 'SearchResultCtrl'
8080
})
8181
.otherwise({
82-
redirectTo: '/'
82+
redirectTo: '/'
8383
});
8484

85-
ngToastProvider.configure({
86-
dismissButton: true,
87-
dismissOnClick: false,
88-
timeout: 6000
89-
});
85+
ngToastProvider.configure({
86+
dismissButton: true,
87+
dismissOnClick: false,
88+
timeout: 6000
89+
});
9090
});
9191

92+
function auth() {
93+
var $http = angular.injector(['ng']).get('$http');
94+
var baseUrlSrv = angular.injector(['zeppelinWebApp']).get('baseUrlSrv');
95+
// withCredentials when running locally via grunt
96+
$http.defaults.withCredentials = true;
9297

93-
function auth() {
94-
var $http = angular.injector(['ng']).get('$http');
95-
var baseUrlSrv = angular.injector(['zeppelinWebApp']).get('baseUrlSrv');
96-
// withCredentials when running locally via grunt
97-
$http.defaults.withCredentials = true;
98-
99-
return $http.get(baseUrlSrv.getRestApiBase()+'/security/ticket').then(function(response) {
100-
zeppelinWebApp.run(function($rootScope) {
101-
$rootScope.ticket = angular.fromJson(response.data).body;
102-
});
103-
}, function(errorResponse) {
104-
// Handle error case
105-
});
106-
}
107-
108-
function bootstrapApplication() {
109-
angular.bootstrap(document, ['zeppelinWebApp']);
110-
}
98+
return $http.get(baseUrlSrv.getRestApiBase() + '/security/ticket').then(function(response) {
99+
zeppelinWebApp.run(function($rootScope) {
100+
$rootScope.ticket = angular.fromJson(response.data).body;
101+
});
102+
}, function(errorResponse) {
103+
// Handle error case
104+
});
105+
}
111106

107+
function bootstrapApplication() {
108+
angular.bootstrap(document, ['zeppelinWebApp']);
109+
}
112110

113-
angular.element(document).ready(function() {
114-
auth().then(bootstrapApplication);
115-
});
111+
angular.element(document).ready(function() {
112+
auth().then(bootstrapApplication);
113+
});
116114

117115
}());
118116

zeppelin-web/src/app/configuration/configuration.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ angular.module('zeppelinWebApp').controller('ConfigurationCtrl', function($scope
1919
$scope._ = _;
2020

2121
var getConfigurations = function() {
22-
$http.get(baseUrlSrv.getRestApiBase()+'/configurations/all').
22+
$http.get(baseUrlSrv.getRestApiBase() + '/configurations/all').
2323
success(function(data, status, headers, config) {
2424
$scope.configurations = data.body;
2525
}).

zeppelin-web/src/app/credential/credential.controller.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515
'use strict';
1616

17-
angular.module('zeppelinWebApp').controller('CredentialCtrl', function($scope, $route, $routeParams, $location, $rootScope,
18-
$http, baseUrlSrv) {
17+
angular.module('zeppelinWebApp').controller('CredentialCtrl', function($scope, $route, $routeParams, $location,
18+
$rootScope, $http, baseUrlSrv) {
1919
$scope._ = _;
2020

2121
$scope.credentialEntity = '';
@@ -33,11 +33,11 @@ angular.module('zeppelinWebApp').controller('CredentialCtrl', function($scope, $
3333
}
3434

3535
$http.put(baseUrlSrv.getRestApiBase() + '/credential',
36-
{ 'entity': $scope.credentialEntity,
36+
{'entity': $scope.credentialEntity,
3737
'username': $scope.credentialUsername,
3838
'password': $scope.credentialPassword
39-
} ).
40-
success(function (data, status, headers, config) {
39+
}).
40+
success(function(data, status, headers, config) {
4141
BootstrapDialog.alert({
4242
closable: true,
4343
message: 'Successfully saved credentials.'
@@ -47,7 +47,7 @@ angular.module('zeppelinWebApp').controller('CredentialCtrl', function($scope, $
4747
$scope.credentialPassword = '';
4848
console.log('Success %o %o', status, data.message);
4949
}).
50-
error(function (data, status, headers, config) {
50+
error(function(data, status, headers, config) {
5151
alert('Error saving credentials');
5252
console.log('Error %o %o', status, data.message);
5353
});

zeppelin-web/src/app/home/home.controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
*/
1414
'use strict';
1515

16-
angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, notebookListDataFactory, websocketMsgSrv, $rootScope, arrayOrderingSrv, $http, baseUrlSrv) {
16+
angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, notebookListDataFactory, websocketMsgSrv,
17+
$rootScope, arrayOrderingSrv, $http, baseUrlSrv) {
1718
var vm = this;
1819
vm.notes = notebookListDataFactory;
1920
vm.websocketMsgSrv = websocketMsgSrv;

0 commit comments

Comments
 (0)