@@ -4,7 +4,7 @@ const enhance = require('enhance-visitors');
44const deepStrictEqual = require ( 'deep-strict-equal' ) ;
55const util = require ( './util' ) ;
66
7- const avaImportDeclarationAst = {
7+ const avaImportDeclarationAsts = [ {
88 type : 'ImportDeclaration' ,
99 specifiers : [
1010 {
@@ -19,9 +19,66 @@ const avaImportDeclarationAst = {
1919 type : 'Literal' ,
2020 value : 'ava'
2121 }
22- } ;
22+ } , {
23+ type : 'ImportDeclaration' ,
24+ specifiers : [
25+ {
26+ type : 'ImportSpecifier' ,
27+ imported : {
28+ type : 'Identifier' ,
29+ name : 'serial'
30+ } ,
31+ local : {
32+ type : 'Identifier' ,
33+ name : 'test'
34+ }
35+ }
36+ ] ,
37+ source : {
38+ type : 'Literal' ,
39+ value : 'ava'
40+ }
41+ } , {
42+ type : 'ImportDeclaration' ,
43+ specifiers : [
44+ {
45+ type : 'ImportSpecifier' ,
46+ imported : {
47+ type : 'Identifier' ,
48+ name : 'serial'
49+ } ,
50+ local : {
51+ type : 'Identifier' ,
52+ name : 'test'
53+ }
54+ }
55+ ] ,
56+ source : {
57+ type : 'Literal' ,
58+ value : 'ava'
59+ }
60+ } , {
61+ type : 'ImportDeclaration' ,
62+ specifiers : [
63+ {
64+ type : 'ImportSpecifier' ,
65+ imported : {
66+ type : 'Identifier' ,
67+ name : 'serial'
68+ } ,
69+ local : {
70+ type : 'Identifier' ,
71+ name : 'serial'
72+ }
73+ }
74+ ] ,
75+ source : {
76+ type : 'Literal' ,
77+ value : 'ava'
78+ }
79+ } ] ;
2380
24- const avaVariableDeclaratorAst = {
81+ const avaVariableDeclaratorAsts = [ {
2582 type : 'VariableDeclarator' ,
2683 id : {
2784 type : 'Identifier' ,
@@ -40,7 +97,73 @@ const avaVariableDeclaratorAst = {
4097 }
4198 ]
4299 }
43- } ;
100+ } , {
101+ type : 'VariableDeclarator' ,
102+ id : {
103+ type : 'ObjectPattern' ,
104+ properties : [ {
105+ type : 'Property' ,
106+ key : {
107+ type : 'Identifier' ,
108+ name : 'serial'
109+ } ,
110+ value : {
111+ type : 'Identifier' ,
112+ name : 'serial'
113+ } ,
114+ kind : 'init' ,
115+ method : false ,
116+ shorthand : true ,
117+ computed : false
118+ } ]
119+ } ,
120+ init : {
121+ type : 'CallExpression' ,
122+ callee : {
123+ type : 'Identifier' ,
124+ name : 'require'
125+ } ,
126+ arguments : [
127+ {
128+ type : 'Literal' ,
129+ value : 'ava'
130+ }
131+ ]
132+ }
133+ } , {
134+ type : 'VariableDeclarator' ,
135+ id : {
136+ type : 'ObjectPattern' ,
137+ properties : [ {
138+ type : 'Property' ,
139+ key : {
140+ type : 'Identifier' ,
141+ name : 'serial'
142+ } ,
143+ value : {
144+ type : 'Identifier' ,
145+ name : 'test'
146+ } ,
147+ kind : 'init' ,
148+ method : false ,
149+ shorthand : false ,
150+ computed : false
151+ } ]
152+ } ,
153+ init : {
154+ type : 'CallExpression' ,
155+ callee : {
156+ type : 'Identifier' ,
157+ name : 'require'
158+ } ,
159+ arguments : [
160+ {
161+ type : 'Literal' ,
162+ value : 'ava'
163+ }
164+ ]
165+ }
166+ } ] ;
44167
45168function isTestFunctionCall ( node ) {
46169 if ( node . type === 'Identifier' ) {
@@ -65,12 +188,12 @@ module.exports = () => {
65188 /* eslint quote-props: [2, "as-needed"] */
66189 const predefinedRules = {
67190 ImportDeclaration : node => {
68- if ( ! isTestFile && deepStrictEqual ( espurify ( node ) , avaImportDeclarationAst ) ) {
191+ if ( ! isTestFile && avaImportDeclarationAsts . some ( ast => deepStrictEqual ( espurify ( node ) , ast ) ) ) {
69192 isTestFile = true ;
70193 }
71194 } ,
72195 VariableDeclarator : node => {
73- if ( ! isTestFile && deepStrictEqual ( espurify ( node ) , avaVariableDeclaratorAst ) ) {
196+ if ( ! isTestFile && avaVariableDeclaratorAsts . some ( ast => deepStrictEqual ( espurify ( node ) , ast ) ) ) {
74197 isTestFile = true ;
75198 }
76199 } ,
0 commit comments