Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Clarify the description of sort-imports options #18198

Merged
merged 9 commits into from
Mar 22, 2024
85 changes: 73 additions & 12 deletions docs/src/rules/sort-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,34 +193,59 @@ import {b, a, c} from 'foo.js'
### `ignoreCase`

When `true` the rule ignores the case-sensitivity of the imports local name.
Uppercase letters of the alphabet must always precede lowercase letters.
gwBear1 marked this conversation as resolved.
Show resolved Hide resolved

Examples of **incorrect** code for this rule with the `{ "ignoreCase": true }` option:
Examples of **incorrect** code for this rule with the default `{ "ignoreCase": false }` option:

::: incorrect

```js
/*eslint sort-imports: ["error", { "ignoreCase": true }]*/

import B from 'foo.js';
/*eslint sort-imports: ["error", { "ignoreCase": false }]*/
import a from 'bar.js';
import B from 'foo.js';
import c from 'baz.js';
```

:::

Examples of **correct** code for this rule with the `{ "ignoreCase": true }` option:
Examples of **correct** code for this rule with the default `{ "ignoreCase": false }` option:

::: correct

```js
/*eslint sort-imports: ["error", { "ignoreCase": true }]*/

import a from 'foo.js';
/*eslint sort-imports: ["error", { "ignoreCase": false }]*/
import B from 'bar.js';
import a from 'foo.js';
import c from 'baz.js';
```

:::

Examples of **correct** code for this rule with `{ "ignoreCase": true }` option:

::: correct

```js
/*eslint sort-imports: ["error", { "ignoreCase": true }]*/
import a from 'bar.js';
import B from 'foo.js';
import c from 'baz.js';
```

:::

Examples of **incorrect** code for this rule with the `{ "ignoreCase": true }` option:

::: incorrect

```js
/*eslint sort-imports: ["error", { "ignoreCase": true }]*/
import B from 'foo.js';
import a from 'bar.js';
```

:::

Default is `false`.
Tanujkanti4441 marked this conversation as resolved.
Show resolved Hide resolved

### `ignoreDeclarationSort`
Expand All @@ -239,18 +264,20 @@ import a from 'bar.js'

:::

Examples of **correct** code for this rule with the `{ "ignoreDeclarationSort": true }` option:
Examples of **correct** code for this rule with the default `{ "ignoreDeclarationSort": false }` option:

::: correct

```js
/*eslint sort-imports: ["error", { "ignoreDeclarationSort": true }]*/
import a from 'foo.js'
import b from 'bar.js'
/*eslint sort-imports: ["error", { "ignoreDeclarationSort": false }]*/
import a from 'bar.js';
import b from 'foo.js';
```

:::

Examples of **correct** code for this rule with the `{ "ignoreDeclarationSort": true }` option:

::: correct

```js
Expand All @@ -261,6 +288,17 @@ import a from 'bar.js'

:::

Examples of **incorrect** code for this rule with the `{ "ignoreDeclarationSort": true }` option:

::: incorrect

```js
/*eslint sort-imports: ["error", { "ignoreDeclarationSort": true }]*/
import {b, a, c} from 'foo.js';
```

:::

Default is `false`.

### `ignoreMemberSort`
Expand All @@ -278,6 +316,17 @@ import {b, a, c} from 'foo.js'

:::

Examples of **correct** code for this rule with the default `{ "ignoreMemberSort": false }` option:

::: correct

```js
/*eslint sort-imports: ["error", { "ignoreMemberSort": false }]*/
import {a, b, c} from 'foo.js';
```

:::

Examples of **correct** code for this rule with the `{ "ignoreMemberSort": true }` option:

::: correct
Expand All @@ -289,6 +338,18 @@ import {b, a, c} from 'foo.js'

:::

Examples of **incorrect** code for this rule with the `{ "ignoreMemberSort": true }` option:

::: incorrect

```js
/*eslint sort-imports: ["error", { "ignoreMemberSort": true }]*/
import b from 'foo.js';
import a from 'bar.js';
```

:::

Default is `false`.

### `memberSyntaxSortOrder`
Expand Down