Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/eslint-plugin/src/rules/no-unused-vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default createRule<Options, MessageIds>({
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
caughtErrors: 'none',
caughtErrors: 'all',
};

if (typeof firstOption === 'string') {
Expand Down Expand Up @@ -245,9 +245,7 @@ export default createRule<Options, MessageIds>({
) {
continue;
}
}

if (def.type === TSESLint.Scope.DefinitionType.Parameter) {
} else if (def.type === TSESLint.Scope.DefinitionType.Parameter) {
// if "args" option is "none", skip any parameter
if (options.args === 'none') {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,13 @@ foo();
doSomething();
})();
`,
`
{
code: `
try {
} catch (e) {}
`,
`,
options: [{ caughtErrors: 'none' }],
},
'/*global a */ a;',
{
code: `
Expand Down Expand Up @@ -925,7 +928,7 @@ try {
try {
} catch (err) {}
`,
options: [{ vars: 'all', args: 'all' }],
options: [{ vars: 'all', args: 'all', caughtErrors: 'none' }],
},

// Using object rest for variable omission
Expand Down Expand Up @@ -2235,6 +2238,22 @@ try {
definedError('err', '. Allowed unused args must match /^ignore/u'),
],
},
{
code: `
try {
} catch (err) {}
`,
options: [{ caughtErrors: 'all', varsIgnorePattern: '^err' }],
errors: [definedError('err', '. Allowed unused vars must match /^err/u')],
},
{
code: `
try {
} catch (err) {}
`,
options: [{ caughtErrors: 'all', varsIgnorePattern: '^.' }],
errors: [definedError('err', '. Allowed unused vars must match /^./u')],
},

// multiple try catch with one success
{
Expand Down