mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
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:
parent
18d2e7cd57
commit
62751b5a0b
|
@ -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
|
||||
// ******************************************************************
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -216,7 +216,7 @@ export function removePackageFromMissingList(packageName: string): void {
|
|||
);
|
||||
|
||||
config.set('nodes.packagesMissing', packageFailedToLoad.join(' '));
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ function isUrl(value: string) {
|
|||
let url: URL;
|
||||
try {
|
||||
url = new URL(value);
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue