Skip to content

Commit

Permalink
Content Node: add no-unused-vars eslint rule (#4061)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaylor89 committed Oct 24, 2022
1 parent d35dde4 commit 28811d9
Show file tree
Hide file tree
Showing 33 changed files with 74 additions and 66 deletions.
14 changes: 12 additions & 2 deletions creator-node/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ module.exports = {
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unused-vars': 'off', // We should turn this one on soon

// Note: you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
'argsIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_'
}
],

'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-extraneous-class': 'warn',
Expand All @@ -74,7 +85,6 @@ module.exports = {

'no-use-before-define': 'off',
camelcase: 'off',
'no-unused-vars': 'warn',
'func-call-spacing': 'off',
semi: ['error', 'never'],
'no-undef': 'error',
Expand Down
2 changes: 2 additions & 0 deletions creator-node/src/TranscodingQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class TranscodingQueue {
})
this.logStatus('Initialized TranscodingQueue')

// disabling because `new Worker()` has side effects
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const worker = new Worker(
'transcoding-queue',
async (job) => {
Expand Down
5 changes: 2 additions & 3 deletions creator-node/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Request, Response, NextFunction, IRoute } from 'express'
import type Logger from 'bunyan'
import type { Response, NextFunction, IRoute } from 'express'

import express from 'express'
import bodyParser from 'body-parser'
Expand Down Expand Up @@ -32,7 +31,7 @@ function errorHandler(
err: any,
req: RequestWithLogger,
res: Response,
next: NextFunction
_next: NextFunction
) {
req.logger.error('Internal server error')
req.logger.error(err.stack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const getTracksController = async (req) => {
return successResponse({ values: trackIds })
}

const contentBlacklistGetAllController = async (req) => {
const contentBlacklistGetAllController = async (_req) => {
const blacklistedContent = await getAllContentBlacklist()
return successResponse(blacklistedContent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const syncHealthCheckController = async (req) => {
* Controller for health_check/duration route
* Calls healthCheckComponentService
*/
const healthCheckDurationController = async (req) => {
const healthCheckDurationController = async (_req) => {
const response = await healthCheckDuration()
return successResponse(response)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const respondToURSMRequestForProposalController = async (req) => {
}
}

const getSyncStatusController = async (req, res) => {
const getSyncStatusController = async (req, _res) => {
try {
const syncStatus = await getSyncStatus(req.params.syncUuid)
return successResponse({ syncStatus })
Expand All @@ -82,7 +82,7 @@ const getSyncStatusController = async (req, res) => {
*
* @notice Returns success regardless of sync outcome -> primary node will re-request sync if needed
*/
const _syncRouteController = async (req, res) => {
const _syncRouteController = async (req, _res) => {
const serviceRegistry = req.app.get('serviceRegistry')
if (
_.isEmpty(serviceRegistry?.syncQueue) ||
Expand Down Expand Up @@ -206,7 +206,7 @@ const syncRouteController = instrumentTracing({
* Adds a job to manualSyncQueue to issue a sync to secondary with syncMode MergePrimaryAndSecondary
* @notice This will only work if called on a primary for a user
*/
const mergePrimaryAndSecondaryController = async (req, res) => {
const mergePrimaryAndSecondaryController = async (req, _res) => {
const serviceRegistry = req.app.get('serviceRegistry')
const { recurringSyncQueue, nodeConfig: config } = serviceRegistry

Expand Down Expand Up @@ -251,7 +251,7 @@ const mergePrimaryAndSecondaryController = async (req, res) => {
/**
* Changes a user's replica set. Gated by`devMode` env var to only work locally.
*/
const manuallyUpdateReplicaSetController = async (req, res) => {
const manuallyUpdateReplicaSetController = async (req, _res) => {
const audiusLibs = req.app.get('audiusLibs')
const serviceRegistry = req.app.get('serviceRegistry')
const { nodeConfig: config } = serviceRegistry
Expand Down
2 changes: 1 addition & 1 deletion creator-node/src/ffprobe-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function getSegmentsDuration(req, segmentPath) {
const cmd = `find ${segmentPath}/ -maxdepth 1 -iname '*.ts' -print -exec ${ffprobeStatic.path} -v quiet -of csv=p=0 -show_entries format=duration {} \\;`

return new Promise((resolve, reject) => {
exec(cmd, (err, stdout, stderr) => {
exec(cmd, (err, stdout, _stderr) => {
if (err) {
req.logger.error(err)
reject(new Error(err))
Expand Down
1 change: 0 additions & 1 deletion creator-node/src/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ async function copyMultihashToFs(multihash, srcPath, logContext) {
* @param {Object} param.logger
*/
async function fetchFileFromNetworkAndWriteToDisk({
libs,
gatewayContentRoutes,
targetGateways,
multihash,
Expand Down
4 changes: 2 additions & 2 deletions creator-node/src/monitors/MonitoringQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class MonitoringQueue {
this.seedInitialValues()
}
if (clusterUtils.isThisWorkerSpecial()) {
const worker = new Worker(
const _worker = new Worker(
'monitoring-queue',
async (job) => {
async (_job) => {
try {
await this.logStatus('Starting')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CheckAccessArgs, CheckAccessResponse } from './types'

export class StubPremiumContentAccessChecker {
accessCheckReturnsWith: CheckAccessResponse = {} as CheckAccessResponse
checkPremiumContentAccess(args: CheckAccessArgs) {
checkPremiumContentAccess(_args: CheckAccessArgs) {
return Promise.resolve(this.accessCheckReturnsWith)
}
}
2 changes: 1 addition & 1 deletion creator-node/src/reqLimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const batchCidsExistReqLimiter = rateLimit({
}
})

const onLimitReached = (req, res, options) => {
const onLimitReached = (req, _res, _options) => {
req.logger.warn(req.rateLimit, `Rate Limit Hit`)
}

Expand Down
4 changes: 2 additions & 2 deletions creator-node/src/routes/audiusUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ router.post(
authMiddleware,
ensurePrimaryMiddleware,
ensureStorageMiddleware,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const metadataJSON = req.body.metadata
const metadataBuffer = Buffer.from(JSON.stringify(metadataJSON))
const cnodeUserUUID = req.session.cnodeUserUUID
Expand Down Expand Up @@ -95,7 +95,7 @@ router.post(
authMiddleware,
ensurePrimaryMiddleware,
ensureStorageMiddleware,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const { blockchainUserId, blockNumber, metadataFileUUID } = req.body

if (!blockchainUserId || !blockNumber || !metadataFileUUID) {
Expand Down
2 changes: 1 addition & 1 deletion creator-node/src/routes/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const router = express.Router()

router.get(
'/contact',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const trustedNotifierManager = req.app.get('trustedNotifierManager')
const email =
trustedNotifierManager.getTrustedNotifierData().email ||
Expand Down
10 changes: 4 additions & 6 deletions creator-node/src/routes/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ const getCID = async (req, res) => {
const blockStartMs = Date.now()
try {
startMs = Date.now()
const libs = req.app.get('audiusLibs')
const found = await findCIDInNetwork(storagePath, CID, req.logger, trackId)
if (!found) {
throw new Error('Not found in network')
Expand Down Expand Up @@ -545,7 +544,6 @@ const getDirCID = async (req, res) => {
try {
// CID is the file CID, parse it from the storagePath
const CID = storagePath.split('/').slice(-1).join('')
const libs = req.app.get('audiusLibs')
const found = await findCIDInNetwork(storagePath, CID, req.logger)
if (!found) throw new Error(`CID=${CID} not found in network`)

Expand Down Expand Up @@ -612,7 +610,7 @@ async function _generateContentToHash(resizeResp, dirCID) {

router.get(
'/async_processing_status',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const AsyncProcessingQueue =
req.app.get('serviceRegistry').asyncProcessingQueue

Expand All @@ -634,7 +632,7 @@ router.post(
ensurePrimaryMiddleware,
ensureStorageMiddleware,
uploadTempDiskStorage.single('file'),
handleResponseWithHeartbeat(async (req, res) => {
handleResponseWithHeartbeat(async (req, _res) => {
if (
!req.body.square ||
!(req.body.square === 'true' || req.body.square === 'false')
Expand Down Expand Up @@ -779,7 +777,7 @@ router.get(['/ipfs/:dirCID/:filename', '/content/:dirCID/:filename'], getDirCID)
*/
router.post(
'/batch_cids_exist',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const { cids } = req.body

if (cids && cids.length > BATCH_CID_ROUTE_LIMIT) {
Expand Down Expand Up @@ -837,7 +835,7 @@ router.post(
*/
router.post(
'/batch_image_cids_exist',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const { cids } = req.body

if (cids && cids.length > BATCH_CID_ROUTE_LIMIT) {
Expand Down
8 changes: 4 additions & 4 deletions creator-node/src/routes/healthCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const router = express.Router()
*/
router.get(
'/db_check',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const verbose = req.query.verbose === 'true'
const maxConnections =
parseInt(req.query.maxConnections) || MAX_DB_CONNECTIONS
Expand Down Expand Up @@ -68,7 +68,7 @@ router.get(

router.get(
'/version',
handleResponse(async (req, res) => {
handleResponse(async (_req, _res) => {
if (config.get('isReadOnlyMode')) {
return errorResponseServerError()
}
Expand All @@ -89,7 +89,7 @@ router.get(
*/
router.get(
'/disk_check',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const maxUsageBytes = parseInt(req.query.maxUsageBytes)
const maxUsagePercent =
parseInt(req.query.maxUsagePercent) || config.get('maxStorageUsedPercent')
Expand Down Expand Up @@ -136,7 +136,7 @@ router.get(

router.get(
'/ip_check',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const { ip } = req

return successResponse({
Expand Down
4 changes: 2 additions & 2 deletions creator-node/src/routes/nodeSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { instrumentTracing, tracing } = require('../tracer')

const router = express.Router()

const handleExport = async (req, res) => {
const handleExport = async (req, _res) => {
const start = Date.now()

const walletPublicKeys = req.query.wallet_public_key // array
Expand Down Expand Up @@ -93,7 +93,7 @@ router.get(
/** Checks if node sync is in progress for wallet. */
router.get(
'/sync_status/:walletPublicKey',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const walletPublicKey = req.params.walletPublicKey

const redisClient = req.app.get('redisClient')
Expand Down
4 changes: 2 additions & 2 deletions creator-node/src/routes/playlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ router.post(
authMiddleware,
ensurePrimaryMiddleware,
ensureStorageMiddleware,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const metadataJSON = req.body.metadata
const metadataBuffer = Buffer.from(JSON.stringify(metadataJSON))
const cnodeUserUUID = req.session.cnodeUserUUID
Expand Down Expand Up @@ -96,7 +96,7 @@ router.post(
authMiddleware,
ensurePrimaryMiddleware,
ensureStorageMiddleware,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const { blockchainId, blockNumber, metadataFileUUID } = req.body

if (!blockchainId || !blockNumber || !metadataFileUUID) {
Expand Down
12 changes: 6 additions & 6 deletions creator-node/src/routes/tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ router.post(
ensurePrimaryMiddleware,
ensureStorageMiddleware,
handleTrackContentUpload,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
tracing.setSpanAttribute('requestID', req.logContext.requestID)
if (req.fileSizeError || req.fileFilterError) {
removeTrackFolder({ logContext: req.logContext }, req.fileDir)
Expand Down Expand Up @@ -104,7 +104,7 @@ router.post(
router.post(
'/clear_transcode_and_segment_artifacts',
ensureValidSPMiddleware,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const fileDir = req.body.fileDir
req.logger.info('Clearing filesystem fileDir', fileDir)
if (!fileDir.includes('tmp_track_artifacts')) {
Expand All @@ -130,7 +130,7 @@ router.post(
ensureValidSPMiddleware,
ensureStorageMiddleware,
handleTrackContentUpload,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const AsyncProcessingQueue =
req.app.get('serviceRegistry').asyncProcessingQueue

Expand Down Expand Up @@ -205,7 +205,7 @@ router.post(
authMiddleware,
ensurePrimaryMiddleware,
ensureStorageMiddleware,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const metadataJSON = req.body.metadata

if (
Expand Down Expand Up @@ -400,7 +400,7 @@ router.post(
authMiddleware,
ensurePrimaryMiddleware,
ensureStorageMiddleware,
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const {
blockchainTrackId,
blockNumber,
Expand Down Expand Up @@ -675,7 +675,7 @@ router.post(
/** Returns download status of track and 320kbps CID if ready + downloadable. */
router.get(
'/tracks/download_status/:blockchainId',
handleResponse(async (req, res) => {
handleResponse(async (req, _res) => {
const blockchainId = req.params.blockchainId
if (!blockchainId) {
return errorResponseBadRequest('Please provide blockchainId.')
Expand Down

0 comments on commit 28811d9

Please sign in to comment.