@@ -95,25 +95,45 @@ ruleTester.run('catch-error-name', rule, {
9595		testCase ( 'obj.catch(function (error) {})' ,  'error' ) , 
9696		testCase ( 'obj.catch(function (outerError) { return obj2.catch(function (innerError) {}) })' ) , 
9797		testCase ( 'obj.catch()' ) , 
98+ 		testCase ( 'obj.catch(_ => { console.log(_); })' ) , 
99+ 		testCase ( 'obj.catch(function (_) { console.log(_); })' ) , 
98100		testCase ( 'foo(function (err) {})' ) , 
99101		testCase ( 'foo().then(function (err) {})' ) , 
100- 		testCase ( 'foo().catch(function (err) {})' ) 
102+ 		testCase ( 'foo().catch(function (err) {})' ) , 
103+ 		testCase ( 'try {} catch (_) {}' ) , 
104+ 		testCase ( 'try {} catch (_) { try {} catch (_) {} }' ) , 
105+ 		testCase ( 'try {} catch (_) { console.log(_); }' ) , 
106+ 		testCase ( ` 
107+ 				const handleError = error => { 
108+ 					try { 
109+ 						doSomething(); 
110+ 					} catch (_) { 
111+ 						console.log(_); 
112+ 					} 
113+ 				} 
114+ 		` ) , 
115+ 		testCase ( 'obj.catch(_ => {})' ) , 
116+ 		{ 
117+ 			code : 'try {} catch (skipErr) {}' , 
118+ 			options : [ 
119+ 				{ 
120+ 					caughtErrorsIgnorePattern : '^skip' 
121+ 				} 
122+ 			] 
123+ 		} 
101124	] , 
102125	invalid : [ 
103126		testCase ( 'try {} catch (error) {}' ,  null ,  true ) , 
104127		testCase ( 'try {} catch (err) {}' ,  'error' ,  true ) , 
105128		testCase ( 'try {} catch ({message}) {}' ,  null ,  true ) , 
106- 		testCase ( 'try {} catch (_) { console.log(_); }' ,  null ,  true ) , 
107129		testCase ( 'try {} catch (outerError) {}' ,  null ,  true ) , 
108130		testCase ( 'try {} catch (innerError) {}' ,  null ,  true ) , 
109131		testCase ( 'obj.catch(error => {})' ,  null ,  true ) , 
110132		testCase ( 'obj.catch(err => {})' ,  'error' ,  true ) , 
111133		testCase ( 'obj.catch(({message}) => {})' ,  null ,  true ) , 
112- 		testCase ( 'obj.catch(_ => { console.log(_); })' ,  null ,  true ) , 
113134		testCase ( 'obj.catch(function (error) {})' ,  null ,  true ) , 
114135		testCase ( 'obj.catch(function ({message}) {})' ,  null ,  true ) , 
115136		testCase ( 'obj.catch(function (err) {})' ,  'error' ,  true ) , 
116- 		testCase ( 'obj.catch(function (_) { console.log(_); })' ,  null ,  true ) , 
117137		// Failing tests for #107 
118138		// testCase(` 
119139		// 	foo.then(() => { 
@@ -205,6 +225,20 @@ ruleTester.run('catch-error-name', rule, {
205225				{ ruleId : 'catch-error-name' } , 
206226				{ ruleId : 'catch-error-name' } 
207227			] 
228+ 		} , 
229+ 		{ 
230+ 			code : 'try {} catch (_err) {}' , 
231+ 			errors : [ 
232+ 				{ 
233+ 					ruleId : 'catch-error-name' , 
234+ 					message : 'The catch parameter should be named `err`.' 
235+ 				} 
236+ 			] , 
237+ 			options : [ 
238+ 				{ 
239+ 					caughtErrorsIgnorePattern : '^skip' 
240+ 				} 
241+ 			] 
208242		} 
209243	] 
210244} ) ; 
0 commit comments