22
33const montag = require ( 'montag' ) ;
44const { test, stub} = require ( 'supertape' ) ;
5- const mockRequire = require ( 'mock-require' ) ;
65
76const parseOptions = require ( 'putout/parse-options' ) ;
8- const putout = require ( 'putout' ) ;
7+
98const processFile = require ( './process-file' ) ;
109
1110const { assign} = Object ;
1211const noop = ( ) => { } ;
13- const { reRequire, stopAll} = mockRequire ;
1412const { stringify} = JSON ;
1513
1614test ( 'putout: cli: process-file: eslint' , async ( t ) => {
@@ -22,14 +20,10 @@ test('putout: cli: process-file: eslint', async (t) => {
2220 const log = stub ( ) ;
2321 const write = stub ( ) ;
2422
25- mockRequire ( '@putout/eslint' , eslint ) ;
26-
2723 const options = {
2824 dir : '.' ,
2925 } ;
3026
31- const processFile = reRequire ( './process-file' ) ;
32-
3327 const fn = processFile ( {
3428 fix,
3529 log,
@@ -42,10 +36,9 @@ test('putout: cli: process-file: eslint', async (t) => {
4236 index : 0 ,
4337 length : 1 ,
4438 options,
39+ eslint,
4540 } ) ;
4641
47- stopAll ( ) ;
48-
4942 const expected = {
5043 code : source ,
5144 fix,
@@ -65,14 +58,10 @@ test('putout: cli: process-file: ts from preProcessor', async (t) => {
6558 const log = stub ( ) ;
6659 const write = stub ( ) ;
6760
68- mockRequire ( '@putout/eslint' , eslint ) ;
69-
7061 const options = {
7162 dir : '.' ,
7263 } ;
7364
74- const processFile = reRequire ( './process-file' ) ;
75-
7665 const fn = processFile ( {
7766 fix,
7867 log,
@@ -85,10 +74,9 @@ test('putout: cli: process-file: ts from preProcessor', async (t) => {
8574 index : 0 ,
8675 length : 1 ,
8776 options,
77+ eslint,
8878 } ) ;
8979
90- stopAll ( ) ;
91-
9280 const expected = {
9381 code : source ,
9482 fix,
@@ -110,8 +98,6 @@ test('putout: cli: process-file: tsx from preProcessor', async (t) => {
11098 dir : '.' ,
11199 } ;
112100
113- const processFile = reRequire ( './process-file' ) ;
114-
115101 const fn = processFile ( {
116102 fix,
117103 log,
@@ -156,10 +142,6 @@ test('putout: cli: process-file: options for inner data', async (t) => {
156142 plugins : [ 'putout-config' ] ,
157143 } ;
158144
159- mockRequire ( '@putout/eslint' , eslint ) ;
160-
161- const processFile = reRequire ( './process-file' ) ;
162-
163145 const fn = processFile ( {
164146 fix,
165147 log,
@@ -172,10 +154,9 @@ test('putout: cli: process-file: options for inner data', async (t) => {
172154 index : 0 ,
173155 length : 1 ,
174156 options,
157+ eslint,
175158 } ) ;
176159
177- stopAll ( ) ;
178-
179160 const expected = [ {
180161 message : `Use 'String (on/off)' instead of 'Boolean (true/false)'` ,
181162 position : {
@@ -223,14 +204,10 @@ test('putout: cli: process-file: ruler', async (t) => {
223204 plugins : [ 'putout-config' ] ,
224205 } ;
225206
226- mockRequire ( '@putout/eslint' , eslint ) ;
227-
228207 const ruler = {
229208 enableAll : true ,
230209 } ;
231210
232- const processFile = reRequire ( './process-file' ) ;
233-
234211 const fn = processFile ( {
235212 fix,
236213 log,
@@ -243,11 +220,10 @@ test('putout: cli: process-file: ruler', async (t) => {
243220 source,
244221 index : 0 ,
245222 length : 1 ,
223+ eslint,
246224 options,
247225 } ) ;
248226
249- stopAll ( ) ;
250-
251227 const expected = [ {
252228 message : `Use 'String (on/off)' instead of 'Boolean (true/false)'` ,
253229 position : {
@@ -280,16 +256,10 @@ test('putout: cli: process-file: configurePrinter', async (t) => {
280256 const log = stub ( ) ;
281257 const write = stub ( ) ;
282258
283- mockRequire ( 'putout' , {
284- putoutAsync,
285- } ) ;
286-
287259 const options = {
288260 dir : '.' ,
289261 } ;
290262
291- const processFile = reRequire ( './process-file' ) ;
292-
293263 const fn = processFile ( {
294264 fix,
295265 log,
@@ -304,10 +274,9 @@ test('putout: cli: process-file: configurePrinter', async (t) => {
304274 length : 1 ,
305275
306276 source,
277+ putoutAsync,
307278 } ) ;
308279
309- stopAll ( ) ;
310-
311280 const expected = [ 'log123("hello")' , {
312281 dir : '.' ,
313282 fix : false ,
@@ -342,11 +311,6 @@ test('putout: cli: process-file: configurePrinter: overrides', async (t) => {
342311 const log = stub ( ) ;
343312 const write = stub ( ) ;
344313
345- mockRequire ( 'putout' , {
346- ...putout ,
347- putoutAsync,
348- } ) ;
349-
350314 const options = {
351315 dir : '.' ,
352316 printer : [ 'putout' , {
@@ -356,8 +320,6 @@ test('putout: cli: process-file: configurePrinter: overrides', async (t) => {
356320 } ] ,
357321 } ;
358322
359- const processFile = reRequire ( './process-file' ) ;
360-
361323 const fn = processFile ( {
362324 fix,
363325 log,
@@ -372,10 +334,9 @@ test('putout: cli: process-file: configurePrinter: overrides', async (t) => {
372334 length : 1 ,
373335
374336 source,
337+ putoutAsync,
375338 } ) ;
376339
377- stopAll ( ) ;
378-
379340 const expected = [
380341 source , {
381342 dir : '.' ,
@@ -408,19 +369,10 @@ test('putout: cli: process-file: plugin not found', async (t) => {
408369 const log = stub ( ) ;
409370 const write = stub ( ) ;
410371
411- mockRequire ( 'putout' , {
412- ...putout ,
413- putoutAsync,
414- } ) ;
415-
416372 const options = {
417373 dir : '.' ,
418374 } ;
419375
420- reRequire ( '@putout/eslint' ) ;
421-
422- const processFile = reRequire ( './process-file' ) ;
423-
424376 const fn = processFile ( {
425377 fix,
426378 log,
@@ -435,10 +387,9 @@ test('putout: cli: process-file: plugin not found', async (t) => {
435387 length : 1 ,
436388
437389 source,
390+ putoutAsync,
438391 } ) ;
439392
440- stopAll ( ) ;
441-
442393 const expected = {
443394 code : `__putout_processor_yaml({hello: 'world'});` ,
444395 places : [ {
@@ -734,13 +685,6 @@ test('putout: cli: process-file: recursion: infinite loop', async (t) => {
734685 lint,
735686 } ) ;
736687
737- mockRequire ( './simple-import' , {
738- simpleImport,
739- } ) ;
740-
741- reRequire ( 'putout' ) ;
742- const processFile = reRequire ( './process-file' ) ;
743-
744688 const fn = processFile ( {
745689 fix,
746690 log,
@@ -755,6 +699,7 @@ test('putout: cli: process-file: recursion: infinite loop', async (t) => {
755699 options : {
756700 dir : '.' ,
757701 } ,
702+ simpleImport,
758703 } ) ;
759704
760705 const expected = {
@@ -776,8 +721,6 @@ test('putout: cli: process-file: recursion: infinite loop', async (t) => {
776721 } ] ,
777722 } ;
778723
779- stopAll ( ) ;
780-
781724 t . deepEqual ( result , expected ) ;
782725 t . end ( ) ;
783726} ) ;
0 commit comments