File tree Expand file tree Collapse file tree
packages/analysis/src/jsts/rules/S2486 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,17 @@ function switchBody() {
108108 }
109109}
110110
111+ function blockBody ( ) {
112+ try {
113+ {
114+ doSomething ( ) ;
115+ doSomethingElse ( ) ;
116+ }
117+ } catch ( err ) { // Noncompliant {{Handle this exception or don't catch it at all.}}
118+
119+ }
120+ }
121+
111122function labeledLoopBody ( ) {
112123 try {
113124 outer: for ( const x of xs ) {
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ import { generateMeta } from '../helpers/generate-meta.js';
2323import { getVariableFromScope } from '../helpers/ast.js' ;
2424import * as meta from './generated-meta.js' ;
2525
26- const LOOP_OR_SWITCH_TYPES = new Set ( [
26+ const NON_SIMPLE_STATEMENT_TYPES = new Set ( [
27+ 'BlockStatement' ,
2728 'ForStatement' ,
2829 'ForInStatement' ,
2930 'ForOfStatement' ,
@@ -40,7 +41,7 @@ function isSingleSimpleStatement(body: estree.Statement[]): boolean {
4041 while ( stmt . type === 'LabeledStatement' ) {
4142 stmt = ( stmt as estree . LabeledStatement ) . body ;
4243 }
43- return ! LOOP_OR_SWITCH_TYPES . has ( stmt . type ) ;
44+ return ! NON_SIMPLE_STATEMENT_TYPES . has ( stmt . type ) ;
4445}
4546
4647export const rule : Rule . RuleModule = {
You can’t perform that action at this time.
0 commit comments