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
5 changed files with 35 additions and 3 deletions

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',