diff --git a/tests/src/rules/order.js b/tests/src/rules/order.js index 3ffa4b8a1d..0dce831e46 100644 --- a/tests/src/rules/order.js +++ b/tests/src/rules/order.js @@ -1238,6 +1238,52 @@ ruleTester.run('order', rule, { '`./local4` import should occur after import of `global5`', ], }), + // reorder fix cannot cross function call on moving below + test(withoutAutofixOutput({ + code: ` + const local = require('./local'); + const global1 = require('global1'); + const global2 = require('global2'); + fn_call(); + const global3 = require('global3'); + + fn_call(); + `, + errors: [{ + ruleId: 'order', + message: '`./local` import should occur after import of `global3`', + }], + })), + // reorder fix cannot cross function call on moving below + // fix imports that not crosses function call only + test({ + code: ` + const local1 = require('./local1'); + const global1 = require('global1'); + const global2 = require('global2'); + fn_call(); + const local2 = require('./local2'); + const global3 = require('global3'); + const global4 = require('global4'); + + fn_call(); + `, + output: ` + const local1 = require('./local1'); + const global1 = require('global1'); + const global2 = require('global2'); + fn_call(); + const global3 = require('global3'); + const global4 = require('global4'); + const local2 = require('./local2'); + + fn_call(); + `, + errors: [ + '`./local1` import should occur after import of `global4`', + '`./local2` import should occur after import of `global4`', + ], + }), // reorder fix cannot cross non import or require test(withoutAutofixOutput({ code: `