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

chore: add correct incorrect in all rules doc #16021

Merged
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
30 changes: 30 additions & 0 deletions docs/src/rules/accessor-pairs.md
Expand Up @@ -26,6 +26,7 @@ var o = {
}
};


// Good
var o = {
set a(value) {
Expand Down Expand Up @@ -58,6 +59,8 @@ This rule always checks object literals and property descriptors. By default, it

Examples of **incorrect** code for the default `{ "setWithoutGet": true }` option:

:::incorrect

```js
/*eslint accessor-pairs: "error"*/

Expand All @@ -67,6 +70,7 @@ var o = {
}
};


var o = {d: 1};
Object.defineProperty(o, 'c', {
set: function(value) {
Expand All @@ -75,8 +79,12 @@ Object.defineProperty(o, 'c', {
});
```

:::

Examples of **correct** code for the default `{ "setWithoutGet": true }` option:

:::correct

```js
/*eslint accessor-pairs: "error"*/

Expand All @@ -101,10 +109,14 @@ Object.defineProperty(o, 'c', {

```

:::

### getWithoutSet

Examples of **incorrect** code for the `{ "getWithoutSet": true }` option:

:::incorrect

```js
/*eslint accessor-pairs: ["error", { "getWithoutSet": true }]*/

Expand Down Expand Up @@ -135,8 +147,12 @@ Object.defineProperty(o, 'c', {
});
```

:::

Examples of **correct** code for the `{ "getWithoutSet": true }` option:

:::correct

```js
/*eslint accessor-pairs: ["error", { "getWithoutSet": true }]*/
var o = {
Expand All @@ -160,6 +176,8 @@ Object.defineProperty(o, 'c', {

```

:::

### enforceForClassMembers

When `enforceForClassMembers` is set to `true` (default):
Expand All @@ -169,6 +187,8 @@ When `enforceForClassMembers` is set to `true` (default):

Examples of **incorrect** code for `{ "getWithoutSet": true, "enforceForClassMembers": true }`:

:::incorrect

```js
/*eslint accessor-pairs: ["error", { "getWithoutSet": true, "enforceForClassMembers": true }]*/

Expand All @@ -194,8 +214,12 @@ const Baz = class {
}
```

:::

Examples of **incorrect** code for `{ "setWithoutGet": true, "enforceForClassMembers": true }`:

:::incorrect

```js
/*eslint accessor-pairs: ["error", { "setWithoutGet": true, "enforceForClassMembers": true }]*/

Expand All @@ -212,10 +236,14 @@ const Bar = class {
}
```

:::

When `enforceForClassMembers` is set to `false`, this rule ignores classes.

Examples of **correct** code for `{ "getWithoutSet": true, "setWithoutGet": true, "enforceForClassMembers": false }`:

:::correct

```js
/*eslint accessor-pairs: ["error", {
"getWithoutSet": true, "setWithoutGet": true, "enforceForClassMembers": false
Expand Down Expand Up @@ -246,6 +274,8 @@ const Quux = class {
}
```

:::

## Known Limitations

Due to the limits of static analysis, this rule does not account for possible side effects and in certain cases
Expand Down
48 changes: 48 additions & 0 deletions docs/src/rules/array-bracket-newline.md
Expand Up @@ -34,6 +34,8 @@ Or an object option (Requires line breaks if any of properties is satisfied. Oth

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

:::incorrect

```js
/*eslint array-bracket-newline: ["error", "always"]*/

Expand All @@ -47,8 +49,12 @@ var e = [function foo() {
}];
```

:::

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

:::correct

```js
/*eslint array-bracket-newline: ["error", "always"]*/

Expand All @@ -71,10 +77,14 @@ var e = [
];
```

:::

### never

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

:::incorrect

```js
/*eslint array-bracket-newline: ["error", "never"]*/

Expand All @@ -97,8 +107,12 @@ var e = [
];
```

:::

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

:::correct

```js
/*eslint array-bracket-newline: ["error", "never"]*/

Expand All @@ -112,10 +126,14 @@ var e = [function foo() {
}];
```

:::

### consistent

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

:::incorrect

```js
/*eslint array-bracket-newline: ["error", "consistent"]*/

Expand All @@ -133,8 +151,12 @@ var d = [
}]
```

:::

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

:::correct

```js
/*eslint array-bracket-newline: ["error", "consistent"]*/

Expand All @@ -155,10 +177,14 @@ var f = [
];
```

:::

### multiline

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

:::incorrect

```js
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/

Expand All @@ -177,8 +203,12 @@ var e = [function foo() {
}];
```

:::

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

:::correct

```js
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/

Expand All @@ -196,10 +226,14 @@ var e = [
];
```

:::

### minItems

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

:::incorrect

```js
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/

Expand All @@ -218,8 +252,12 @@ var e = [
];
```

:::

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

:::correct

```js
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/

Expand All @@ -237,10 +275,14 @@ var e = [function foo() {
}];
```

:::

### multiline and minItems

Examples of **incorrect** code for this rule with the `{ "multiline": true, "minItems": 2 }` options:

:::incorrect

```js
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/

Expand All @@ -257,8 +299,12 @@ var e = [function foo() {
}];
```

:::

Examples of **correct** code for this rule with the `{ "multiline": true, "minItems": 2 }` options:

:::correct

```js
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/

Expand All @@ -278,6 +324,8 @@ var e = [
];
```

:::

## When Not To Use It

If you don't want to enforce line breaks after opening and before closing array brackets, don't enable this rule.
Expand Down