Skip to content

Commit

Permalink
docs(eslint-plugin): format array-type docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Jun 28, 2019
1 parent 44b099d commit 44677b4
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions packages/eslint-plugin/docs/rules/array-type.md
Expand Up @@ -23,15 +23,15 @@ Always use `T[]` or `readonly T[]` for all array types.
Incorrect code for `"array"`:

```ts
const x: Array<string> = ["a", "b"];
const y: ReadonlyArray<string> = ["a", "b"];
const x: Array<string> = ['a', 'b'];
const y: ReadonlyArray<string> = ['a', 'b'];
```

Correct code for `"array"`:

```ts
const x: string[] = ["a", "b"];
const y: readonly string[] = ["a", "b"];
const x: string[] = ['a', 'b'];
const y: readonly string[] = ['a', 'b'];
```

### `"generic"`
Expand All @@ -41,15 +41,15 @@ Always use `Array<T>` or `ReadonlyArray<T>` for all array types.
Incorrect code for `"generic"`:

```ts
const x: string[] = ["a", "b"];
const y: readonly string[] = ["a", "b"];
const x: string[] = ['a', 'b'];
const y: readonly string[] = ['a', 'b'];
```

Correct code for `"generic"`:

```ts
const x: Array<string> = ["a", "b"];
const y: ReadonlyArray<string> = ["a", "b"];
const x: Array<string> = ['a', 'b'];
const y: ReadonlyArray<string> = ['a', 'b'];
```

### `"array-simple"`
Expand All @@ -60,23 +60,23 @@ Use `Array<T>` or `ReadonlyArray<T>` for all other types (union types, intersect
Incorrect code for `"array-simple"`:

```ts
const a: (string | number)[] = ["a", "b"];
const b: ({ prop: string })[] = [{ prop: "a" }];
const a: (string | number)[] = ['a', 'b'];
const b: ({ prop: string })[] = [{ prop: 'a' }];
const c: (() => void)[] = [() => {}];
const d: Array<MyType> = ["a", "b"];
const e: Array<string> = ["a", "b"];
const f: ReadonlyArray<string> = ["a", "b"];
const d: Array<MyType> = ['a', 'b'];
const e: Array<string> = ['a', 'b'];
const f: ReadonlyArray<string> = ['a', 'b'];
```

Correct code for `"array-simple"`:

```ts
const a: Array<string | number> = ["a", "b"];
const b: Array<{ prop: string }> = [{ prop: "a" }];
const a: Array<string | number> = ['a', 'b'];
const b: Array<{ prop: string }> = [{ prop: 'a' }];
const c: Array<() => void> = [() => {}];
const d: MyType[] = ["a", "b"];
const e: string[] = ["a", "b"];
const f: readonly string[] = ["a", "b"];
const d: MyType[] = ['a', 'b'];
const e: string[] = ['a', 'b'];
const f: readonly string[] = ['a', 'b'];
```

## Related to
Expand Down

0 comments on commit 44677b4

Please sign in to comment.