Skip to content

Commit a7bdd1c

Browse files
authored
test(eslint-plugin): render snapshots of ESLint output for each code example (#8497)
1 parent 6e4881c commit a7bdd1c

File tree

142 files changed

+10395
-106
lines changed

Some content is hidden

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

142 files changed

+10395
-106
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ if (false) {
4141
console.log('hello');
4242
}
4343
if (false) {
44-
/*
45-
@ts-ignore: Unreachable code error
46-
*/
44+
/* @ts-ignore: Unreachable code error */
4745
console.log('hello');
4846
}
4947
```
@@ -90,9 +88,7 @@ if (false) {
9088
console.log('hello');
9189
}
9290
if (false) {
93-
/*
94-
@ts-expect-error: Unreachable code error
95-
*/
91+
/* @ts-expect-error: Unreachable code error */
9692
console.log('hello');
9793
}
9894
```

packages/eslint-plugin/docs/rules/class-methods-use-this.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Example of incorrect code when `ignoreClassesThatImplementAnInterface` is set to
7070
<Tabs>
7171
<TabItem value="❌ Incorrect">
7272

73-
```ts
73+
```ts option='{ "ignoreClassesThatImplementAnInterface": "public-fields" }'
7474
class X implements Y {
7575
method() {}
7676
property = () => {};
@@ -86,7 +86,7 @@ class X implements Y {
8686
</TabItem>
8787
<TabItem value="✅ Correct">
8888

89-
```ts
89+
```ts option='{ "ignoreClassesThatImplementAnInterface": "public-fields" }'
9090
class X implements Y {
9191
method() {}
9292
property = () => {};

packages/eslint-plugin/docs/rules/consistent-type-exports.mdx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,6 @@ export type { T };
8585
export { x };
8686
```
8787

88-
<Tabs>
89-
<TabItem value="❌ Incorrect">
90-
91-
```ts option='{ "fixMixedExportsWithInlineTypeSpecifier": true }'
92-
export { Button } from 'some-library';
93-
export type { ButtonProps } from 'some-library';
94-
```
95-
96-
</TabItem>
97-
<TabItem value="✅ Correct">
98-
99-
```ts option='{ "fixMixedExportsWithInlineTypeSpecifier": true }'
100-
export { Button, type ButtonProps } from 'some-library';
101-
```
102-
103-
</TabItem>
104-
</Tabs>
105-
10688
## When Not To Use It
10789

10890
If you use `--isolatedModules` the compiler would error if a type is not re-exported using `export type`.

packages/eslint-plugin/docs/rules/default-param-last.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ It adds support for optional parameters.
1616
<TabItem value="❌ Incorrect">
1717

1818
```ts
19-
/* eslint @typescript-eslint/default-param-last: "error" */
20-
2119
function f(a = 0, b: number) {}
2220
function f(a: number, b = 0, c: number) {}
2321
function f(a: number, b?: number, c: number) {}
@@ -39,8 +37,6 @@ class Foo {
3937
<TabItem value="✅ Correct">
4038

4139
```ts
42-
/* eslint @typescript-eslint/default-param-last: "error" */
43-
4440
function f(a = 0) {}
4541
function f(a: number, b = 0) {}
4642
function f(a: number, b?: number) {}

packages/eslint-plugin/docs/rules/explicit-module-boundary-types.mdx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,33 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e.
9797

9898
### `allowArgumentsExplicitlyTypedAsAny`
9999

100-
Examples of code for this rule with `{ allowArgumentsExplicitlyTypedAsAny: false }`:
100+
When this option is `true`, the rule ignores arguments that are explicitly typed as any.
101101

102102
<Tabs>
103-
<TabItem value="❌ Incorrect">
103+
<TabItem value="❌ Incorrect for `allowArgumentsExplicitlyTypedAsAny: false`">
104104

105105
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
106106
export const func = (value: any): number => value + 1;
107107
```
108108

109109
</TabItem>
110-
<TabItem value="✅ Correct">
110+
<TabItem value="✅ Correct for `allowArgumentsExplicitlyTypedAsAny: true`">
111111

112-
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
113-
export const func = (value: number): number => value + 1;
112+
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": true }'
113+
export const func = (value: any): number => value + 1;
114114
```
115115

116116
</TabItem>
117117
</Tabs>
118118

119119
### `allowDirectConstAssertionInArrowFunctions`
120120

121-
Examples of code for this rule with `{ allowDirectConstAssertionInArrowFunctions: false }`:
121+
When this option is `true`, the rule ignores return type annotations on body-less arrow functions that return an `as const` type assertion.
122122

123123
<Tabs>
124-
<TabItem value="❌ Incorrect">
124+
<TabItem value="❌ Incorrect for `allowDirectConstAssertionInArrowFunctions: false`">
125125

126-
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
126+
```ts option='{ "allowDirectConstAssertionInArrowFunctions": false }'
127127
export const func = (value: number) => ({ type: 'X', value });
128128
export const foo = () => ({
129129
bar: true,
@@ -132,9 +132,9 @@ export const bar = () => 1;
132132
```
133133

134134
</TabItem>
135-
<TabItem value="✅ Correct">
135+
<TabItem value="✅ Correct for `allowDirectConstAssertionInArrowFunctions: true`">
136136

137-
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
137+
```ts option='{ "allowDirectConstAssertionInArrowFunctions": true }'
138138
export const func = (value: number) => ({ type: 'X', value }) as const;
139139
export const foo = () =>
140140
({
@@ -163,10 +163,10 @@ You may pass function/method names you would like this rule to ignore, like so:
163163

164164
### `allowHigherOrderFunctions`
165165

166-
Examples of code for this rule with `{ allowHigherOrderFunctions: false }`:
166+
When this option is `true`, the rule ignores return type annotations on function, which is immediately returning another function expression.
167167

168168
<Tabs>
169-
<TabItem value="❌ Incorrect">
169+
<TabItem value="❌ Incorrect for `allowHigherOrderFunctions: false`">
170170

171171
```ts option='{ "allowHigherOrderFunctions": false }'
172172
export const arrowFn = () => () => {};
@@ -181,9 +181,9 @@ export function foo(outer: string) {
181181
```
182182

183183
</TabItem>
184-
<TabItem value="✅ Correct">
184+
<TabItem value="✅ Correct for `allowHigherOrderFunctions: true`">
185185

186-
```ts option='{ "allowHigherOrderFunctions": false }'
186+
```ts option='{ "allowHigherOrderFunctions": true }'
187187
export const arrowFn = () => (): void => {};
188188

189189
export function fn() {
@@ -200,10 +200,10 @@ export function foo(outer: string) {
200200

201201
### `allowTypedFunctionExpressions`
202202

203-
Examples of code for this rule with `{ allowTypedFunctionExpressions: false }`:
203+
When this option is `true`, the rule ignores type annotations on the variable of a function expression.
204204

205205
<Tabs>
206-
<TabItem value="❌ Incorrect">
206+
<TabItem value="❌ Incorrect for `allowTypedFunctionExpressions: false`">
207207

208208
```ts option='{ "allowTypedFunctionExpressions": false }'
209209
export let arrowFn = () => 'test';
@@ -220,9 +220,9 @@ export const foo = bar => {};
220220
```
221221

222222
</TabItem>
223-
<TabItem value="✅ Correct">
223+
<TabItem value="✅ Correct for `allowTypedFunctionExpressions: true`">
224224

225-
```ts option='{ "allowTypedFunctionExpressions": false }'
225+
```ts option='{ "allowTypedFunctionExpressions": true }'
226226
type FuncType = () => string;
227227

228228
export let arrowFn: FuncType = () => 'test';

packages/eslint-plugin/docs/rules/member-ordering.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,9 +1011,9 @@ interface Foo {
10111011
b(): void;
10121012
a: boolean;
10131013

1014-
[a: string]: number; // Order doesn't matter (no sortable identifier)
1015-
new (): Bar; // Order doesn't matter (no sortable identifier)
1016-
(): Baz; // Order doesn't matter (no sortable identifier)
1014+
[a: string]: number;
1015+
new (): Bar;
1016+
(): Baz;
10171017
}
10181018
```
10191019

@@ -1022,12 +1022,12 @@ interface Foo {
10221022

10231023
```ts option='{ "default": { "memberTypes": "never", "order": "alphabetically" } }'
10241024
interface Foo {
1025+
[a: string]: number;
10251026
a: boolean;
10261027
b(): void;
10271028

1028-
[a: string]: number; // Order doesn't matter (no sortable identifier)
1029-
new (): Bar; // Order doesn't matter (no sortable identifier)
1030-
(): Baz; // Order doesn't matter (no sortable identifier)
1029+
(): Baz;
1030+
new (): Bar;
10311031
}
10321032
```
10331033

packages/eslint-plugin/docs/rules/no-extraneous-class.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class NotEmptyClass {
293293

294294
### `allowWithDecorator`
295295

296-
The `allowWithDecorator` option adds an exemption for classes that contain a member decorated with a `@` decorator.
296+
The `allowWithDecorator` option adds an exemption for classes decorated with a `@` decorator.
297297

298298
<Tabs>
299299
<TabItem value="❌ Incorrect">
@@ -308,8 +308,8 @@ class Constants {
308308
<TabItem value="✅ Correct">
309309

310310
```ts option='{ "allowWithDecorator": true }'
311+
@logOnRead()
311312
class Constants {
312-
@logOnRead()
313313
static readonly version = 42;
314314
}
315315
```

packages/eslint-plugin/docs/rules/no-floating-promises.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ This allows you to skip checking of async IIFEs (Immediately Invoked function Ex
104104

105105
Examples of **correct** code for this rule with `{ ignoreIIFE: true }`:
106106

107-
<!-- prettier-ignore -->
107+
{/* prettier-ignore */}
108108
```ts option='{ "ignoreIIFE": true }' showPlaygroundButton
109109
await (async function () {
110110
await res(1);

packages/eslint-plugin/docs/rules/no-implied-eval.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ This rule aims to eliminate implied `eval()` through the use of `new Function()`
3636
<TabItem value="❌ Incorrect">
3737

3838
```ts
39-
/* eslint @typescript-eslint/no-implied-eval: "error" */
40-
4139
setTimeout('alert(`Hi!`);', 100);
4240

4341
setInterval('alert(`Hi!`);', 100);
@@ -65,8 +63,6 @@ const fn = new Function('a', 'b', 'return a + b');
6563
<TabItem value="✅ Correct">
6664

6765
```ts
68-
/* eslint @typescript-eslint/no-implied-eval: "error" */
69-
7066
setTimeout(function () {
7167
alert('Hi!');
7268
}, 100);

packages/eslint-plugin/docs/rules/no-meaningless-void-operator.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function bar(x: number) {
4444
void x; // discarding a number
4545
return 2;
4646
}
47-
void bar(); // discarding a number
47+
void bar(1); // discarding a number
4848
```
4949

5050
</TabItem>

0 commit comments

Comments
 (0)