File tree Expand file tree Collapse file tree 1 file changed +8
-26
lines changed Expand file tree Collapse file tree 1 file changed +8
-26
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const getDocsUrl = require ( './util' ) . getDocsUrl ;
4
- const getNodeName = require ( './util' ) . getNodeName ;
4
+
5
5
const message = `Jest is automatically in scope. Do not import "jest", as Jest doesn't export anything.` ;
6
6
7
7
module . exports = {
@@ -12,32 +12,14 @@ module.exports = {
12
12
} ,
13
13
create ( context ) {
14
14
return {
15
- ImportDeclaration ( node ) {
16
- if ( node . source . value === 'jest' ) {
17
- context . report ( {
18
- node,
19
- message,
20
- } ) ;
21
- }
15
+ 'ImportDeclaration[source.value="jest"]' ( node ) {
16
+ context . report ( { node, message } ) ;
22
17
} ,
23
- CallExpression ( node ) {
24
- const calleeName = getNodeName ( node . callee ) ;
25
- if (
26
- calleeName === 'require' &&
27
- node . arguments [ 0 ] &&
28
- node . arguments [ 0 ] . value === 'jest'
29
- ) {
30
- context . report ( {
31
- loc : {
32
- end : {
33
- column : node . arguments [ 0 ] . loc . end . column ,
34
- line : node . arguments [ 0 ] . loc . end . line ,
35
- } ,
36
- start : node . arguments [ 0 ] . loc . start ,
37
- } ,
38
- message,
39
- } ) ;
40
- }
18
+ 'CallExpression[callee.name="require"][arguments.0.value="jest"]' ( node ) {
19
+ context . report ( {
20
+ loc : node . arguments [ 0 ] . loc ,
21
+ message,
22
+ } ) ;
41
23
} ,
42
24
} ;
43
25
} ,
You can’t perform that action at this time.
0 commit comments