File tree Expand file tree Collapse file tree 2 files changed +10
-22
lines changed Expand file tree Collapse file tree 2 files changed +10
-22
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
+ const getScopes = require ( './utils/get-scopes.js' ) ;
2
3
3
4
const MESSAGE_ID = 'no-unused-properties' ;
4
5
const messages = {
@@ -211,25 +212,16 @@ const create = context => {
211
212
}
212
213
} ;
213
214
214
- const checkChildScopes = scope => {
215
- for ( const childScope of scope . childScopes ) {
216
- checkScope ( childScope ) ;
217
- }
218
- } ;
219
-
220
- const checkScope = scope => {
221
- if ( scope . type === 'global' ) {
222
- return checkChildScopes ( scope ) ;
223
- }
224
-
225
- checkVariables ( scope ) ;
226
-
227
- return checkChildScopes ( scope ) ;
228
- } ;
229
-
230
215
return {
231
216
'Program:exit' ( ) {
232
- checkScope ( context . getScope ( ) ) ;
217
+ const scopes = getScopes ( context . getScope ( ) ) ;
218
+ for ( const scope of scopes ) {
219
+ if ( scope . type === 'global' ) {
220
+ continue ;
221
+ }
222
+
223
+ checkVariables ( scope ) ;
224
+ }
233
225
} ,
234
226
} ;
235
227
} ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ const getIndentString = require('./utils/get-indent-string.js');
7
7
const { getParenthesizedText} = require ( './utils/parentheses.js' ) ;
8
8
const shouldAddParenthesesToConditionalExpressionChild = require ( './utils/should-add-parentheses-to-conditional-expression-child.js' ) ;
9
9
const { extendFixRange} = require ( './fix/index.js' ) ;
10
+ const getScopes = require ( './utils/get-scopes.js' ) ;
10
11
11
12
const messageId = 'prefer-ternary' ;
12
13
@@ -40,11 +41,6 @@ function getNodeBody(node) {
40
41
return node ;
41
42
}
42
43
43
- const getScopes = scope => [
44
- scope ,
45
- ...scope . childScopes . flatMap ( scope => getScopes ( scope ) ) ,
46
- ] ;
47
-
48
44
const isSingleLineNode = node => node . loc . start . line === node . loc . end . line ;
49
45
50
46
const create = context => {
You can’t perform that action at this time.
0 commit comments