refactor: Add lint rule no-unused-param-in-catch-clause (#5868)

👕 Add lint rule `no-unused-param-in-catch-clause`
This commit is contained in:
Iván Ovejero 2023-03-31 16:44:08 +02:00 committed by GitHub
parent 18d2e7cd57
commit 62751b5a0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 3 deletions

View file

@ -343,6 +343,8 @@ const config = (module.exports = {
'n8n-local-rules/no-interpolation-in-regular-string': 'error',
'n8n-local-rules/no-unused-param-in-catch-clause': 'error',
// ******************************************************************
// overrides to base ruleset
// ******************************************************************

View file

@ -140,6 +140,36 @@ module.exports = {
},
},
'no-unused-param-in-catch-clause': {
meta: {
type: 'problem',
docs: {
description: 'Unused param in catch clause must be omitted.',
recommended: 'error',
},
messages: {
removeUnusedParam: 'Remove unused param in catch clause',
},
fixable: 'code',
},
create(context) {
return {
CatchClause(node) {
if (node.param?.name.startsWith('_')) {
const start = node.range[0] + 'catch '.length;
const end = node.param.range[1] + '()'.length;
context.report({
messageId: 'removeUnusedParam',
node,
fix: (fixer) => fixer.removeRange([start, end]),
});
}
},
};
},
},
'no-interpolation-in-regular-string': {
meta: {
type: 'problem',

View file

@ -216,7 +216,7 @@ export function removePackageFromMissingList(packageName: string): void {
);
config.set('nodes.packagesMissing', packageFailedToLoad.join(' '));
} catch (_error) {
} catch {
// Do nothing
}
}

View file

@ -72,7 +72,7 @@ export async function getRepositories(
{},
{ q, page, per_page },
);
} catch (_error) {
} catch {
// will fail if the owner does not have any repositories
}

View file

@ -185,7 +185,7 @@ function isUrl(value: string) {
let url: URL;
try {
url = new URL(value);
} catch (_error) {
} catch {
return false;
}