@@ -285,6 +285,78 @@ import index from './';
285
285
import sibling from ' ./foo' ;
286
286
```
287
287
288
+ ### ` named: true|false|{ enabled: true|false, import: true|false, export: true|false, require: true|false, cjsExports: true|false, types: mixed|types-first|types-last } `
289
+
290
+ Enforce ordering of names within imports and exports:
291
+
292
+ - If set to ` true ` , named imports must be ordered according to the ` alphabetize ` options
293
+ - If set to ` false ` , named imports can occur in any order
294
+
295
+ ` enabled ` enables the named ordering for all expressions by default.
296
+ Use ` import ` , ` export ` and ` require ` and ` cjsExports ` to override the enablement for the following kind of expressions:
297
+
298
+ - ` import ` :
299
+
300
+ ``` ts
301
+ import { Readline } from " readline" ;
302
+ ```
303
+
304
+ - ` export ` :
305
+
306
+ ``` ts
307
+ export { Readline };
308
+ // and
309
+ export { Readline } from " readline" ;
310
+ ```
311
+
312
+ - ` require `
313
+
314
+ ``` ts
315
+ const { Readline } = require (" readline" );
316
+ ```
317
+
318
+ - ` cjsExports `
319
+
320
+ ``` ts
321
+ module .exports .Readline = Readline ;
322
+ // and
323
+ module .exports = { Readline };
324
+ ```
325
+
326
+ The ` types ` option allows you to specify the order of ` import ` s and ` export ` s of ` type ` specifiers.
327
+ Following values are possible:
328
+
329
+ - ` types-first ` : forces ` type ` specifiers to occur first
330
+ - ` types-last ` : forces value specifiers to occur first
331
+ - ` mixed ` : sorts all specifiers in alphabetical order
332
+
333
+ The default value is ` false ` .
334
+
335
+ Example setting:
336
+
337
+ ``` ts
338
+ {
339
+ named : true ,
340
+ alphabetize : {
341
+ order : ' asc'
342
+ }
343
+ }
344
+ ```
345
+
346
+ This will fail the rule check:
347
+
348
+ ``` ts
349
+ /* eslint import/order: ["error", {"named": true, "alphabetize": {"order": "asc"}}] */
350
+ import { compose , apply } from ' xcompose' ;
351
+ ```
352
+
353
+ While this will pass:
354
+
355
+ ``` ts
356
+ /* eslint import/order: ["error", {"named": true, "alphabetize": {"order": "asc"}}] */
357
+ import { apply , compose } from ' xcompose' ;
358
+ ```
359
+
288
360
### ` alphabetize: {order: asc|desc|ignore, orderImportKind: asc|desc|ignore, caseInsensitive: true|false} `
289
361
290
362
Sort the order within each group in alphabetical manner based on ** import path** :
0 commit comments