@@ -7,7 +7,6 @@ const ruleTester = new TSESLint.RuleTester({
7
7
parser : espreeParser ,
8
8
parserOptions : {
9
9
ecmaVersion : 2015 ,
10
- sourceType : 'module' ,
11
10
} ,
12
11
} ) ;
13
12
@@ -31,7 +30,6 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
31
30
expect(true).toBeDefined();
32
31
});
33
32
` ,
34
- parserOptions : { sourceType : 'module' } ,
35
33
} ,
36
34
{
37
35
code : dedent `
@@ -45,7 +43,6 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
45
43
const { test } = require('@jest/globals');
46
44
test("foo");
47
45
` ,
48
- parserOptions : { sourceType : 'module' } ,
49
46
} ,
50
47
] ,
51
48
invalid : [
@@ -65,9 +62,9 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
65
62
expect(true).toBeDefined();
66
63
})
67
64
` ,
68
- parserOptions : { sourceType : 'module ' } ,
65
+ parserOptions : { sourceType : 'script ' } ,
69
66
errors : [
70
- { endColumn : 3 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
67
+ { endColumn : 9 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
71
68
] ,
72
69
} ,
73
70
{
@@ -86,9 +83,8 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
86
83
expect(true).toBeDefined();
87
84
})
88
85
` ,
89
- parserOptions : { sourceType : 'module' } ,
90
86
errors : [
91
- { endColumn : 3 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
87
+ { endColumn : 9 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
92
88
] ,
93
89
} ,
94
90
{
@@ -107,49 +103,55 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
107
103
expect(true).toBeDefined();
108
104
})
109
105
` ,
110
- parserOptions : { sourceType : 'module' } ,
111
106
errors : [
112
- { endColumn : 3 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
107
+ { endColumn : 9 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
113
108
] ,
114
109
} ,
115
110
{
116
111
code : dedent `
112
+ import React from 'react';
113
+ import { yourFunction } from './yourFile';
114
+ import something from "something";
117
115
import { test } from '@jest/globals';
116
+ import { xit } from '@jest/globals';
118
117
describe("suite", () => {
119
118
test("foo");
120
119
expect(true).toBeDefined();
121
120
})
122
121
` ,
123
122
output : dedent `
123
+ import React from 'react';
124
+ import { yourFunction } from './yourFile';
125
+ import something from "something";
124
126
import { test, describe, expect } from '@jest/globals';
127
+ import { xit } from '@jest/globals';
125
128
describe("suite", () => {
126
129
test("foo");
127
130
expect(true).toBeDefined();
128
131
})
129
132
` ,
130
133
parserOptions : { sourceType : 'module' } ,
131
134
errors : [
132
- { endColumn : 3 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
135
+ { endColumn : 9 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
133
136
] ,
134
137
} ,
135
138
{
136
139
code : dedent `
137
140
const { test } = require('@jest/globals');
138
- describe("suite", () => {
139
- test("foo");
141
+ describe("suite", () => {
142
+ test("foo");
140
143
expect(true).toBeDefined();
141
144
})
142
145
` ,
143
146
output : dedent `
144
147
const { test, describe, expect } = require('@jest/globals');
145
- describe("suite", () => {
146
- test("foo");
148
+ describe("suite", () => {
149
+ test("foo");
147
150
expect(true).toBeDefined();
148
151
})
149
152
` ,
150
- parserOptions : { sourceType : 'module' } ,
151
153
errors : [
152
- { endColumn : 3 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
154
+ { endColumn : 9 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
153
155
] ,
154
156
} ,
155
157
{
@@ -160,15 +162,14 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
160
162
});
161
163
` ,
162
164
output : dedent `
163
- const { describe, test } = require('@jest/globals');
164
165
const { pending } = require('actions');
166
+ const { describe, test } = require('@jest/globals');
165
167
describe('foo', () => {
166
168
test.each(['hello', 'world'])("%s", (a) => {});
167
169
});
168
170
` ,
169
- parserOptions : { sourceType : 'module' } ,
170
171
errors : [
171
- { endColumn : 4 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
172
+ { endColumn : 9 , column : 1 , messageId : 'preferImportingJestGlobal' } ,
172
173
] ,
173
174
} ,
174
175
] ,
0 commit comments