3
3
const util = require ( 'util' ) ;
4
4
const lodash = require ( 'lodash' ) ;
5
5
const espree = require ( 'espree' ) ;
6
- const escope = require ( 'escope ' ) ;
6
+ const eslintScope = require ( 'eslint-scope ' ) ;
7
7
const estraverse = require ( 'estraverse' ) ;
8
8
const assert = require ( 'chai' ) . assert ;
9
9
const utils = require ( '../../lib/utils' ) ;
@@ -27,7 +27,7 @@ describe('utils', () => {
27
27
'module.exports = { create: async function foo() {} }' ,
28
28
] . forEach ( noRuleCase => {
29
29
it ( `returns null for ${ noRuleCase } ` , ( ) => {
30
- const ast = espree . parse ( noRuleCase , { ecmaVersion : 8 } ) ;
30
+ const ast = espree . parse ( noRuleCase , { ecmaVersion : 8 , range : true } ) ;
31
31
assert . isNull ( utils . getRuleInfo ( ast ) , 'Expected no rule to be found' ) ;
32
32
} ) ;
33
33
} ) ;
@@ -114,7 +114,7 @@ describe('utils', () => {
114
114
115
115
Object . keys ( CASES ) . forEach ( ruleSource => {
116
116
it ( ruleSource , ( ) => {
117
- const ast = espree . parse ( ruleSource , { ecmaVersion : 6 } ) ;
117
+ const ast = espree . parse ( ruleSource , { ecmaVersion : 6 , range : true } ) ;
118
118
const ruleInfo = utils . getRuleInfo ( ast ) ;
119
119
assert (
120
120
lodash . isMatch ( ruleInfo , CASES [ ruleSource ] ) ,
@@ -148,8 +148,8 @@ describe('utils', () => {
148
148
149
149
Object . keys ( CASES ) . forEach ( ruleSource => {
150
150
it ( ruleSource , ( ) => {
151
- const ast = espree . parse ( ruleSource , { ecmaVersion : 6 } ) ;
152
- const scope = escope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
151
+ const ast = espree . parse ( ruleSource , { ecmaVersion : 6 , range : true } ) ;
152
+ const scope = eslintScope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
153
153
const identifiers = utils . getContextIdentifiers ( scope , ast ) ;
154
154
155
155
assert ( identifiers instanceof Set , 'getContextIdentifiers should return a Set' ) ;
@@ -178,7 +178,7 @@ describe('utils', () => {
178
178
} ;
179
179
Object . keys ( CASES ) . forEach ( objectSource => {
180
180
it ( objectSource , ( ) => {
181
- const ast = espree . parse ( objectSource , { ecmaVersion : 6 } ) ;
181
+ const ast = espree . parse ( objectSource , { ecmaVersion : 6 , range : true } ) ;
182
182
183
183
assert . strictEqual ( utils . getKeyName ( ast . body [ 0 ] . expression . properties [ 0 ] ) , CASES [ objectSource ] ) ;
184
184
} ) ;
@@ -189,7 +189,7 @@ describe('utils', () => {
189
189
} ;
190
190
Object . keys ( CASES_ES9 ) . forEach ( objectSource => {
191
191
it ( objectSource , ( ) => {
192
- const ast = espree . parse ( objectSource , { ecmaVersion : 9 } ) ;
192
+ const ast = espree . parse ( objectSource , { ecmaVersion : 9 , range : true } ) ;
193
193
194
194
assert . strictEqual ( utils . getKeyName ( ast . body [ 0 ] . expression . properties [ 0 ] ) , CASES_ES9 [ objectSource ] ) ;
195
195
} ) ;
@@ -211,8 +211,8 @@ describe('utils', () => {
211
211
'new RuleTester().run(foo, bar, notAnObject)' ,
212
212
] . forEach ( noTestsCase => {
213
213
it ( `returns no tests for ${ noTestsCase } ` , ( ) => {
214
- const ast = espree . parse ( noTestsCase , { ecmaVersion : 8 } ) ;
215
- const scope = escope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
214
+ const ast = espree . parse ( noTestsCase , { ecmaVersion : 8 , range : true } ) ;
215
+ const scope = eslintScope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
216
216
assert . deepEqual ( utils . getTestInfo ( scope , ast ) , [ ] , 'Expected no tests to be found' ) ;
217
217
} ) ;
218
218
} ) ;
@@ -229,8 +229,8 @@ describe('utils', () => {
229
229
230
230
Object . keys ( CASES ) . forEach ( testSource => {
231
231
it ( testSource , ( ) => {
232
- const ast = espree . parse ( testSource , { ecmaVersion : 6 } ) ;
233
- const scope = escope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
232
+ const ast = espree . parse ( testSource , { ecmaVersion : 6 , range : true } ) ;
233
+ const scope = eslintScope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
234
234
const testInfo = utils . getTestInfo ( scope , ast ) ;
235
235
236
236
assert . strictEqual ( testInfo . length , 1 , 'Expected to find one test run' ) ;
@@ -274,8 +274,8 @@ describe('utils', () => {
274
274
275
275
Object . keys ( CASES ) . forEach ( testSource => {
276
276
it ( testSource , ( ) => {
277
- const ast = espree . parse ( testSource , { ecmaVersion : 6 } ) ;
278
- const scope = escope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
277
+ const ast = espree . parse ( testSource , { ecmaVersion : 6 , range : true } ) ;
278
+ const scope = eslintScope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
279
279
const testInfo = utils . getTestInfo ( scope , ast ) ;
280
280
281
281
assert . strictEqual (
@@ -343,8 +343,8 @@ describe('utils', () => {
343
343
344
344
Object . keys ( CASES ) . forEach ( testSource => {
345
345
it ( testSource , ( ) => {
346
- const ast = espree . parse ( testSource , { ecmaVersion : 6 } ) ;
347
- const scope = escope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
346
+ const ast = espree . parse ( testSource , { ecmaVersion : 6 , range : true } ) ;
347
+ const scope = eslintScope . analyze ( ast , { ignoreEval : true , ecmaVersion : 6 , sourceType : 'script' , nodejsScope : true } ) ;
348
348
349
349
estraverse . traverse ( ast , {
350
350
enter ( node , parent ) {
0 commit comments