Skip to content

Commit aa82fa6

Browse files
committed
Add rough sort style setup
1 parent 5d7c471 commit aa82fa6

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

src/index.ts

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,84 @@ export default function (styleApi: IStyleAPI, options?: any): Array<IStyleItem>
1515
unicode,
1616
} = styleApi
1717

18-
return []
18+
function isFrameworkModule () {}
19+
20+
// function isFirstPartyModule() {}
21+
22+
return [
23+
/**
24+
* Absolute modules with side effects.
25+
* @example import 'foo'
26+
*/
27+
{ match: and(hasNoMember, isAbsoluteModule) },
28+
{ separator: true },
29+
30+
/**
31+
* Relative modules with side effects.
32+
* @example import './foo'
33+
*/
34+
{ match: and(hasNoMember, isRelativeModule) },
35+
{ separator: true },
36+
37+
/**
38+
* Standard Node.js modules.
39+
* @example import … from 'fs'
40+
*/
41+
{
42+
match: isNodeModule,
43+
sort: moduleName(naturally),
44+
sortNamedMembers: alias(unicode),
45+
},
46+
{ separator: true },
47+
48+
/**
49+
* Known framework modules.
50+
* @example import … from '@ember/foo'
51+
*/
52+
{
53+
match: isFrameworkModule,
54+
sort: moduleName(naturally),
55+
sortNamedMembers: alias(unicode),
56+
},
57+
{ separator: true },
58+
59+
/**
60+
* Third-party modules.
61+
* @example import … from 'foo'
62+
*/
63+
{
64+
match: and(
65+
isAbsoluteModule,
66+
not(isFrameworkModule),
67+
not(isFirstPartyModule),
68+
),
69+
sort: moduleName(naturally),
70+
sortNamedMembers: alias(unicode),
71+
},
72+
{ separator: true },
73+
74+
/**
75+
* Known first-party modules.
76+
* @example import … from '@ember/foo'
77+
*/
78+
{
79+
match: isFirstPartyModule,
80+
sort: moduleName(naturally),
81+
sortNamedMembers: alias(unicode),
82+
},
83+
{ separator: true },
84+
85+
/**
86+
* Explicitly local modules.
87+
* @example
88+
* import … from './foo'
89+
* import … from '../foo'
90+
*/
91+
{
92+
match: isRelativeModule,
93+
sort: [dotSegmentCount, moduleName(naturally)],
94+
sortNamedMembers: alias(unicode),
95+
},
96+
{ separator: true },
97+
]
1998
}

0 commit comments

Comments
 (0)