Skip to content

Commit

Permalink
bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Dec 27, 2024
1 parent 735b6a8 commit 2966bca
Show file tree
Hide file tree
Showing 69 changed files with 1,643 additions and 1,903 deletions.
33 changes: 33 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import mocha from "eslint-plugin-mocha";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends("scality"), {
plugins: {
mocha,
},

languageOptions: {
ecmaVersion: 2020,
sourceType: "script",
},

rules: {
"import/extensions": "off",
"lines-around-directive": "off",
"no-underscore-dangle": "off",
"quote-props": "off",
"mocha/no-exclusive-tests": "error",
"no-param-reassign": "off",
},
}];
1 change: 0 additions & 1 deletion examples/javascript-V4Auth-example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const http = require('http');
// eslint-disable-next-line import/no-extraneous-dependencies
const aws4 = require('aws4');

// Input AWS access key, secret key, and session token.
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable global-require */
// eslint-disable-line strict
let toExport;

if (process.env.ENABLE_UTAPI_V2) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-bitwise */
const assert = require('assert');
const fs = require('fs');
const path = require('path');
Expand Down
8 changes: 3 additions & 5 deletions lib/ListMetrics.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable prefer-spread */
/* eslint-disable prefer-destructuring */
/* eslint-disable class-methods-use-this */
/* eslint-disable no-mixed-operators */


