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: Fix tabs in rule examples #17653

Merged
merged 6 commits into from Oct 26, 2023
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
11 changes: 7 additions & 4 deletions docs/src/rules/indent-legacy.md
Expand Up @@ -140,20 +140,23 @@ function foo(d) {

Examples of **correct** code for this rule with the `"tab"` option:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: correct

```js
/*eslint indent-legacy: ["error", "tab"]*/

if (a) {
/*tab*/b=c;
/*tab*/function foo(d) {
/*tab*//*tab*/e=f;
/*tab*/}
b=c;
function foo(d) {
e=f;
}
}
```

:::
<!-- markdownlint-restore -->

### SwitchCase

Expand Down
11 changes: 7 additions & 4 deletions docs/src/rules/indent.md
Expand Up @@ -141,20 +141,23 @@ function foo(d) {

Examples of **correct** code for this rule with the `"tab"` option:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: correct

```js
/*eslint indent: ["error", "tab"]*/

if (a) {
/*tab*/b=c;
/*tab*/function foo(d) {
/*tab*//*tab*/e=f;
/*tab*/}
b=c;
function foo(d) {
e=f;
}
}
```

:::
<!-- markdownlint-restore -->

### ignoredNodes

Expand Down
19 changes: 13 additions & 6 deletions docs/src/rules/max-len.md
Expand Up @@ -69,30 +69,36 @@ var foo = {

Examples of **incorrect** code for this rule with the default `{ "tabWidth": 4 }` option:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: incorrect

```js
/*eslint max-len: ["error", { "code": 80, "tabWidth": 4 }]*/

\t \t var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };
var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };
```

:::
<!-- markdownlint-restore -->

Examples of **correct** code for this rule with the default `{ "tabWidth": 4 }` option:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: correct

```js
/*eslint max-len: ["error", { "code": 80, "tabWidth": 4 }]*/

\t \t var foo = {
\t \t \t \t "bar": "This is a bar.",
\t \t \t \t "baz": { "qux": "This is a qux" }
\t \t };
var foo = {
"bar": "This is a bar.",
"baz": { "qux": "This is a qux" }
};
```

:::
<!-- markdownlint-restore -->

### comments

Expand Down Expand Up @@ -203,7 +209,8 @@ Examples of **correct** code for this rule with the `ignorePattern` option:
::: correct

```js
/*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(" }]*/
/*eslint max-len:
["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(" }]*/

var dep = require('really/really/really/really/really/really/really/really/long/module');
```
Expand Down
30 changes: 15 additions & 15 deletions docs/src/rules/no-mixed-spaces-and-tabs.md
Expand Up @@ -15,42 +15,42 @@ This rule disallows mixed spaces and tabs for indentation.

Examples of **incorrect** code for this rule:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: incorrect

```js
/*eslint no-mixed-spaces-and-tabs: "error"*/

function add(x, y) {
// --->..return x + y;
fasttime marked this conversation as resolved.
Show resolved Hide resolved

return x + y;
return x + y;
}

function main() {
// --->var x = 5,
// --->....y = 7;

var x = 5,
y = 7;
var x = 5,
y = 7;
}
```

:::
<!-- markdownlint-restore -->

Examples of **correct** code for this rule:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: correct

```js
/*eslint no-mixed-spaces-and-tabs: "error"*/

function add(x, y) {
// --->return x + y;
return x + y;
return x + y;
}
```

:::
<!-- markdownlint-restore -->

## Options

Expand All @@ -62,18 +62,18 @@ This rule has a string option.

Examples of **correct** code for this rule with the `"smart-tabs"` option:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: correct

```js
/*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/

function main() {
// --->var x = 5,
// --->....y = 7;

var x = 5,
y = 7;
var x = 5,
y = 7;
}
```

:::
<!-- markdownlint-restore -->
20 changes: 15 additions & 5 deletions docs/src/rules/no-tabs.md
Expand Up @@ -12,26 +12,33 @@ This rule looks for tabs anywhere inside a file: code, comments or anything else

Examples of **incorrect** code for this rule:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: incorrect

```js
var a \t= 2;
/* eslint no-tabs: "error" */

var a = 2;

/**
* \t\t it's a test function
* it's a test function
*/
function test(){}

var x = 1; // \t test
var x = 1; // test
```

:::
<!-- markdownlint-restore -->

Examples of **correct** code for this rule:

::: correct

```js
/* eslint no-tabs: "error" */

var a = 2;

/**
Expand All @@ -54,19 +61,22 @@ This rule has an optional object option with the following properties:

Examples of **correct** code for this rule with the `allowIndentationTabs: true` option:

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD010 -->
::: correct

```js
/* eslint no-tabs: ["error", { allowIndentationTabs: true }] */

function test() {
\tdoSomething();
doSomething();
}

\t// comment with leading indentation tab
// comment with leading indentation tab
```

:::
<!-- markdownlint-restore -->

## When Not To Use It

Expand Down