Switch to eslint.
This ports over changes made in openstack-health to convert the project from jshint to eslint, with the eslint-config-openstack plugin. Change-Id: Iaa0490d07603e2481e1c738136f9fda1be95dea8
This commit is contained in:
parent
42b83c81da
commit
7eab971d3f
8
.eslintignore
Normal file
8
.eslintignore
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
cover
|
||||||
|
build
|
||||||
|
node_modules
|
||||||
|
coverage
|
||||||
|
doc
|
||||||
|
app/vendor-js
|
||||||
|
app/js/templates.js
|
||||||
|
gulp
|
14
.eslintrc
Normal file
14
.eslintrc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Use eslint-config-openstack
|
||||||
|
extends: openstack
|
||||||
|
|
||||||
|
# Set up globals
|
||||||
|
globals:
|
||||||
|
angular: false
|
||||||
|
module: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
browser: true
|
||||||
|
jasmine: true
|
||||||
|
|
||||||
|
rules:
|
||||||
|
module-setter: 0
|
20
.jshintrc
20
.jshintrc
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"node": true,
|
|
||||||
"jasmine": true,
|
|
||||||
"browser": true,
|
|
||||||
"esnext": true,
|
|
||||||
"bitwise": true,
|
|
||||||
"curly": true,
|
|
||||||
"eqeqeq": true,
|
|
||||||
"immed": true,
|
|
||||||
"indent": 2,
|
|
||||||
"latedef": true,
|
|
||||||
"noarg": true,
|
|
||||||
"regexp": true,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true,
|
|
||||||
"strict": true,
|
|
||||||
"trailing": true,
|
|
||||||
"smarttabs": true,
|
|
||||||
"newcap": false
|
|
||||||
}
|
|
7
app/.eslintrc
Normal file
7
app/.eslintrc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Enable eslint-plugin-angular
|
||||||
|
plugins:
|
||||||
|
- angular
|
||||||
|
|
||||||
|
rules:
|
||||||
|
angular/module-setter: 0
|
||||||
|
angular/module-getter: 0
|
@ -96,7 +96,7 @@ var getDstatLanes = function(data, mins, maxes) {
|
|||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
*/
|
*/
|
||||||
function timeline(datasetService) {
|
function timeline($log, datasetService) {
|
||||||
var link = function(scope, el, attrs) {
|
var link = function(scope, el, attrs) {
|
||||||
var data = [];
|
var data = [];
|
||||||
var dstat = {};
|
var dstat = {};
|
||||||
@ -578,7 +578,7 @@ function timeline(datasetService) {
|
|||||||
// (dstat may not exist, but that's okay)
|
// (dstat may not exist, but that's okay)
|
||||||
initData(raw, dstat);
|
initData(raw, dstat);
|
||||||
}).catch(function(ex) {
|
}).catch(function(ex) {
|
||||||
console.error(ex);
|
$log.error(ex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -12,9 +12,7 @@ require('./services/_index');
|
|||||||
require('./directives/_index');
|
require('./directives/_index');
|
||||||
require('./filters/_index');
|
require('./filters/_index');
|
||||||
|
|
||||||
var bootstrap = function() {
|
var requires = [
|
||||||
|
|
||||||
var requires = [
|
|
||||||
'ui.router',
|
'ui.router',
|
||||||
'ui.bootstrap',
|
'ui.bootstrap',
|
||||||
'templates',
|
'templates',
|
||||||
@ -23,22 +21,16 @@ var bootstrap = function() {
|
|||||||
'app.directives',
|
'app.directives',
|
||||||
'app.filters',
|
'app.filters',
|
||||||
'picardy.fontawesome'
|
'picardy.fontawesome'
|
||||||
];
|
];
|
||||||
|
|
||||||
// mount on window for testing
|
angular.module('app', requires);
|
||||||
window.app = angular.module('app', requires);
|
|
||||||
|
|
||||||
angular.module('app').constant('AppSettings', require('./constants'));
|
angular.module('app').constant('AppSettings', require('./constants'));
|
||||||
|
|
||||||
angular.module('app').config(require('./on_config'));
|
var onConfig = require('./on_config');
|
||||||
|
angular.module('app').config(onConfig);
|
||||||
|
|
||||||
angular.module('app').run(require('./on_run'));
|
var onRun = require('./on_run');
|
||||||
|
angular.module('app').run(require('./on_run'));
|
||||||
|
|
||||||
angular.bootstrap(document, ['app']);
|
angular.bootstrap(document, ['app']);
|
||||||
|
|
||||||
window.bootstrap = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
// create and bootstrap application
|
|
||||||
angular.element(document).ready(bootstrap);
|
|
||||||
window.bootstrap = bootstrap;
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
function OnRun($rootScope, AppSettings) {
|
function OnRun($rootScope, AppSettings) {
|
||||||
|
|
||||||
// change page title based on state
|
// change page title based on state
|
||||||
$rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
var disable = $rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
||||||
$rootScope.pageTitle = '';
|
$rootScope.pageTitle = '';
|
||||||
|
|
||||||
if ( toState.title ) {
|
if (toState.title) {
|
||||||
$rootScope.pageTitle += toState.title;
|
$rootScope.pageTitle += toState.title;
|
||||||
$rootScope.pageTitle += ' \u2014 ';
|
$rootScope.pageTitle += ' \u2014 ';
|
||||||
}
|
}
|
||||||
@ -17,6 +17,8 @@ function OnRun($rootScope, AppSettings) {
|
|||||||
$rootScope.pageTitle += AppSettings.appTitle;
|
$rootScope.pageTitle += AppSettings.appTitle;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$rootScope.$on('$destroy', disable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = OnRun;
|
module.exports = OnRun;
|
@ -1,11 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var config = require('../config');
|
|
||||||
var gulp = require('gulp');
|
|
||||||
var jshint = require('gulp-jshint');
|
|
||||||
|
|
||||||
gulp.task('lint', function() {
|
|
||||||
return gulp.src([config.scripts.src, '!app/js/templates.js'])
|
|
||||||
.pipe(jshint())
|
|
||||||
.pipe(jshint.reporter('jshint-stylish'));
|
|
||||||
});
|
|
@ -6,7 +6,6 @@ var gulp = require('gulp');
|
|||||||
gulp.task('watch', ['browserSync', 'server'], function() {
|
gulp.task('watch', ['browserSync', 'server'], function() {
|
||||||
|
|
||||||
// Scripts are automatically watched and rebundled by Watchify inside Browserify task
|
// Scripts are automatically watched and rebundled by Watchify inside Browserify task
|
||||||
gulp.watch(config.scripts.src, ['lint']);
|
|
||||||
gulp.watch(config.styles.src, ['styles']);
|
gulp.watch(config.styles.src, ['styles']);
|
||||||
gulp.watch(config.images.src, ['images']);
|
gulp.watch(config.images.src, ['images']);
|
||||||
gulp.watch(config.fonts.src, ['fonts']);
|
gulp.watch(config.fonts.src, ['fonts']);
|
||||||
|
@ -23,8 +23,9 @@
|
|||||||
"d3": "^3.5.6",
|
"d3": "^3.5.6",
|
||||||
"debowerify": "^1.2.0",
|
"debowerify": "^1.2.0",
|
||||||
"del": "^0.1.3",
|
"del": "^0.1.3",
|
||||||
"eslint": "^0.23.0",
|
"eslint": "1.5.1",
|
||||||
"eslint-config-openstack": "1.2.0",
|
"eslint-config-openstack": "1.2.2",
|
||||||
|
"eslint-plugin-angular": "0.12.0",
|
||||||
"express": "^4.7.2",
|
"express": "^4.7.2",
|
||||||
"gulp": "^3.8.8",
|
"gulp": "^3.8.8",
|
||||||
"gulp-angular-templatecache": "^1.3.0",
|
"gulp-angular-templatecache": "^1.3.0",
|
||||||
@ -34,7 +35,6 @@
|
|||||||
"gulp-gzip": "^0.0.8",
|
"gulp-gzip": "^0.0.8",
|
||||||
"gulp-if": "^1.2.5",
|
"gulp-if": "^1.2.5",
|
||||||
"gulp-imagemin": "^1.1.0",
|
"gulp-imagemin": "^1.1.0",
|
||||||
"gulp-jshint": "^1.8.3",
|
|
||||||
"gulp-karma": "0.0.4",
|
"gulp-karma": "0.0.4",
|
||||||
"gulp-notify": "^2.0.0",
|
"gulp-notify": "^2.0.0",
|
||||||
"gulp-protractor": "0.0.11",
|
"gulp-protractor": "0.0.11",
|
||||||
@ -49,7 +49,6 @@
|
|||||||
"jasmine-ajax": "^3.1.1",
|
"jasmine-ajax": "^3.1.1",
|
||||||
"jasmine-core": "^2.3.4",
|
"jasmine-core": "^2.3.4",
|
||||||
"jasmine-fixture": "^1.3.2",
|
"jasmine-fixture": "^1.3.2",
|
||||||
"jshint-stylish": "^1.0.0",
|
|
||||||
"karma": "~0.12.0",
|
"karma": "~0.12.0",
|
||||||
"karma-babel-preprocessor": "^4.0.1",
|
"karma-babel-preprocessor": "^4.0.1",
|
||||||
"karma-browserify": "^4.0.0",
|
"karma-browserify": "^4.0.0",
|
||||||
@ -71,7 +70,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "if [ ! -d .venv ]; then tox -epy27 --notest; fi",
|
"postinstall": "if [ ! -d .venv ]; then tox -epy27 --notest; fi",
|
||||||
"test": "gulp unit",
|
"test": "gulp unit",
|
||||||
"lint": "eslint --no-color stackviz/static"
|
"lint": "eslint ./"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
window.bootstrap && window.bootstrap();
|
|
||||||
|
|
||||||
describe('Unit: HomeCtrl', function() {
|
describe('Unit: HomeCtrl', function() {
|
||||||
|
|
||||||
var ctrl;
|
var ctrl;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
window.bootstrap && window.bootstrap();
|
|
||||||
|
|
||||||
describe('Unit: DatasetService', function() {
|
describe('Unit: DatasetService', function() {
|
||||||
|
|
||||||
var service, httpBackend;
|
var service, httpBackend;
|
||||||
@ -32,7 +30,7 @@ describe('Unit: DatasetService', function() {
|
|||||||
|
|
||||||
it('should return config.json', function() {
|
it('should return config.json', function() {
|
||||||
httpBackend.whenGET("data/config.json").respond(exampleConfig);
|
httpBackend.whenGET("data/config.json").respond(exampleConfig);
|
||||||
service.list().then(function(config){
|
service.list().then(function(config) {
|
||||||
expect(config.data).toEqual(exampleConfig);
|
expect(config.data).toEqual(exampleConfig);
|
||||||
});
|
});
|
||||||
httpBackend.flush();
|
httpBackend.flush();
|
||||||
@ -40,28 +38,28 @@ describe('Unit: DatasetService', function() {
|
|||||||
|
|
||||||
it('should GET the raw file from a dataset', function() {
|
it('should GET the raw file from a dataset', function() {
|
||||||
httpBackend.whenGET(exampleConfig.raw).respond(exampleConfig.raw);
|
httpBackend.whenGET(exampleConfig.raw).respond(exampleConfig.raw);
|
||||||
service.raw(exampleConfig).then(function(raw){
|
service.raw(exampleConfig).then(function(raw) {
|
||||||
expect(raw).toEqual(exampleConfig.raw);
|
expect(raw).toEqual(exampleConfig.raw);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should GET the details file from a dataset', function() {
|
it('should GET the details file from a dataset', function() {
|
||||||
httpBackend.whenGET(exampleConfig.details).respond(exampleConfig.details);
|
httpBackend.whenGET(exampleConfig.details).respond(exampleConfig.details);
|
||||||
service.details(exampleConfig).then(function(details){
|
service.details(exampleConfig).then(function(details) {
|
||||||
expect(details).toEqual(exampleConfig.details);
|
expect(details).toEqual(exampleConfig.details);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should GET the tree file from a dataset', function() {
|
it('should GET the tree file from a dataset', function() {
|
||||||
httpBackend.whenGET(exampleConfig.tree).respond(exampleConfig.tree);
|
httpBackend.whenGET(exampleConfig.tree).respond(exampleConfig.tree);
|
||||||
service.tree(exampleConfig).then(function(tree){
|
service.tree(exampleConfig).then(function(tree) {
|
||||||
expect(tree).toEqual(exampleConfig.tree);
|
expect(tree).toEqual(exampleConfig.tree);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should GET the dstat file from a dataset', function() {
|
it('should GET the dstat file from a dataset', function() {
|
||||||
httpBackend.whenGET(exampleConfig.dstat).respond(exampleConfig.dstat);
|
httpBackend.whenGET(exampleConfig.dstat).respond(exampleConfig.dstat);
|
||||||
service.dstat(exampleConfig).then(function(dstat){
|
service.dstat(exampleConfig).then(function(dstat) {
|
||||||
expect(dstat).toEqual(exampleConfig.dstat);
|
expect(dstat).toEqual(exampleConfig.dstat);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user