Skip to content

Commit 04baac8

Browse files
author
Josh Goldberg
authored
docs: standardized rule docs heading and option-less Options (#4367)
1 parent 4a6d217 commit 04baac8

File tree

125 files changed

+710
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+710
-140
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# `your-rule-name`
2+
3+
Your rule description here.
4+
5+
## Rule Details
6+
7+
To fill out: tell us more about this rule.
8+
9+
<!--tabs-->
10+
11+
### ❌ Incorrect
12+
13+
```ts
14+
// To fill out: incorrect code
15+
```
16+
17+
### ✅ Correct
18+
19+
```ts
20+
// To fill out: correct code
21+
```
22+
23+
## Options
24+
25+
```jsonc
26+
// .eslintrc.json
27+
{
28+
"rules": {
29+
"@typescript-eslint/your-rule-name": "error"
30+
}
31+
}
32+
```
33+
34+
If not configurable: This rule is not configurable.
35+
36+
If configurable...
37+
38+
```ts
39+
type Options = {
40+
someOption?: boolean;
41+
};
42+
43+
const defaultOptions: Options = {
44+
someOption: false,
45+
};
46+
```
47+
48+
## When Not To Use It
49+
50+
To fill out: why wouldn't you want to use this rule?
51+
For example if this rule requires a feature released in a certain TS version.
52+
53+
## Attributes
54+
55+
- [ ] ✅ Recommended
56+
- [ ] 🔧 Fixable
57+
- [ ] 💭 Requires type information

packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Require that member overloads be consecutive (`adjacent-overload-signatures`)
1+
# `adjacent-overload-signatures`
2+
3+
Require that member overloads be consecutive.
24

35
Grouping overloaded members together can improve readability of the code.
46

@@ -82,6 +84,19 @@ export function foo(n: number): void;
8284
export function foo(sn: string | number): void;
8385
```
8486

87+
## Options
88+
89+
```jsonc
90+
// .eslintrc.json
91+
{
92+
"rules": {
93+
"@typescript-eslint/adjacent-overload-signatures": "error"
94+
}
95+
}
96+
```
97+
98+
This rule is not configurable.
99+
85100
## When Not To Use It
86101

87102
If you don't care about the general structure of the code, then you will not need this rule.

packages/eslint-plugin/docs/rules/array-type.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Requires using either `T[]` or `Array<T>` for arrays (`array-type`)
1+
# `array-type`
2+
3+
Requires using either `T[]` or `Array<T>` for arrays.
24

35
Using the same style for array definitions across your codebase makes it easier for your developers to read and understand the types.
46

packages/eslint-plugin/docs/rules/await-thenable.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Disallows awaiting a value that is not a Thenable (`await-thenable`)
1+
# `await-thenable`
2+
3+
Disallows awaiting a value that is not a Thenable.
24

35
This rule disallows awaiting a value that is not a "Thenable" (an object which has `then` method, such as a Promise).
46
While it is valid JavaScript to await a non-`Promise`-like value (it will resolve immediately), this pattern is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise.
@@ -27,6 +29,19 @@ const createValue = async () => 'value';
2729
await createValue();
2830
```
2931

32+
## Options
33+
34+
```jsonc
35+
// .eslintrc.json
36+
{
37+
"rules": {
38+
"@typescript-eslint/await-thenable": "error"
39+
}
40+
}
41+
```
42+
43+
This rule is not configurable.
44+
3045
## When Not To Use It
3146

3247
If you want to allow code to `await` non-Promise values.

packages/eslint-plugin/docs/rules/ban-ts-comment.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Bans `@ts-<directive>` comments from being used or requires descriptions after directive (`ban-ts-comment`)
1+
# `ban-ts-comment`
2+
3+
Bans `@ts-<directive>` comments from being used or requires descriptions after directive.
24

35
TypeScript provides several directive comments that can be used to alter how it processes files.
46
Using these to suppress TypeScript Compiler Errors reduces the effectiveness of TypeScript overall.

packages/eslint-plugin/docs/rules/ban-tslint-comment.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Bans `// tslint:<rule-flag>` comments from being used (`ban-tslint-comment`)
1+
# `ban-tslint-comment`
2+
3+
Bans `// tslint:<rule-flag>` comments from being used.
24

35
Useful when migrating from TSLint to ESLint. Once TSLint has been removed, this rule helps locate TSLint annotations (e.g. `// tslint:disable`).
46

packages/eslint-plugin/docs/rules/ban-types.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Bans specific types from being used (`ban-types`)
1+
# `ban-types`
2+
3+
Bans specific types from being used.
24

35
Some builtin types have aliases, some types are considered dangerous or harmful.
46
It's often a good idea to ban certain types to help with consistency and safety.

packages/eslint-plugin/docs/rules/brace-style.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Enforce consistent brace style for blocks (`brace-style`)
1+
# `brace-style`
2+
3+
Enforce consistent brace style for blocks.
24

35
## Rule Details
46

packages/eslint-plugin/docs/rules/class-literal-property-style.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Ensures that literals on classes are exposed in a consistent style (`class-literal-property-style`)
1+
# `class-literal-property-style`
2+
3+
Ensures that literals on classes are exposed in a consistent style.
24

35
When writing TypeScript applications, it's typically safe to store literal values on classes using fields with the `readonly` modifier to prevent them from being reassigned.
46
When writing TypeScript libraries that could be used by JavaScript users however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type.

packages/eslint-plugin/docs/rules/comma-dangle.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Require or disallow trailing comma (`comma-dangle`)
1+
# `comma-dangle`
2+
3+
Require or disallow trailing comma.
24

35
## Rule Details
46

0 commit comments

Comments
 (0)