Skip to content

Commit

Permalink
Docs: Added examples and structure to padded-blocks (fixes #6628) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto authored and ilyavolodin committed Jul 11, 2016
1 parent 350e1c0 commit e108850
Showing 1 changed file with 69 additions and 12 deletions.
81 changes: 69 additions & 12 deletions docs/rules/padded-blocks.md
Expand Up @@ -24,8 +24,9 @@ This rule takes one argument, which can be an string or an object. If it is `"al

If you want to enforce padding within switches and classes, a configuration object can be passed as the rule argument to configure the cases separately ( e.g. `{ "blocks": "always", "switches": "always", "classes": "always" }` ).

### always

The following patterns are considered problems when set to `"always"`:
Examples of **incorrect** code for this rule with the `"always"` option:

```js
/*eslint padded-blocks: ["error", "always"]*/
Expand Down Expand Up @@ -58,7 +59,7 @@ if (a) {
}
```

The following patterns are not considered problems when set to `"always"`:
Examples of **correct** code for this rule with the `"always"` option:

```js
/*eslint padded-blocks: ["error", "always"]*/
Expand All @@ -84,7 +85,9 @@ if (a) {
}
```

The following patterns are considered problems when set to `"never"`:
### never

Examples of **incorrect** code for this rule with the `"never"` option:

```js
/*eslint padded-blocks: ["error", "never"]*/
Expand Down Expand Up @@ -113,7 +116,7 @@ if (a) {
}
```

The following patterns are not considered problems when set to `"never"`:
Examples of **correct** code for this rule with the `"never"` option:

```js
/*eslint padded-blocks: ["error", "never"]*/
Expand All @@ -128,7 +131,59 @@ if (a)
}
```

The following patterns are considered problems when configured `{ "switches": "always" }`:
### blocks

Examples of **incorrect** code for this rule with the `{ "blocks": "always" }` option:

```js
/*eslint padded-blocks: ["error", { "blocks": "always" }]*/

if (a) {
b();
}

```

Examples of **correct** code for this rule with the `{ "blocks": "always" }` option:

```js
/*eslint padded-blocks: ["error", { "blocks": "always" }]*/

if (a) {

b();

}

```

Examples of **incorrect** code for this rule with the `{ "blocks": "never" }` option:

```js
/*eslint padded-blocks: ["error", { "blocks": "never" }]*/

if (a) {

b();

}

```

Examples of **correct** code for this rule with the `{ "blocks": "never" }` option:

```js
/*eslint padded-blocks: ["error", { "blocks": "never" }]*/

if (a) {
b();
}

```

### switches

Examples of **incorrect** code for this rule with the `{ "switches": "always" }` option:

```js
/*eslint padded-blocks: ["error", { "switches": "always" }]*/
Expand All @@ -138,7 +193,7 @@ switch (a) {
}
```

The following patterns are not considered problems when configured `{ "switches": "always" }`:
Examples of **correct** code for this rule with the `{ "switches": "always" }` option:

```js
/*eslint padded-blocks: ["error", { "switches": "always" }]*/
Expand All @@ -154,7 +209,7 @@ if (a) {
}
```

The following patterns are considered problems when configured `{ "switches": "never" }`:
Examples of **incorrect** code for this rule with the `{ "switches": "never" }` option:

```js
/*eslint padded-blocks: ["error", { "switches": "never" }]*/
Expand All @@ -166,7 +221,7 @@ switch (a) {
}
```

The following patterns are not considered problems when configured `{ "switches": "never" }`:
Examples of **correct** code for this rule with the `{ "switches": "never" }` option:

```js
/*eslint padded-blocks: ["error", { "switches": "never" }]*/
Expand All @@ -182,7 +237,9 @@ if (a) {
}
```

The following patterns are considered problems when configured `{ "classes": "always" }`:
### classes

Examples of **incorrect** code for this rule with the `{ "classes": "always" }` option:

```js
/*eslint padded-blocks: ["error", { "classes": "always" }]*/
Expand All @@ -193,7 +250,7 @@ class A {
}
```

The following patterns are not considered problems when configured `{ "classes": "always" }`:
Examples of **correct** code for this rule with the `{ "classes": "always" }` option:

```js
/*eslint padded-blocks: ["error", { "classes": "always" }]*/
Expand All @@ -206,7 +263,7 @@ class A {
}
```

The following patterns are considered problems when configured `{ "classes": "never" }`:
Examples of **incorrect** code for this rule with the `{ "classes": "never" }` option:

```js
/*eslint padded-blocks: ["error", { "classes": "never" }]*/
Expand All @@ -219,7 +276,7 @@ class A {
}
```

The following patterns are not considered problems when configured `{ "classes": "never" }`:
Examples of **correct** code for this rule with the `{ "classes": "never" }` option:

```js
/*eslint padded-blocks: ["error", { "classes": "never" }]*/
Expand Down

0 comments on commit e108850

Please sign in to comment.