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
|
@ -5,4 +5,4 @@ var bulk = require('bulk-require');
|
||||
|
||||
module.exports = angular.module('app.controllers', []);
|
||||
|
||||
bulk(__dirname, ['./**/!(*_index|*.spec).js']);
|
||||
bulk(__dirname, ['./**/!(*_index|*.spec).js']);
|
||||
|
@ -5,4 +5,4 @@ var bulk = require('bulk-require');
|
||||
|
||||
module.exports = angular.module('app.directives', []);
|
||||
|
||||
bulk(__dirname, ['./**/!(*_index|*.spec).js']);
|
||||
bulk(__dirname, ['./**/!(*_index|*.spec).js']);
|
||||
|
@ -52,10 +52,10 @@ var getDstatLanes = function(data, mins, maxes) {
|
||||
|
||||
if ('memory_usage_used' in row) {
|
||||
lanes.push([{
|
||||
scale: d3.scale.linear().domain([0, maxes.memory_usage_used]),
|
||||
value: function(d) { return d.memory_usage_used; },
|
||||
color: "rgba(102, 140, 178, 0.75)",
|
||||
text: "Memory"
|
||||
scale: d3.scale.linear().domain([0, maxes.memory_usage_used]),
|
||||
value: function(d) { return d.memory_usage_used; },
|
||||
color: "rgba(102, 140, 178, 0.75)",
|
||||
text: "Memory"
|
||||
}]);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ var getDstatLanes = function(data, mins, maxes) {
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
function timeline(datasetService) {
|
||||
function timeline($log, datasetService) {
|
||||
var link = function(scope, el, attrs) {
|
||||
var data = [];
|
||||
var dstat = {};
|
||||
@ -578,7 +578,7 @@ function timeline(datasetService) {
|
||||
// (dstat may not exist, but that's okay)
|
||||
initData(raw, dstat);
|
||||
}).catch(function(ex) {
|
||||
console.error(ex);
|
||||
$log.error(ex);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -12,33 +12,25 @@ require('./services/_index');
|
||||
require('./directives/_index');
|
||||
require('./filters/_index');
|
||||
|
||||
var bootstrap = function() {
|
||||
var requires = [
|
||||
'ui.router',
|
||||
'ui.bootstrap',
|
||||
'templates',
|
||||
'app.controllers',
|
||||
'app.services',
|
||||
'app.directives',
|
||||
'app.filters',
|
||||
'picardy.fontawesome'
|
||||
];
|
||||
|
||||
var requires = [
|
||||
'ui.router',
|
||||
'ui.bootstrap',
|
||||
'templates',
|
||||
'app.controllers',
|
||||
'app.services',
|
||||
'app.directives',
|
||||
'app.filters',
|
||||
'picardy.fontawesome'
|
||||
];
|
||||
angular.module('app', requires);
|
||||
|
||||
// mount on window for testing
|
||||
window.app = angular.module('app', requires);
|
||||
angular.module('app').constant('AppSettings', require('./constants'));
|
||||
|
||||
angular.module('app').constant('AppSettings', require('./constants'));
|
||||
var onConfig = require('./on_config');
|
||||
angular.module('app').config(onConfig);
|
||||
|
||||
angular.module('app').config(require('./on_config'));
|
||||
var onRun = require('./on_run');
|
||||
angular.module('app').run(require('./on_run'));
|
||||
|
||||
angular.module('app').run(require('./on_run'));
|
||||
|
||||
angular.bootstrap(document, ['app']);
|
||||
|
||||
window.bootstrap = null;
|
||||
};
|
||||
|
||||
// create and bootstrap application
|
||||
angular.element(document).ready(bootstrap);
|
||||
window.bootstrap = bootstrap;
|
||||
angular.bootstrap(document, ['app']);
|
||||
|
@ -6,10 +6,10 @@
|
||||
function OnRun($rootScope, AppSettings) {
|
||||
|
||||
// change page title based on state
|
||||
$rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
||||
var disable = $rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
||||
$rootScope.pageTitle = '';
|
||||
|
||||
if ( toState.title ) {
|
||||
if (toState.title) {
|
||||
$rootScope.pageTitle += toState.title;
|
||||
$rootScope.pageTitle += ' \u2014 ';
|
||||
}
|
||||
@ -17,6 +17,8 @@ function OnRun($rootScope, AppSettings) {
|
||||
$rootScope.pageTitle += AppSettings.appTitle;
|
||||
});
|
||||
|
||||
$rootScope.$on('$destroy', disable);
|
||||
|
||||
}
|
||||
|
||||
module.exports = OnRun;
|
||||
module.exports = OnRun;
|
||||
|
@ -5,4 +5,4 @@ var bulk = require('bulk-require');
|
||||
|
||||
module.exports = angular.module('app.services', []);
|
||||
|
||||
bulk(__dirname, ['./**/!(*_index|*.spec).js']);
|
||||
bulk(__dirname, ['./**/!(*_index|*.spec).js']);
|
||||
|
@ -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() {
|
||||
|
||||
// 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.images.src, ['images']);
|
||||
gulp.watch(config.fonts.src, ['fonts']);
|
||||
|
@ -23,8 +23,9 @@
|
||||
"d3": "^3.5.6",
|
||||
"debowerify": "^1.2.0",
|
||||
"del": "^0.1.3",
|
||||
"eslint": "^0.23.0",
|
||||
"eslint-config-openstack": "1.2.0",
|
||||
"eslint": "1.5.1",
|
||||
"eslint-config-openstack": "1.2.2",
|
||||
"eslint-plugin-angular": "0.12.0",
|
||||
"express": "^4.7.2",
|
||||
"gulp": "^3.8.8",
|
||||
"gulp-angular-templatecache": "^1.3.0",
|
||||
@ -34,7 +35,6 @@
|
||||
"gulp-gzip": "^0.0.8",
|
||||
"gulp-if": "^1.2.5",
|
||||
"gulp-imagemin": "^1.1.0",
|
||||
"gulp-jshint": "^1.8.3",
|
||||
"gulp-karma": "0.0.4",
|
||||
"gulp-notify": "^2.0.0",
|
||||
"gulp-protractor": "0.0.11",
|
||||
@ -49,7 +49,6 @@
|
||||
"jasmine-ajax": "^3.1.1",
|
||||
"jasmine-core": "^2.3.4",
|
||||
"jasmine-fixture": "^1.3.2",
|
||||
"jshint-stylish": "^1.0.0",
|
||||
"karma": "~0.12.0",
|
||||
"karma-babel-preprocessor": "^4.0.1",
|
||||
"karma-browserify": "^4.0.0",
|
||||
@ -71,7 +70,7 @@
|
||||
"scripts": {
|
||||
"postinstall": "if [ ! -d .venv ]; then tox -epy27 --notest; fi",
|
||||
"test": "gulp unit",
|
||||
"lint": "eslint --no-color stackviz/static"
|
||||
"lint": "eslint ./"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
@ -18,4 +18,4 @@ describe('E2E: Example', function() {
|
||||
expect(element.getText()).toEqual('1234');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -9,4 +9,4 @@ describe('E2E: Routes', function() {
|
||||
expect(browser.getLocationAbsUrl()).toMatch('/');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -29,4 +29,4 @@ exports.config = {
|
||||
'e2e/**/*.js'
|
||||
]
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
window.bootstrap && window.bootstrap();
|
||||
|
||||
describe('Unit: HomeCtrl', function() {
|
||||
|
||||
var ctrl;
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
window.bootstrap && window.bootstrap();
|
||||
|
||||
describe('Unit: DatasetService', function() {
|
||||
|
||||
var service, httpBackend;
|
||||
@ -13,7 +11,7 @@ describe('Unit: DatasetService', function() {
|
||||
"tree": "tempest_file_freshlog_0_tree.json",
|
||||
"id": 0,
|
||||
"name": "Subunit File: freshlog"}
|
||||
]};
|
||||
]};
|
||||
|
||||
beforeEach(function() {
|
||||
// instantiate the app module
|
||||
@ -32,7 +30,7 @@ describe('Unit: DatasetService', function() {
|
||||
|
||||
it('should return config.json', function() {
|
||||
httpBackend.whenGET("data/config.json").respond(exampleConfig);
|
||||
service.list().then(function(config){
|
||||
service.list().then(function(config) {
|
||||
expect(config.data).toEqual(exampleConfig);
|
||||
});
|
||||
httpBackend.flush();
|
||||
@ -40,28 +38,28 @@ describe('Unit: DatasetService', function() {
|
||||
|
||||
it('should GET the raw file from a dataset', function() {
|
||||
httpBackend.whenGET(exampleConfig.raw).respond(exampleConfig.raw);
|
||||
service.raw(exampleConfig).then(function(raw){
|
||||
service.raw(exampleConfig).then(function(raw) {
|
||||
expect(raw).toEqual(exampleConfig.raw);
|
||||
});
|
||||
});
|
||||
|
||||
it('should GET the details file from a dataset', function() {
|
||||
httpBackend.whenGET(exampleConfig.details).respond(exampleConfig.details);
|
||||
service.details(exampleConfig).then(function(details){
|
||||
service.details(exampleConfig).then(function(details) {
|
||||
expect(details).toEqual(exampleConfig.details);
|
||||
});
|
||||
});
|
||||
|
||||
it('should GET the tree file from a dataset', function() {
|
||||
httpBackend.whenGET(exampleConfig.tree).respond(exampleConfig.tree);
|
||||
service.tree(exampleConfig).then(function(tree){
|
||||
service.tree(exampleConfig).then(function(tree) {
|
||||
expect(tree).toEqual(exampleConfig.tree);
|
||||
});
|
||||
});
|
||||
|
||||
it('should GET the dstat file from a dataset', function() {
|
||||
httpBackend.whenGET(exampleConfig.dstat).respond(exampleConfig.dstat);
|
||||
service.dstat(exampleConfig).then(function(dstat){
|
||||
service.dstat(exampleConfig).then(function(dstat) {
|
||||
expect(dstat).toEqual(exampleConfig.dstat);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user