File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,13 @@ function findParentCatch(node) {
138138module . exports = {
139139 meta : {
140140 type : "suggestion" ,
141+
142+ defaultOptions : [
143+ {
144+ requireCatchParameter : false ,
145+ } ,
146+ ] ,
147+
141148 docs : {
142149 description :
143150 "Disallow losing originally caught error when re-throwing custom errors" ,
@@ -158,7 +165,6 @@ module.exports = {
158165 properties : {
159166 requireCatchParameter : {
160167 type : "boolean" ,
161- default : false ,
162168 description :
163169 "Requires the catch blocks to always have the caught error parameter so it is not discarded." ,
164170 } ,
@@ -185,7 +191,7 @@ module.exports = {
185191
186192 create ( context ) {
187193 const sourceCode = context . sourceCode ;
188- const options = context . options [ 0 ] || { } ;
194+ const [ { requireCatchParameter } ] = context . options ;
189195
190196 //----------------------------------------------------------------------
191197 // Helpers
@@ -273,7 +279,7 @@ module.exports = {
273279
274280 // Check if there are throw statements and caught error is being ignored
275281 if ( ! caughtError ) {
276- if ( options . requireCatchParameter ) {
282+ if ( requireCatchParameter ) {
277283 context . report ( {
278284 node : throwStatement ,
279285 messageId : "missingCatchErrorParam" ,
Original file line number Diff line number Diff line change @@ -4812,6 +4812,9 @@ export interface ESLintRules extends Linter.RulesRecord {
48124812 "preserve-caught-error" : Linter . RuleEntry <
48134813 [
48144814 Partial < {
4815+ /**
4816+ * @default false
4817+ */
48154818 requireCatchParameter : boolean ;
48164819 } > ,
48174820 ]
You can’t perform that action at this time.
0 commit comments