const async = require('async');
const { errors } = require('arsenal');
const { getMetricFromKey, getKeys, generateStateKey } = require('./schema');
Expand Down Expand Up @@ -175,7 +173,7 @@ class ListMetrics {
const end = range[1] || Date.now();
const subRangesCount = Math.floor((end - start) / MAX_RANGE_MS) + 1;
const subRanges = [];
// eslint-disable-next-line no-plusplus
for (let i = 0; i < subRangesCount; i++) {
if (i + 1 === subRangesCount) {
subRanges.push([start, end]);
Expand Down
5 changes: 2 additions & 3 deletions lib/UtapiClient.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable class-methods-use-this */
/* eslint-disable no-mixed-operators */


const assert = require('assert');
const { doUntil, parallel } = require('async');
const werelogs = require('werelogs');
Expand Down
2 changes: 1 addition & 1 deletion lib/UtapiReplay.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-plusplus */
const assert = require('assert');
const async = require('async');
const { scheduleJob } = require('node-schedule');
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/Memory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable class-methods-use-this */
const assert = require('assert');
const map = require('async/map');

Expand Down
6 changes: 3 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable class-methods-use-this */
const http = require('http');
const https = require('https');
const url = require('url');
Expand Down Expand Up @@ -49,15 +49,15 @@ class UtapiServer {
if (typeof component === 'string') {
try {
decodeURIComponent(component);
} catch (err) {
} catch {
return true;
}
} else {
return Object.keys(component).find(x => {
try {
decodeURIComponent(x);
decodeURIComponent(component[x]);
} catch (err) {
} catch {
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions libV2/cache/backend/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class MemoryCache {
this._expirations = {};
}

// eslint-disable-next-line class-methods-use-this
async connect() {
return true;
}

// eslint-disable-next-line class-methods-use-this
async disconnect() {
Object.values(this._expirations).forEach(clearTimeout);
return true;
Expand Down
6 changes: 2 additions & 4 deletions libV2/client/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const { callbackify } = require('util');
const { Transform } = require('stream');
const uuid = require('uuid');
const { v4: uuid } = require('uuid');
const needle = require('needle');

// These modules are added via the `level-mem` package rather than individually
/* eslint-disable import/no-extraneous-dependencies */
const levelup = require('levelup');
const memdown = require('memdown');
const encode = require('encoding-down');
/* eslint-enable import/no-extraneous-dependencies */

const { UtapiMetric } = require('../models');
const {
Expand Down Expand Up @@ -257,7 +255,7 @@ class UtapiClient {

// Assign a uuid if one isn't passed
if (!metric.uuid) {
metric.uuid = uuid.v4();
metric.uuid = uuid();
}

// Assign a timestamp if one isn't passed
Expand Down
3 changes: 1 addition & 2 deletions libV2/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ class Config {
new Set([
...Object.keys(parent),
...Object.keys(child)],
// eslint-disable-next-line function-paren-newline
))
.reduce((ret, key) => {
// eslint-disable-next-line no-param-reassign
ret[key] = this._recursiveUpdate(parent[key], child[key]);
return ret;
}, {});
Expand Down
1 change: 0 additions & 1 deletion libV2/errors/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
const utapiErrors = require('./errors.json');

class UtapiError extends Error {
Expand Down
4 changes: 2 additions & 2 deletions libV2/metadata/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-restricted-syntax */
const arsenal = require('arsenal');
const async = require('async');
const metadata = require('./client');
Expand Down Expand Up @@ -45,7 +45,7 @@ function _listObject(bucket, prefix, hydrateFunc) {
let res;

try {
// eslint-disable-next-line no-await-in-loop
res = await async.retryable(ebConfig, _listingWrapper)(bucket, { ...listingParams, gt });
} catch (error) {
moduleLogger.error('Error during listing', { error });
Expand Down
4 changes: 2 additions & 2 deletions libV2/models/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ function buildModel(name, schema) {
Object.keys(schema).forEach(key =>
Object.defineProperty(Model.prototype, key, {
// `function` is used rather than `=>` to work around context problem with `this`
/* eslint-disable func-names, object-shorthand */
/* eslint-disable object-shorthand */
get: function () {
return this._get(key);
},
set: function (value) {
this._set(key, value);
},
/* eslint-enable func-names, object-shorthand */
/* eslint-enable object-shorthand */
}));
return Model;
}
Expand Down
4 changes: 2 additions & 2 deletions libV2/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class Process extends EventEmitter {
await this._join();
}

/* eslint-disable class-methods-use-this,no-empty-function */
async _setup() {}

async _start() {}

async _join() {}
/* eslint-enable class-methods-use-this,no-empty-function */
}

module.exports = Process;
1 change: 0 additions & 1 deletion libV2/server/API/internal/healthcheck.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
async function healthcheck(ctx) {
// eslint-disable-next-line no-param-reassign
ctx.results.statusCode = 200;
}

Expand Down
2 changes: 1 addition & 1 deletion libV2/server/API/internal/prometheusMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ collectDefaultMetrics({
});

async function prometheusMetrics(ctx) {
// eslint-disable-next-line no-param-reassign
ctx.results.statusCode = 200;
ctx.results.body = await register.metrics();
}
Expand Down
6 changes: 3 additions & 3 deletions libV2/server/API/metrics/ingestMetric.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ async function ingestMetric(ctx, params) {
timestamp: convertTimestamp(m.timestamp),
operationId: ingestionOpTranslationMap[m.operationId] || m.operationId,
}));
} catch (error) {
} catch {
throw errors.InvalidRequest;
}
try {
await Promise.all(metrics.map(m => cacheClient.pushMetric(m)));
} catch (error) {
} catch {
throw errors.ServiceUnavailable;
}
// eslint-disable-next-line no-param-reassign
ctx.results.statusCode = 200;
}

Expand Down
2 changes: 0 additions & 2 deletions libV2/server/controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
const { apiOperations, apiOperationMiddleware } = require('./spec');
const { middleware: utapiMiddleware } = require('./middleware');
const RequestContext = require('../models/RequestContext');
Expand All @@ -23,7 +22,6 @@ class APIController {

static _safeRequire(path) {
try {
// eslint-disable-next-line import/no-dynamic-require, global-require
return require(path);
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
Expand Down
7 changes: 3 additions & 4 deletions libV2/server/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ async function initializeOasTools(spec, app) {
}

function loggerMiddleware(req, res, next) {
// eslint-disable-next-line no-param-reassign
req.logger = buildRequestLogger(req);
req.logger.info('Received request');
return next();
Expand Down Expand Up @@ -83,11 +82,11 @@ function errorMiddleware(err, req, res, next) {
// failed request validation by oas-tools
if (err.failedValidation) {
// You can't actually use destructing here
/* eslint-disable prefer-destructuring */
statusCode = errors.InvalidRequest.code;
code = errors.InvalidRequest.message;
message = errors.InvalidRequest.description;
/* eslint-enable prefer-destructuring */
}

if (!err.utapiError && !config.development) {
Expand All @@ -103,7 +102,7 @@ function errorMiddleware(err, req, res, next) {
responseLoggerMiddleware(req, res, () => httpMetricsMiddleware(req, res));
}

// eslint-disable-next-line no-unused-vars
async function authV4Middleware(request, response, params) {
const authHeader = request.headers.authorization;
if (!authHeader || !authHeader.startsWith('AWS4-')) {
Expand Down
2 changes: 1 addition & 1 deletion libV2/server/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function _getApiOperationIds(routes) {
.with({ method: '_getApiOperationIds' })
.trace('Registering handler', { tag, operationId: optId });
if (optIds[tag] === undefined) {
// eslint-disable-next-line no-param-reassign
optIds[tag] = new Set([optId]);
} else {
optIds[tag].add(optId);
Expand Down
4 changes: 2 additions & 2 deletions libV2/tasks/BaseTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class BaseTask extends Process {
};
}

// eslint-disable-next-line class-methods-use-this
_registerMetricHandlers() {
return {};
}
Expand Down Expand Up @@ -175,7 +175,7 @@ class BaseTask extends Process {
}
}

// eslint-disable-next-line class-methods-use-this
async _execute(timestamp) {
logger.info(`Default Task ${timestamp}`);
}
Expand Down
2 changes: 1 addition & 1 deletion libV2/tasks/CreateCheckpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CreateCheckpoint extends BaseTask {
this._defaultLag = checkpointLagSecs;
}

// eslint-disable-next-line class-methods-use-this
_registerMetricHandlers() {
const created = new promClient.Counter({
name: 's3_utapi_create_checkpoint_created_total',
Expand Down
2 changes: 1 addition & 1 deletion libV2/tasks/CreateSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CreateSnapshot extends BaseTask {
this._defaultLag = snapshotLagSecs;
}

// eslint-disable-next-line class-methods-use-this
_registerMetricHandlers() {
const created = new promClient.Counter({
name: 's3_utapi_create_snapshot_created_total',
Expand Down
4 changes: 2 additions & 2 deletions libV2/tasks/DiskUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MonitorDiskUsage extends BaseTask {
);
}

// eslint-disable-next-line class-methods-use-this
_registerMetricHandlers() {
const isLocked = new promClient.Gauge({
name: 's3_utapi_monitor_disk_usage_is_locked',
Expand Down Expand Up @@ -143,7 +143,7 @@ class MonitorDiskUsage extends BaseTask {
return this._program.lock !== undefined;
}

// eslint-disable-next-line class-methods-use-this
async _getUsage(path) {
moduleLogger.debug(`calculating disk usage for ${path}`);
if (!fs.existsSync(path)) {
Expand Down
4 changes: 2 additions & 2 deletions libV2/tasks/IngestShard.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class IngestShardTask extends BaseTask {
this._stripEventUUID = options.stripEventUUID !== undefined ? options.stripEventUUID : true;
}

// eslint-disable-next-line class-methods-use-this
_registerMetricHandlers() {
const ingestedTotal = new promClient.Counter({
name: 's3_utapi_ingest_shard_task_ingest_total',
Expand Down Expand Up @@ -151,7 +151,7 @@ class IngestShardTask extends BaseTask {

let ingestedIntoNodeId;
const status = await this.withWarp10(async warp10 => {
// eslint-disable-next-line prefer-destructuring
ingestedIntoNodeId = warp10.nodeId;
return warp10.ingest(
{
Expand Down
Loading

0 comments on commit 2966bca

Please sign in to comment.