Skip to content

Commit

Permalink
Update order.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian committed Mar 22, 2022
1 parent 21304bd commit 2caaf13
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions docs/rules/order.md
Expand Up @@ -5,7 +5,7 @@ Enforce a convention in the order of `require()` / `import` statements.

With the [`groups`](#groups-array) option set to `["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"]` the order is as shown in the following example:

```js
```ts
// 1. node "builtin" modules
import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -36,7 +36,7 @@ Statements using the ES6 `import` syntax must appear before any `require()` stat

## Fail

```js
```ts
import _ from 'lodash';
import path from 'path'; // `path` import should occur before import of `lodash`

Expand All @@ -54,7 +54,7 @@ import foo from './foo'; // `import` statements must be before `require` stateme

## Pass

```js
```ts
import path from 'path';
import _ from 'lodash';

Expand Down Expand Up @@ -85,7 +85,7 @@ This rule supports the following options:
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"`, `"unknown"`, `"parent"`, `"sibling"`, `"index"`, `"object"`, `"type"`.
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:
```js
```ts
[
'builtin', // Built-in types are first
['sibling', 'parent'], // Then sibling and parent types. They can be mingled together
Expand All @@ -98,7 +98,7 @@ The default value is `["builtin", "external", "parent", "sibling", "index"]`.

You can set the options like this:

```js
```ts
"import/order": ["error", {"groups": ["index", "sibling", "parent", "internal", "external", "builtin", "object", "type"]}]
```

Expand Down Expand Up @@ -184,15 +184,15 @@ The default value is `"ignore"`.

With the default group setting, the following will be invalid:

```js
```ts
/* eslint import/order: ["error", {"newlines-between": "always"}] */
import fs from 'fs';
import path from 'path';
import index from './';
import sibling from './foo';
```

```js
```ts
/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */
import fs from 'fs';

Expand All @@ -201,7 +201,7 @@ import index from './';
import sibling from './foo';
```

```js
```ts
/* eslint import/order: ["error", {"newlines-between": "never"}] */
import fs from 'fs';
import path from 'path';
Expand All @@ -213,7 +213,7 @@ import sibling from './foo';

while those will be valid:

```js
```ts
/* eslint import/order: ["error", {"newlines-between": "always"}] */
import fs from 'fs';
import path from 'path';
Expand All @@ -223,7 +223,7 @@ import index from './';
import sibling from './foo';
```

```js
```ts
/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */
import fs from 'fs';

Expand All @@ -234,7 +234,7 @@ import index from './';
import sibling from './foo';
```

```js
```ts
/* eslint import/order: ["error", {"newlines-between": "never"}] */
import fs from 'fs';
import path from 'path';
Expand All @@ -250,7 +250,7 @@ Sort the order within each group in alphabetical manner based on **import path**
- `caseInsensitive`: use `true` to ignore case, and `false` to consider case (default: `false`).

Example setting:
```js
```ts
alphabetize: {
order: 'asc', /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */
caseInsensitive: true /* ignore case. Options: [true, false] */
Expand All @@ -259,7 +259,7 @@ alphabetize: {

This will fail the rule check:

```js
```ts
/* eslint import/order: ["error", {"alphabetize": {"order": "asc", "caseInsensitive": true}}] */
import React, { PureComponent } from 'react';
import aTypes from 'prop-types';
Expand All @@ -270,7 +270,7 @@ import blist from 'BList';

While this will pass:

```js
```ts
/* eslint import/order: ["error", {"alphabetize": {"order": "asc", "caseInsensitive": true}}] */
import blist from 'BList';
import * as classnames from 'classnames';
Expand All @@ -290,7 +290,7 @@ way that is safe.

This will fail the rule check:

```js
```ts
/* eslint import/order: ["error", {"warnOnUnassignedImports": true}] */
import fs from 'fs';
import './styles.css';
Expand All @@ -299,7 +299,7 @@ import path from 'path';

While this will pass:

```js
```ts
/* eslint import/order: ["error", {"warnOnUnassignedImports": true}] */
import fs from 'fs';
import path from 'path';
Expand Down

0 comments on commit 2caaf13

Please sign in to comment.