Skip to content

Commit 4f74e4d

Browse files
jdforrestermvolz
andauthored
Require >= node12, update to 4.0.0
* CI: Drop Node 10 testing, add 14 and 16 * build: Upgrade eslint-config-wikimedia to 0.21.0 Auto-fix existence checks via `.indexOf()` into `.includes()`. * Bump yargs dependency to 17.3.1 and mocha dev-dependency to 9.1.4 This avoids npm audit alerts around security issues. * Require >= node12, update to 4.0.0 *Update packages *Require >= node 12 *Update to 4.0.0. Co-authored-by: Marielle Volz <marielle.volz@gmail.com>
1 parent 19c4087 commit 4f74e4d

File tree

8 files changed

+1991
-2728
lines changed

8 files changed

+1991
-2728
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [10.x, 12.x]
12+
node-version: [12.x, 14.x, 16.x]
1313

1414
steps:
1515
- uses: actions/checkout@v2

lib/base_service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ class BaseService {
234234
.argv;
235235

236236
args.deployRepo = args.deployRepo || args.review;
237-
args.build = args._.indexOf('build') !== -1 || args.deployRepo;
238-
args.dockerStart = args._.indexOf('docker-start') !== -1;
239-
args.dockerTest = args._.indexOf('docker-test') !== -1;
240-
args.generate = args._.indexOf('generate') !== -1;
237+
args.build = args._.includes('build') || args.deployRepo;
238+
args.dockerStart = args._.includes('docker-start');
239+
args.dockerTest = args._.includes('docker-test');
240+
args.generate = args._.includes('generate');
241241
args.deployRepo = args.deployRepo || args.build || args.building;
242242

243243
if ([args.build, args.dockerStart, args.dockerTest, args.generate]

lib/logger.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ const streamConverter = {
3939
if (stream.uris) {
4040
const hosts = stream.uris.split(',');
4141
const selectedURI = hosts[Math.floor(Math.random() * hosts.length)];
42-
const selectedHost = selectedURI.substr(0, selectedURI.indexOf(':'));
43-
const selectedPort = parseInt(selectedHost.substr(selectedHost.indexOf(':') + 1), 10);
42+
const selectedHost = selectedURI.slice(0, Math.max(0, selectedURI.indexOf(':')));
43+
const selectedPort = parseInt(selectedHost.slice(selectedHost.indexOf(':') + 1), 10);
4444

4545
if (selectedHost && !Number.isNaN(selectedPort)) {
4646
host = selectedHost;
@@ -181,7 +181,7 @@ class Logger {
181181
conf.streams.forEach((stream) => {
182182
let idx;
183183
let convertedStream = stream;
184-
if (streamConverterList.indexOf(stream.type) > -1) {
184+
if (streamConverterList.includes(stream.type)) {
185185
convertedStream = streamConverter[stream.type](stream, conf);
186186
}
187187
idx = streams.push(convertedStream);

lib/metrics/metric.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Metric {
2020
increment(amount, labels) {
2121
labels = labels || [];
2222
amount = amount || 1;
23-
if ([types.COUNTER, types.GAUGE].indexOf(this.type) !== -1) {
23+
if ([types.COUNTER, types.GAUGE].includes(this.type)) {
2424
this.metrics.map((metric) => metric.increment(amount, labels));
2525
} else {
2626
this.logger.log('error/metrics', `increment() unsupported for metric type ${this.type}`);
@@ -39,7 +39,7 @@ class Metric {
3939

4040
observe(value, labels) {
4141
labels = labels || [];
42-
if ([types.HISTOGRAM, types.SUMMARY].indexOf(this.type) !== -1) {
42+
if ([types.HISTOGRAM, types.SUMMARY].includes(this.type)) {
4343
this.metrics.map((metric) => metric.observe(value, labels));
4444
} else {
4545
this.logger.log('error/metrics', `observe() unsupported for metric type ${this.type}`);

lib/metrics/prometheus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PrometheusMetric {
5555
const updatedLabelValues = [...labelValues];
5656
// Add staticLabel values to updatedLabelValues if they aren't already listed.
5757
Object.keys(this.staticLabels).forEach((labelName) => {
58-
if (updatedLabelValues.indexOf(this.staticLabels[labelName]) === -1) {
58+
if (!updatedLabelValues.includes(this.staticLabels[labelName])) {
5959
updatedLabelValues.unshift(this.staticLabels[labelName]);
6060
}
6161
});

0 commit comments

Comments
 (0)