File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { TSESTree as es } from '@typescript-eslint/utils' ;
2
- import { getTypeServices , isCallExpression , isUnaryExpression } from '../etc' ;
2
+ import { getTypeServices , isCallExpression } from '../etc' ;
3
3
import { ruleCreator } from '../utils' ;
4
4
5
5
const defaultOptions : readonly {
@@ -41,12 +41,8 @@ export const noFloatingObservablesRule = ruleCreator({
41
41
const [ config = { } ] = context . options ;
42
42
const { ignoreVoid = true } = config ;
43
43
44
- function checkNode ( node : es . Expression ) {
45
- if ( ! ignoreVoid && isUnaryExpression ( node ) && node . operator === 'void' ) {
46
- node = node . argument ;
47
- }
48
-
49
- if ( isCallExpression ( node ) && couldBeObservable ( node ) ) {
44
+ function checkNode ( node : es . CallExpression ) {
45
+ if ( couldBeObservable ( node ) ) {
50
46
context . report ( {
51
47
messageId : ignoreVoid ? 'forbidden' : 'forbiddenNoVoid' ,
52
48
node,
@@ -59,7 +55,11 @@ export const noFloatingObservablesRule = ruleCreator({
59
55
checkNode ( node ) ;
60
56
} ,
61
57
'ExpressionStatement > UnaryExpression' : ( node : es . UnaryExpression ) => {
62
- checkNode ( node ) ;
58
+ if ( ignoreVoid ) return ;
59
+ if ( node . operator !== 'void' ) return ;
60
+ if ( ! isCallExpression ( node . argument ) ) return ;
61
+
62
+ checkNode ( node . argument ) ;
63
63
} ,
64
64
} ;
65
65
} ,
You can’t perform that action at this time.
0 commit comments