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] order: TS code examples should use TS code blocks #2411

Merged
merged 1 commit into from Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
- [Docs] [`no-unresolved`]: Fix RegExp escaping in readme ([#2332], thanks [@stephtr])
- [Refactor] `namespace`: try to improve performance ([#2340], thanks [@ljharb])
- [Docs] make rule doc titles consistent ([#2393], thanks [@TheJaredWilcurt])
- [Docs] `order`: TS code examples should use TS code blocks ([#2411], thanks [@MM25Zamanian])

## [2.25.4] - 2022-01-02

Expand Down Expand Up @@ -973,6 +974,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#2411]: https://github.com/import-js/eslint-plugin-import/pull/2411
[#2393]: https://github.com/import-js/eslint-plugin-import/pull/2393
[#2388]: https://github.com/import-js/eslint-plugin-import/pull/2388
[#2381]: https://github.com/import-js/eslint-plugin-import/pull/2381
Expand Down
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