JSCS cleanup - style guide cleanup for karma.config.js files

karma.config.js files are wirtten in node.js and therefore should
be compliant to the JavaScript code style applyed in Horizon. Also
some formatting inconsistency should be fixed.

Change-Id: I98978ddb271af9dc3cf18c73d2bd83948d723de7
Partially-Implements: blueprint jscs-cleanup
This commit is contained in:
Shaoquan Chen 2015-06-23 22:41:52 -07:00
parent fcc14f6c1e
commit 7033531790
2 changed files with 68 additions and 38 deletions

View File

@ -1,13 +1,30 @@
/*
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict'; 'use strict';
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
module.exports = function(config) { module.exports = function (config) {
var xstaticPath; var xstaticPath;
var basePaths = [ var basePaths = [
'./.venv', './.venv',
'./.tox/py27' './.tox/py27'
] ];
for (var i = 0; i < basePaths.length; i++) { for (var i = 0; i < basePaths.length; i++) {
var basePath = path.resolve(basePaths[i]); var basePath = path.resolve(basePaths[i]);
@ -19,18 +36,17 @@ module.exports = function(config) {
} }
if (!xstaticPath) { if (!xstaticPath) {
console.error("xStatic libraries not found, please set up venv"); console.error('xStatic libraries not found, please set up venv');
process.exit(1); process.exit(1);
} }
config.set({ config.set({
preprocessors: { preprocessors: {
// Used to collect templates for preprocessing. // Used to collect templates for preprocessing.
// NOTE: the templates must also be listed in the files section below. // NOTE: the templates must also be listed in the files section below.
'./**/*.html': ['ng-html2js'], './**/*.html': ['ng-html2js'],
// Used to indicate files requiring coverage reports. // Used to indicate files requiring coverage reports.
'./**/!(*spec).js': ['coverage'] './**/!(*.spec).js': ['coverage']
}, },
// Sets up module to process templates. // Sets up module to process templates.
@ -40,14 +56,15 @@ module.exports = function(config) {
}, },
// Assumes you're in the top-level horizon directory. // Assumes you're in the top-level horizon directory.
basePath : './static/', basePath: './static/',
// Contains both source and test files. // Contains both source and test files.
files : [ files: [
/*
// shim, partly stolen from /i18n/js/horizon/ * shim, partly stolen from /i18n/js/horizon/
// Contains expected items not provided elsewhere (dynamically by * Contains expected items not provided elsewhere (dynamically by
// Django or via jasmine template. * Django or via jasmine template.
*/
'../../test-shim.js', '../../test-shim.js',
// from jasmine.html // from jasmine.html
@ -103,11 +120,11 @@ module.exports = function(config) {
'**/*.html' '**/*.html'
], ],
autoWatch : true, autoWatch: true,
frameworks: ['jasmine'], frameworks: ['jasmine'],
browsers : ['PhantomJS'], browsers: ['PhantomJS'],
phantomjsLauncher: { phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered // Have phantomjs exit if a ResourceError is encountered
@ -115,9 +132,9 @@ module.exports = function(config) {
exitOnResourceError: true exitOnResourceError: true
}, },
reporters : [ 'progress', 'coverage' ], reporters: ['progress', 'coverage'],
plugins : [ plugins: [
'karma-phantomjs-launcher', 'karma-phantomjs-launcher',
'karma-jasmine', 'karma-jasmine',
'karma-ng-html2js-preprocessor', 'karma-ng-html2js-preprocessor',
@ -125,10 +142,8 @@ module.exports = function(config) {
], ],
coverageReporter: { coverageReporter: {
type : 'html', type: 'html',
dir : '../.coverage-karma/' dir: '../.coverage-karma/'
} }
}); });
}; };

View File

@ -1,13 +1,30 @@
/*
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict'; 'use strict';
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
module.exports = function(config) { module.exports = function (config) {
var xstaticPath; var xstaticPath;
var basePaths = [ var basePaths = [
'./.venv', './.venv',
'./.tox/py27' './.tox/py27'
] ];
for (var i = 0; i < basePaths.length; i++) { for (var i = 0; i < basePaths.length; i++) {
var basePath = path.resolve(basePaths[i]); var basePath = path.resolve(basePaths[i]);
@ -19,18 +36,17 @@ module.exports = function(config) {
} }
if (!xstaticPath) { if (!xstaticPath) {
console.error("xStatic libraries not found, please set up venv"); console.error('xStatic libraries not found, please set up venv');
process.exit(1); process.exit(1);
} }
config.set({ config.set({
preprocessors: { preprocessors: {
// Used to collect templates for preprocessing. // Used to collect templates for preprocessing.
// NOTE: the templates must also be listed in the files section below. // NOTE: the templates must also be listed in the files section below.
'./**/*.html': ['ng-html2js'], './**/*.html': ['ng-html2js'],
// Used to indicate files requiring coverage reports. // Used to indicate files requiring coverage reports.
'./**/!(*spec).js': ['coverage'] './**/!(*.spec).js': ['coverage']
}, },
// Sets up module to process templates. // Sets up module to process templates.
@ -40,14 +56,15 @@ module.exports = function(config) {
}, },
// Assumes you're in the top-level horizon directory. // Assumes you're in the top-level horizon directory.
basePath : './static/', basePath: './static/',
// Contains both source and test files. // Contains both source and test files.
files : [ files: [
/*
// shim, partly stolen from /i18n/js/horizon/ * shim, partly stolen from /i18n/js/horizon/
// Contains expected items not provided elsewhere (dynamically by * Contains expected items not provided elsewhere (dynamically by
// Django or via jasmine template. * Django or via jasmine template.
*/
'../../test-shim.js', '../../test-shim.js',
// from jasmine.html // from jasmine.html
@ -103,11 +120,11 @@ module.exports = function(config) {
'**/*.html' '**/*.html'
], ],
autoWatch : true, autoWatch: true,
frameworks: ['jasmine'], frameworks: ['jasmine'],
browsers : ['PhantomJS'], browsers: ['PhantomJS'],
phantomjsLauncher: { phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered // Have phantomjs exit if a ResourceError is encountered
@ -115,9 +132,9 @@ module.exports = function(config) {
exitOnResourceError: true exitOnResourceError: true
}, },
reporters : [ 'progress', 'coverage' ], reporters: ['progress', 'coverage'],
plugins : [ plugins: [
'karma-phantomjs-launcher', 'karma-phantomjs-launcher',
'karma-jasmine', 'karma-jasmine',
'karma-ng-html2js-preprocessor', 'karma-ng-html2js-preprocessor',
@ -125,10 +142,8 @@ module.exports = function(config) {
], ],
coverageReporter: { coverageReporter: {
type : 'html', type: 'html',
dir : '../.coverage-karma/' dir: '../.coverage-karma/'
} }
}); });
}; };