Skip to content

Commit 8691ddf

Browse files
author
Tigran Kaginyan
committed
Removed "private" type from default types and updated docs accordingly
1 parent 33cda36 commit 8691ddf

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

docs/rules/order.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,29 @@ This rule supports the following options:
7777

7878
### `groups: [array]`:
7979

80-
How groups are defined, and the order to respect. `groups` must be an array of `string` or [`string`]. The only allowed `string`s are: `"builtin"`, `"external"`, `"internal"`, `"parent"`, `"sibling"`, `"index"`. The enforced order is the same as the order of each element in a group. Omitted types are implicitly grouped together as the last element. Example:
80+
How groups are defined, and the order to respect. `groups` must be an array of types or [types].
81+
82+
The types can be either `"String"`: `"builtin"`, `"external"`, `"internal"`, `"parent"`, `"sibling"`, `"index"`,
83+
or ```Object```: ```{ name: 'absolute'<String>, pattern: //<RegExp> }```, ```{ name: 'private'<String>, pattern: '^my-awesome-project/libs'<RegExp> }```
84+
85+
We intentionally made `"absolute"` type matching with optional pattern, because a lot of projects use aliases and have complicated absolute path logic.
86+
The meaning of `"private"` type is to separate project/company level packages and libs from all `"external"`
87+
88+
The enforced order is the same as the order of each element in a group. Omitted types are implicitly grouped together as the last element. Example:
8189
```js
8290
[
8391
'builtin', // Built-in types are first
92+
[{ name: 'private', pattern: '^my-awesome-project/libs' }, 'internal'] // The private types and internal (@myproject) are mixed together
93+
{ name: 'absolute', pattern: '^src' }, // Then absolute types
8494
['sibling', 'parent'], // Then sibling and parent types. They can be mingled together
8595
'index', // Then the index file
8696
// Then the rest: internal and external type
8797
]
8898
```
89-
The default value is `["builtin", "external", "parent", "sibling", "index"]`.
99+
The default value is `["builtin", "external", "absolute", "parent", "sibling", "index"]`.
100+
By default `"absolute"` type will be applied to any import which path starts with `"/"` if you want to change
101+
that behavior you can specify absolute type with ```Object``` literal ```{ name: 'absolute'<String>, pattern: //<RegExp> }```.
102+
Custom pattern behavior can be applied only for `"absolute"` and `"private"` types
90103

91104
You can set the options like this:
92105

src/rules/order.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import importType from '../core/importType'
44
import isStaticRequire from '../core/staticRequire'
55
import docsUrl from '../docsUrl'
66

7-
const defaultGroups = ['builtin', 'external', 'private', 'absolute', 'parent', 'sibling', 'index']
7+
const defaultGroups = ['builtin', 'external', 'private', 'absolute', 'sibling', 'index']
88

99
// REPORTING AND FIXING
1010

0 commit comments

Comments
 (0)