@@ -5,6 +5,7 @@ import eslintPkg from 'eslint/package.json';
5
5
import semver from 'semver' ;
6
6
import flatMap from 'array.prototype.flatmap' ;
7
7
import { resolve } from 'path' ;
8
+ import isCoreModule from 'is-core-module' ;
8
9
import { default as babelPresetFlow } from 'babel-preset-flow' ;
9
10
10
11
const ruleTester = new RuleTester ( ) ;
@@ -2962,7 +2963,7 @@ context('TypeScript', function () {
2962
2963
] ,
2963
2964
} ) ,
2964
2965
] ,
2965
- invalid : [
2966
+ invalid : [ ] . concat (
2966
2967
// Option alphabetize: {order: 'asc'}
2967
2968
test ( {
2968
2969
code : `
@@ -3186,53 +3187,22 @@ context('TypeScript', function () {
3186
3187
] ,
3187
3188
} ) ,
3188
3189
3189
- test ( {
3190
- code : `
3191
- import express from 'express';
3192
- import log4js from 'log4js';
3193
- import chpro from 'node:child_process';
3194
- // import fsp from 'node:fs/promises';
3195
- ` ,
3196
- output : `
3197
- import chpro from 'node:child_process';
3198
- import express from 'express';
3199
- import log4js from 'log4js';
3200
- // import fsp from 'node:fs/promises';
3201
- ` ,
3202
- options : [ {
3203
- groups : [
3204
- 'builtin' ,
3205
- 'external' ,
3206
- 'internal' ,
3207
- 'parent' ,
3208
- 'sibling' ,
3209
- 'index' ,
3210
- 'object' ,
3211
- 'type' ,
3212
- ] ,
3213
- } ] ,
3214
- errors : [
3215
- { message : '`node:child_process` import should occur before import of `express`' } ,
3216
- // { message: '`node:fs/promises` import should occur before import of `express`' },
3217
- ] ,
3218
- } ) ,
3219
-
3220
- test ( {
3221
- code : `
3222
- import express from 'express';
3223
- import log4js from 'log4js';
3224
- import chpro from 'node:child_process';
3225
- // import fsp from 'node:fs/promises';
3226
- ` ,
3227
- output : `
3228
- import chpro from 'node:child_process';
3229
- import express from 'express';
3230
- import log4js from 'log4js';
3231
- // import fsp from 'node:fs/promises';
3232
- ` ,
3233
- options : [ {
3234
- groups : [
3235
- [
3190
+ isCoreModule ( 'node:child_process' ) && isCoreModule ( 'node:fs/promises' ) ? [
3191
+ test ( {
3192
+ code : `
3193
+ import express from 'express';
3194
+ import log4js from 'log4js';
3195
+ import chpro from 'node:child_process';
3196
+ // import fsp from 'node:fs/promises';
3197
+ ` ,
3198
+ output : `
3199
+ import chpro from 'node:child_process';
3200
+ import express from 'express';
3201
+ import log4js from 'log4js';
3202
+ // import fsp from 'node:fs/promises';
3203
+ ` ,
3204
+ options : [ {
3205
+ groups : [
3236
3206
'builtin' ,
3237
3207
'external' ,
3238
3208
'internal' ,
@@ -3242,14 +3212,47 @@ context('TypeScript', function () {
3242
3212
'object' ,
3243
3213
'type' ,
3244
3214
] ,
3215
+ } ] ,
3216
+ errors : [
3217
+ { message : '`node:child_process` import should occur before import of `express`' } ,
3218
+ // { message: '`node:fs/promises` import should occur before import of `express`' },
3245
3219
] ,
3246
- } ] ,
3247
- errors : [
3248
- { message : '`node:child_process` import should occur before import of `express`' } ,
3249
- // { message: '`node:fs/promises` import should occur before import of `express`' },
3250
- ] ,
3251
- } ) ,
3252
- ] ,
3220
+ } ) ,
3221
+
3222
+ test ( {
3223
+ code : `
3224
+ import express from 'express';
3225
+ import log4js from 'log4js';
3226
+ import chpro from 'node:child_process';
3227
+ // import fsp from 'node:fs/promises';
3228
+ ` ,
3229
+ output : `
3230
+ import chpro from 'node:child_process';
3231
+ import express from 'express';
3232
+ import log4js from 'log4js';
3233
+ // import fsp from 'node:fs/promises';
3234
+ ` ,
3235
+ options : [ {
3236
+ groups : [
3237
+ [
3238
+ 'builtin' ,
3239
+ 'external' ,
3240
+ 'internal' ,
3241
+ 'parent' ,
3242
+ 'sibling' ,
3243
+ 'index' ,
3244
+ 'object' ,
3245
+ 'type' ,
3246
+ ] ,
3247
+ ] ,
3248
+ } ] ,
3249
+ errors : [
3250
+ { message : '`node:child_process` import should occur before import of `express`' } ,
3251
+ // { message: '`node:fs/promises` import should occur before import of `express`' },
3252
+ ] ,
3253
+ } ) ,
3254
+ ] : [ ] ,
3255
+ ) ,
3253
3256
} ) ;
3254
3257
} ) ;
3255
3258
} ) ;
0 commit comments