Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nsqadmin: fix eslint errors #1469

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions nsqadmin/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@
"wrap-iife": [1]
},
"globals": {
"BASE_PATH": true,
"GRAPHITE_URL": true,
"GRAPH_ENABLED": true,
"IS_ADMIN": true,
"NSQLOOKUPD": true,
"STATSD_COUNTER_FORMAT": true,
"STATSD_GAUGE_FORMAT": true,
"STATSD_INTERVAL": true,
"STATSD_PREFIX": true,
"USER_AGENT": true,
"VERSION": true,
"module": true,
"require": true
}
Expand Down
3 changes: 3 additions & 0 deletions nsqadmin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"type": "git",
"url": ""
},
"scripts": {
"lint": "eslint static/js"
},
"devDependencies": {
"browserify": "^17.0.0",
"gulp": "^4.0.2",
Expand Down
2 changes: 1 addition & 1 deletion nsqadmin/static/build/main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions nsqadmin/static/js/collections/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ var Backbone = require('backbone');

var AppState = require('../app_state');

var Node = require('../models/node'); //eslint-disable-line no-undef
var NodeModel = require('../models/node');

var Nodes = Backbone.Collection.extend({
model: Node,
model: NodeModel,

comparator: 'id',

Expand Down
9 changes: 6 additions & 3 deletions nsqadmin/static/js/lib/handlebars_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,24 @@ var genColorList = function(typ, key) {

// sanitizeGraphiteKey removes special characters from a graphite key
// this matches behavior of bitly/statsdaemon
// eslint-disable-next-line max-len
// https://github.com/bitly/statsdaemon/blob/fc46d9cfe29b674a0c8abc723afaa9370430cdcd/statsdaemon.go#L64-L88
var sanitizeGraphiteKey = function(s) {
return s.replaceAll(' ', '_').replaceAll('/', '-').replaceAll(/[^a-zA-Z0-9-_.]/g, '');
}
};

var genTargets = function(typ, node, ns1, ns2, key) {
var targets = [];
var prefix = statsdPrefix(node ? node : '*');
var fullKey;
var target;
if (typ === 'topic') {
fullKey = formatStatsdKey(metricType(key), prefix + 'topic.' + sanitizeGraphiteKey(ns1) + '.' + key);
fullKey = formatStatsdKey(metricType(key),
prefix + 'topic.' + sanitizeGraphiteKey(ns1) + '.' + key);
targets.push('sumSeries(' + fullKey + ')');
} else if (typ === 'channel') {
fullKey = formatStatsdKey(metricType(key), prefix + 'topic.' + sanitizeGraphiteKey(ns1) + '.channel.' +
fullKey = formatStatsdKey(metricType(key),
prefix + 'topic.' + sanitizeGraphiteKey(ns1) + '.channel.' +
sanitizeGraphiteKey(ns2) + '.' + key);
targets.push('sumSeries(' + fullKey + ')');
} else if (typ === 'node') {
Expand Down
4 changes: 2 additions & 2 deletions nsqadmin/static/js/models/node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var AppState = require('../app_state');
var Backbone = require('backbone');

var Node = Backbone.Model.extend({ //eslint-disable-line no-undef
var NodeModel = Backbone.Model.extend({
idAttribute: 'name',

constructor: function Node() {
Expand All @@ -20,4 +20,4 @@ var Node = Backbone.Model.extend({ //eslint-disable-line no-undef
}
});

module.exports = Node;
module.exports = NodeModel;
14 changes: 7 additions & 7 deletions nsqadmin/static/js/views/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var NodesView = require('./nodes');
var NodeView = require('./node');
var CounterView = require('./counter');

var Node = require('../models/node'); //eslint-disable-line no-undef
var Topic = require('../models/topic');
var Channel = require('../models/channel');
var NodeModel = require('../models/node');
var TopicModel = require('../models/topic');
var ChannelModel = require('../models/channel');

var AppView = BaseView.extend({
// not a fan of setting a view's el to an existing element on the page
Expand Down Expand Up @@ -96,14 +96,14 @@ var AppView = BaseView.extend({

showTopic: function(topic) {
this.showView(function() {
var model = new Topic({'name': topic, 'isAdmin': AppState.get('IS_ADMIN')});
var model = new TopicModel({'name': topic, 'isAdmin': AppState.get('IS_ADMIN')});
return new TopicView({'model': model});
});
},

showChannel: function(topic, channel) {
this.showView(function() {
var model = new Channel({
var model = new ChannelModel({
'topic': topic,
'name': channel,
'isAdmin': AppState.get('IS_ADMIN')
Expand All @@ -126,7 +126,7 @@ var AppView = BaseView.extend({

showNode: function(node) {
this.showView(function() {
var model = new Node({'name': node});
var model = new NodeModel({'name': node});
return new NodeView({'model': model});
});
},
Expand Down Expand Up @@ -157,7 +157,7 @@ var AppView = BaseView.extend({
if (result !== true) {
return;
}
var node = new Node({
var node = new NodeModel({
'name': nodeName
});
node.tombstoneTopic(topicName)
Expand Down
2 changes: 1 addition & 1 deletion nsqadmin/static/js/views/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ var CounterView = BaseView.extend({
},

displayFrame: function() {
this.currentNum = Math.min(this.currentNum + this.delta, this.lastNum)
this.currentNum = Math.min(this.currentNum + this.delta, this.lastNum);
this.writeCounts(this.currentNum);
if (this.currentNum < this.lastNum) {
this.animator = setTimeout(this.displayFrame.bind(this), 1000 / 60);
Expand Down
Loading