refactor: Add lint rules for no unused vars and unused import (#9940)

This commit is contained in:
Lucas Coratger
2025-11-22 22:12:34 +01:00
committed by GitHub
parent 9ed9af48d1
commit 69a925879e
32 changed files with 66 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
/**
* @interface AnalyticsAdapter
* @module Adapters

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
/**
* @interface ParseAuthResponse

View File

@@ -63,7 +63,7 @@ const getAppleKeyByKeyId = async (keyId, cacheMaxEntries, cacheMaxAge) => {
let key;
try {
key = await authUtils.getSigningKey(client, keyId);
} catch (error) {
} catch {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
`Unable to find matching key for Key ID: ${keyId}`

View File

@@ -122,7 +122,7 @@ const getFacebookKeyByKeyId = async (keyId, cacheMaxEntries, cacheMaxAge) => {
let key;
try {
key = await authUtils.getSigningKey(client, keyId);
} catch (error) {
} catch {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
`Unable to find matching key for Key ID: ${keyId}`

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
/**
* @interface
* @memberof module:Adapters

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
/**
* @interface
* @memberof module:Adapters

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
// Files Adapter
//
// Allows you to change the file storage mechanism.

View File

@@ -171,7 +171,7 @@ export class GridFSBucketAdapter extends FilesAdapter {
fileNamesNotRotated = fileNamesNotRotated.filter(function (value) {
return value !== fileName;
});
} catch (err) {
} catch {
continue;
}
}

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
/**
* @interface
* @memberof module:Adapters

View File

@@ -42,7 +42,7 @@ function configureTransports(options) {
parseServerError.name = 'parse-server-error';
transports.push(parseServerError);
}
} catch (e) {
} catch {
/* */
}
@@ -86,7 +86,7 @@ export function configureLogger({
}
try {
fs.mkdirSync(logsFolder);
} catch (e) {
} catch {
/* */
}
}

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
/**
* @interface
* @memberof module:Adapters

View File

@@ -1,5 +1,5 @@
/* eslint-disable unused-imports/no-unused-vars */
// @flow
/*eslint no-unused-vars: "off"*/
// Push Adapter
//
// Allows you to change the push notification mechanism.

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
import { WSSAdapter } from './WSSAdapter';
const WebSocketServer = require('ws').Server;

View File

@@ -1,4 +1,4 @@
/*eslint no-unused-vars: "off"*/
/* eslint-disable unused-imports/no-unused-vars */
// WebSocketServer Adapter
//
// Adapter classes must implement the following functions:

View File

@@ -225,7 +225,7 @@ function wrapToHTTPRequest(hook, key) {
if (typeof body === 'string') {
try {
body = JSON.parse(body);
} catch (e) {
} catch {
err = {
error: 'Malformed response',
code: -1,

View File

@@ -217,7 +217,7 @@ export function getDatabaseAdapter(databaseURI, collectionPrefix, databaseOption
try {
const parsedURI = new URL(databaseURI);
protocol = parsedURI.protocol ? parsedURI.protocol.toLowerCase() : null;
} catch (e) {
} catch {
/* */
}
switch (protocol) {

View File

@@ -38,7 +38,7 @@ const handleUpload = async (upload, config) => {
res.on('end', () => {
try {
resolve(JSON.parse(data));
} catch (e) {
} catch {
reject(new Parse.Error(Parse.error, data));
}
});

View File

@@ -55,7 +55,7 @@ function moduleOrObjectParser(opt) {
}
try {
return JSON.parse(opt);
} catch (e) {
} catch {
/* */
}
return opt;

View File

@@ -149,7 +149,7 @@ export class ClassesRouter extends PromiseRouter {
for (const [key, value] of _.entries(query)) {
try {
json[key] = JSON.parse(value);
} catch (e) {
} catch {
json[key] = value;
}
}

View File

@@ -310,7 +310,7 @@ export class FilesRouter {
const data = await filesController.getMetadata(filename);
res.status(200);
res.json(data);
} catch (e) {
} catch {
res.status(200);
res.json({});
}

View File

@@ -432,7 +432,7 @@ export class PagesRouter extends PromiseRouter {
let data;
try {
data = await this.readFile(path);
} catch (e) {
} catch {
return this.notFound();
}
@@ -474,7 +474,7 @@ export class PagesRouter extends PromiseRouter {
let data;
try {
data = await this.readFile(path);
} catch (e) {
} catch {
return this.notFound();
}
@@ -517,7 +517,7 @@ export class PagesRouter extends PromiseRouter {
try {
const json = require(path.resolve('./', this.pagesConfig.localizationJsonPath));
this.jsonParameters = json;
} catch (e) {
} catch {
throw errors.jsonFailedFileLoading;
}
}

View File

@@ -82,7 +82,7 @@ class Utils {
try {
await fs.access(path);
return true;
} catch (e) {
} catch {
return false;
}
}

View File

@@ -13,7 +13,7 @@ function mountOnto(router) {
function parseURL(urlString) {
try {
return new URL(urlString);
} catch (error) {
} catch {
return undefined;
}
}

View File

@@ -20,7 +20,7 @@ function logStartupOptions(options) {
if (typeof value === 'object') {
try {
value = JSON.stringify(value);
} catch (e) {
} catch {
if (value && value.constructor && value.constructor.name) {
value = value.constructor.name;
}

View File

@@ -79,7 +79,7 @@ export async function handleParseHeaders(req, res, next) {
if (Object.prototype.toString.call(context) !== '[object Object]') {
throw 'Context is not an object';
}
} catch (e) {
} catch {
return malformedContext(req, res);
}
}
@@ -126,7 +126,7 @@ export async function handleParseHeaders(req, res, next) {
// to provide x-parse-app-id in header and parse a binary file will fail
try {
req.body = JSON.parse(req.body);
} catch (e) {
} catch {
return invalidRequest(req, res);
}
fileViaJSON = true;
@@ -173,7 +173,7 @@ export async function handleParseHeaders(req, res, next) {
if (Object.prototype.toString.call(info.context) !== '[object Object]') {
throw 'Context is not an object';
}
} catch (e) {
} catch {
return malformedContext(req, res);
}
}

View File

@@ -8,7 +8,7 @@ try {
hash: _bcrypt.hash,
compare: _bcrypt.verify,
};
} catch (e) {
} catch {
/* */
}

View File

@@ -31,7 +31,7 @@ class HTTPResponse {
if (!_data) {
try {
_data = JSON.parse(getText());
} catch (e) {
} catch {
/* */
}
}