Skip to content

Commit 98bbb2c

Browse files
MM25Zamanianljharb
authored andcommitted
[Docs] order: TS code examples should use TS code blocks
1 parent 21304bd commit 98bbb2c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
2323
- [Docs] [`no-unresolved`]: Fix RegExp escaping in readme ([#2332], thanks [@stephtr])
2424
- [Refactor] `namespace`: try to improve performance ([#2340], thanks [@ljharb])
2525
- [Docs] make rule doc titles consistent ([#2393], thanks [@TheJaredWilcurt])
26+
- [Docs] `order`: TS code examples should use TS code blocks ([#2411], thanks [@MM25Zamanian])
2627

2728
## [2.25.4] - 2022-01-02
2829

@@ -973,6 +974,7 @@ for info on changes for earlier releases.
973974

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

977+
[#2411]: https://github.com/import-js/eslint-plugin-import/pull/2411
976978
[#2393]: https://github.com/import-js/eslint-plugin-import/pull/2393
977979
[#2388]: https://github.com/import-js/eslint-plugin-import/pull/2388
978980
[#2381]: https://github.com/import-js/eslint-plugin-import/pull/2381

docs/rules/order.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Enforce a convention in the order of `require()` / `import` statements.
55

66
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:
77

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

3737
## Fail
3838

39-
```js
39+
```ts
4040
import _ from 'lodash';
4141
import path from 'path'; // `path` import should occur before import of `lodash`
4242

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

5555
## Pass
5656

57-
```js
57+
```ts
5858
import path from 'path';
5959
import _ from 'lodash';
6060

@@ -85,7 +85,7 @@ This rule supports the following options:
8585
How groups are defined, and the order to respect. `groups` must be an array of `string` or [`string`]. The only allowed `string`s are:
8686
`"builtin"`, `"external"`, `"internal"`, `"unknown"`, `"parent"`, `"sibling"`, `"index"`, `"object"`, `"type"`.
8787
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:
88-
```js
88+
```ts
8989
[
9090
'builtin', // Built-in types are first
9191
['sibling', 'parent'], // Then sibling and parent types. They can be mingled together
@@ -98,7 +98,7 @@ The default value is `["builtin", "external", "parent", "sibling", "index"]`.
9898

9999
You can set the options like this:
100100

101-
```js
101+
```ts
102102
"import/order": ["error", {"groups": ["index", "sibling", "parent", "internal", "external", "builtin", "object", "type"]}]
103103
```
104104

@@ -184,15 +184,15 @@ The default value is `"ignore"`.
184184

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

187-
```js
187+
```ts
188188
/* eslint import/order: ["error", {"newlines-between": "always"}] */
189189
import fs from 'fs';
190190
import path from 'path';
191191
import index from './';
192192
import sibling from './foo';
193193
```
194194

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

@@ -201,7 +201,7 @@ import index from './';
201201
import sibling from './foo';
202202
```
203203

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

214214
while those will be valid:
215215

216-
```js
216+
```ts
217217
/* eslint import/order: ["error", {"newlines-between": "always"}] */
218218
import fs from 'fs';
219219
import path from 'path';
@@ -223,7 +223,7 @@ import index from './';
223223
import sibling from './foo';
224224
```
225225

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

@@ -234,7 +234,7 @@ import index from './';
234234
import sibling from './foo';
235235
```
236236

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

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

260260
This will fail the rule check:
261261

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

271271
While this will pass:
272272

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

291291
This will fail the rule check:
292292

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

300300
While this will pass:
301301

302-
```js
302+
```ts
303303
/* eslint import/order: ["error", {"warnOnUnassignedImports": true}] */
304304
import fs from 'fs';
305305
import path from 'path';

0 commit comments

Comments
 (0)