Enable eslint
Running eslint on the code should make it easier to refactor the code later. Change-Id: I33cd7c609617d334596049223954dc24448cb1fe
This commit is contained in:
parent
7cbb7ea7c3
commit
38124b8de4
29
.eslintrc.js
Normal file
29
.eslintrc.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"jquery": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 6
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"indent": [
|
||||||
|
"error",
|
||||||
|
4
|
||||||
|
],
|
||||||
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"no-console": "off",
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"double"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v1.3.0
|
rev: v1.4.0-1
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
@ -11,13 +11,14 @@ repos:
|
|||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- id: check-symlinks
|
- id: check-symlinks
|
||||||
- id: check-vcs-permalinks
|
- id: check-vcs-permalinks
|
||||||
|
- id: check-json
|
||||||
- id: flake8
|
- id: flake8
|
||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
- id: requirements-txt-fixer
|
- id: requirements-txt-fixer
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
files: .*\.(yaml|yml)$
|
files: .*\.(yaml|yml)$
|
||||||
- repo: https://github.com/adrienverge/yamllint.git
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
rev: v1.11.1
|
rev: v1.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
files: \.(yaml|yml)$
|
files: \.(yaml|yml)$
|
||||||
@ -26,3 +27,8 @@ repos:
|
|||||||
rev: 0.6.0
|
rev: 0.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: bashate
|
- id: bashate
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-eslint
|
||||||
|
rev: v5.6.1 # Use the sha / tag you want to point at
|
||||||
|
hooks:
|
||||||
|
- id: eslint
|
||||||
|
entry: "eslint --format unix"
|
||||||
|
@ -31,44 +31,47 @@ const zuul_status_url = zuul_status_base + "api/status/change/";
|
|||||||
|
|
||||||
// Script start
|
// Script start
|
||||||
|
|
||||||
$('style#gerrit_sitecss').append('.result_RUNNING { color: #1e9ced; }');
|
/* defined by hideci.js */
|
||||||
|
/* global ci_latest_patchset, ci_parse_comments */
|
||||||
|
|
||||||
|
$("style#gerrit_sitecss").append(".result_RUNNING { color: #1e9ced; }");
|
||||||
|
|
||||||
var render = function(jobs) {
|
var render = function(jobs) {
|
||||||
var location = $('table.test_result_table');
|
var location = $("table.test_result_table");
|
||||||
|
|
||||||
var table = '<tbody>' +
|
var table = "<tbody>" +
|
||||||
'<tr>' +
|
"<tr>" +
|
||||||
'<td class="header">Zuul check</td>' +
|
"<td class=\"header\">Zuul check</td>" +
|
||||||
'<td class="header ci_date result_WARNING">Still running</td>' +
|
"<td class=\"header ci_date result_WARNING\">Still running</td>" +
|
||||||
'</tr>';
|
"</tr>";
|
||||||
|
|
||||||
$.each(jobs, function(i, job) {
|
$.each(jobs, function(i, job) {
|
||||||
var status_with_completeness = ((job.status === 'running' && typeof job.completeness !== 'undefined') ? 'RUNNING (' + job.completeness + ')' : job.status.toUpperCase());
|
var status_with_completeness = ((job.status === "running" && typeof job.completeness !== "undefined") ? "RUNNING (" + job.completeness + ")" : job.status.toUpperCase());
|
||||||
var voting = job.voting === true ? '' : '<small> (non-voting)</small>';
|
var voting = job.voting === true ? "" : "<small> (non-voting)</small>";
|
||||||
|
|
||||||
table += '<tr>' +
|
table += "<tr>" +
|
||||||
'<td><a href="' + job.url + '" rel="nofollow">' + job.name + '</a>' + voting + '</td>' +
|
"<td><a href=\"" + job.url + "\" rel=\"nofollow\">" + job.name + "</a>" + voting + "</td>" +
|
||||||
'<td><span class="comment_test_result"><span class="result_' + job.status.toUpperCase() +'">' + status_with_completeness + '</span></td>' +
|
"<td><span class=\"comment_test_result\"><span class=\"result_" + job.status.toUpperCase() +"\">" + status_with_completeness + "</span></td>" +
|
||||||
'</tr>';
|
"</tr>";
|
||||||
});
|
});
|
||||||
|
|
||||||
table += '</tbody>';
|
table += "</tbody>";
|
||||||
|
|
||||||
location.html(table);
|
location.html(table);
|
||||||
};
|
};
|
||||||
|
|
||||||
var main = function() {
|
var main = function() {
|
||||||
const url = $(location).attr('href');
|
const url = $(location).attr("href");
|
||||||
const matches_url = /^https?:\/\/review\.openstack\.org\/(#\/c\/)?(\d*)\/?(\d*)?\/?$/.exec(url);
|
const matches_url = /^https?:\/\/review\.openstack\.org\/(#\/c\/)?(\d*)\/?(\d*)?\/?$/.exec(url);
|
||||||
|
|
||||||
const change_id = matches_url[2];
|
const change_id = matches_url[2];
|
||||||
var change_ver = matches_url[3];
|
var change_ver = matches_url[3];
|
||||||
|
|
||||||
if (typeof change_ver === 'undefined'){
|
if (typeof change_ver === "undefined"){
|
||||||
change_ver = ci_latest_patchset(ci_parse_comments());
|
change_ver = ci_latest_patchset(ci_parse_comments());
|
||||||
}
|
}
|
||||||
|
|
||||||
var status_url = zuul_status_url + change_id + ',' + change_ver;
|
var status_url = zuul_status_url + change_id + "," + change_ver;
|
||||||
|
|
||||||
|
|
||||||
$.getJSON(status_url, function(data) {
|
$.getJSON(status_url, function(data) {
|
||||||
@ -76,17 +79,17 @@ var main = function() {
|
|||||||
var jobs = [];
|
var jobs = [];
|
||||||
|
|
||||||
if (data.length === 0){
|
if (data.length === 0){
|
||||||
if ($('.result_WARNING').length > 0){
|
if ($(".result_WARNING").length > 0){
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i <= data.length; i++){
|
for(var i=0; i <= data.length; i++){
|
||||||
queue = data[i];
|
queue = data[i];
|
||||||
if (queue.items_behind.length == 0){
|
if (queue.items_behind.length == 0){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queue){
|
if (!queue){
|
||||||
@ -97,14 +100,14 @@ var main = function() {
|
|||||||
$.each(queue.jobs, function(i, job) {
|
$.each(queue.jobs, function(i, job) {
|
||||||
var item = {};
|
var item = {};
|
||||||
|
|
||||||
item.status = job.result ? job.result.toLowerCase() : (job.url ? 'running' : 'queued');
|
item.status = job.result ? job.result.toLowerCase() : (job.url ? "running" : "queued");
|
||||||
item.name = job.name;
|
item.name = job.name;
|
||||||
item.voting = job.voting
|
item.voting = job.voting;
|
||||||
item.pipeline = job.pipeline;
|
item.pipeline = job.pipeline;
|
||||||
item.url = job.result ? job.report_url : (job.url ? zuul_status_base + job.url : "#");
|
item.url = job.result ? job.report_url : (job.url ? zuul_status_base + job.url : "#");
|
||||||
|
|
||||||
if (item.status === 'running' && job.remaining_time !== null){
|
if (item.status === "running" && job.remaining_time !== null){
|
||||||
item.completeness = Math.round(100 * (job.elapsed_time / (job.elapsed_time + job.remaining_time))) + '%';
|
item.completeness = Math.round(100 * (job.elapsed_time / (job.elapsed_time + job.remaining_time))) + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
jobs.push(item);
|
jobs.push(item);
|
||||||
@ -119,18 +122,19 @@ var main = function() {
|
|||||||
|
|
||||||
// So we refresh on each update.
|
// So we refresh on each update.
|
||||||
|
|
||||||
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
var observer = new MutationObserver(function(mutations, observer) {
|
var observer = new MutationObserver(function(mutations, observer) {
|
||||||
var span = $("span.rpcStatus");
|
var span = $("span.rpcStatus");
|
||||||
$.each(mutations, function(i, mutation) {
|
$.each(mutations, function(i, mutation) {
|
||||||
if (mutation.target === span[0] &&
|
if (mutation.target === span[0] &&
|
||||||
mutation.attributeName === "style" &&
|
mutation.attributeName === "style" &&
|
||||||
(!(span.is(":visible")))) {
|
(!(span.is(":visible")))) {
|
||||||
main();
|
main();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
observer.observe(document, {
|
observer.observe(document, {
|
||||||
subtree: true,
|
subtree: true,
|
||||||
attributes: true
|
attributes: true
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"envlist",
|
"envlist",
|
||||||
"envs",
|
"envs",
|
||||||
"gerrit",
|
"gerrit",
|
||||||
|
"hideci",
|
||||||
"htmlcov",
|
"htmlcov",
|
||||||
"ifeq",
|
"ifeq",
|
||||||
"ifndef",
|
"ifndef",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user