Skip to content

Commit

Permalink
fix(ordering): changed default groups to not contain unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Jun 11, 2019
1 parent 4827e72 commit d81a5c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/rules/order.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ How groups are defined, and the order to respect. `groups` must be an array of `
// Then the rest: internal and external type
]
```
The default value is `["builtin", "external", "unknown", "parent", "sibling", "index"]`.
The default value is `["builtin", "external", "parent", "sibling", "index"]`.

You can set the options like this:

Expand Down
2 changes: 1 addition & 1 deletion src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import importType from '../core/importType'
import isStaticRequire from '../core/staticRequire'
import docsUrl from '../docsUrl'

const defaultGroups = ['builtin', 'external', 'unknown', 'parent', 'sibling', 'index']
const defaultGroups = ['builtin', 'external', 'parent', 'sibling', 'index']

// REPORTING AND FIXING

Expand Down
14 changes: 12 additions & 2 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,19 @@ ruleTester.run('order', rule, {
var index = require('./');
`,
}),
// Using unknown import types (e.g. using an resolver alias via babel)
// Addijg unknown import types (e.g. using an resolver alias via babel) to the groups.
test({
code: `
import fs from 'fs';
import { Input } from '-/components/Input';
import { Button } from '-/components/Button';
import { add } from './helper';`,
options: [{
groups: ['builtin', 'external', 'unknown', 'parent', 'sibling', 'index'],
}],
}),
// Using unknown import types (e.g. using an resolver alias via babel) with
// a custom group list.
// an alternative custom group list.
test({
code: `
import { Input } from '-/components/Input';
Expand All @@ -197,6 +200,7 @@ ruleTester.run('order', rule, {
options: [
{
'newlines-between': 'always',
groups: ['builtin', 'external', 'unknown', 'parent', 'sibling', 'index'],
},
],
}),
Expand Down Expand Up @@ -933,6 +937,11 @@ ruleTester.run('order', rule, {
import { Button } from '-/components/Button';
import { add } from './helper';
`,
options: [
{
groups: ['builtin', 'external', 'unknown', 'parent', 'sibling', 'index'],
},
],
errors: [
{
line: 4,
Expand All @@ -958,6 +967,7 @@ ruleTester.run('order', rule, {
`,
options: [
{
groups: ['builtin', 'external', 'unknown', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
},
],
Expand Down

0 comments on commit d81a5c8

Please sign in to comment.