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: add missing correct/incorrect containers #16087

Merged
merged 1 commit into from Jul 6, 2022
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
4 changes: 4 additions & 0 deletions docs/src/rules/camelcase.md
Expand Up @@ -319,6 +319,8 @@ function UNSAFE_componentWillMount() {

:::

::: correct

```js
/*eslint camelcase: ["error", {allow: ["^UNSAFE_"]}]*/

Expand All @@ -331,6 +333,8 @@ function UNSAFE_componentWillMount() {
}
```

:::

## When Not To Use It

If you have established coding standards using a different naming convention (separating words with underscores), turn this rule off.
8 changes: 8 additions & 0 deletions docs/src/rules/func-name-matching.md
Expand Up @@ -31,6 +31,8 @@ class C {

:::

::: incorrect

```js
/*eslint func-name-matching: ["error", "never"] */

Expand All @@ -46,6 +48,8 @@ class C {
}
```

:::

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

::: correct
Expand Down Expand Up @@ -95,6 +99,8 @@ module['exports'] = function foo(name) {};

:::

::: correct

```js
/*eslint func-name-matching: ["error", "never"] */
/*eslint-env es6*/
Expand Down Expand Up @@ -137,6 +143,8 @@ module.exports = function foo(name) {};
module['exports'] = function foo(name) {};
```

:::

## Options

This rule takes an optional string of "always" or "never" (when omitted, it defaults to "always"), and an optional options object with two properties `considerPropertyDescriptor` and `includeCommonJSModuleExports`.
Expand Down
4 changes: 4 additions & 0 deletions docs/src/rules/key-spacing.md
Expand Up @@ -290,6 +290,8 @@ var obj = {

:::

::: correct

```js
/*eslint key-spacing: ["error", {
"align": {
Expand All @@ -305,6 +307,8 @@ var obj = {
}
```

:::

### align and multiLine

The `multiLine` and `align` options can differ, which allows for fine-tuned control over the `key-spacing` of your files. `align` will **not** inherit from `multiLine` if `align` is configured as an object.
Expand Down
16 changes: 16 additions & 0 deletions docs/src/rules/max-lines-per-function.md
Expand Up @@ -87,6 +87,8 @@ function foo() {

:::

::: incorrect

```js
/*eslint max-lines-per-function: ["error", 2]*/
function foo() {
Expand All @@ -95,6 +97,10 @@ function foo() {
}
```

:::

::: incorrect

```js
/*eslint max-lines-per-function: ["error", 2]*/
function foo() {
Expand All @@ -104,6 +110,8 @@ function foo() {
}
```

:::

Examples of **correct** code for this rule with a max value of `3`:

::: correct
Expand All @@ -117,6 +125,8 @@ function foo() {

:::

::: correct

```js
/*eslint max-lines-per-function: ["error", 3]*/
function foo() {
Expand All @@ -125,6 +135,10 @@ function foo() {
}
```

:::

::: correct

```js
/*eslint max-lines-per-function: ["error", 3]*/
function foo() {
Expand All @@ -134,6 +148,8 @@ function foo() {
}
```

:::

### skipBlankLines

Examples of **incorrect** code for this rule with the `{ "skipBlankLines": true }` option:
Expand Down
16 changes: 16 additions & 0 deletions docs/src/rules/max-lines.md
Expand Up @@ -48,20 +48,28 @@ var a,

:::

::: incorrect

```js
/*eslint max-lines: ["error", 2]*/

var a,
b,c;
```

:::

::: incorrect

```js
/*eslint max-lines: ["error", 2]*/
// a comment
var a,
b,c;
```

:::

Examples of **correct** code for this rule with a max value of `2`:

::: correct
Expand All @@ -74,18 +82,26 @@ var a,

:::

::: correct

```js
/*eslint max-lines: ["error", 2]*/

var a, b, c;
```

:::

::: correct

```js
/*eslint max-lines: ["error", 2]*/
// a comment
var a, b, c;
```

:::

### skipBlankLines

Examples of **incorrect** code for this rule with the `{ "skipBlankLines": true }` option:
Expand Down
20 changes: 20 additions & 0 deletions docs/src/rules/no-class-assign.md
Expand Up @@ -36,6 +36,8 @@ A = 0;

:::

::: incorrect

```js
/*eslint no-class-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -44,6 +46,10 @@ A = 0;
class A { }
```

:::

::: incorrect

```js
/*eslint no-class-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -55,6 +61,10 @@ class A {
}
```

:::

::: incorrect

```js
/*eslint no-class-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -67,6 +77,8 @@ let A = class A {
}
```

:::

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

::: correct
Expand All @@ -81,6 +93,8 @@ A = 0; // A is a variable.

:::

::: correct

```js
/*eslint no-class-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -92,6 +106,10 @@ let A = class {
}
```

:::

::: correct

```js
/*eslint no-class-assign: 2*/
/*eslint-env es6*/
Expand All @@ -103,6 +121,8 @@ class A {
}
```

:::

## When Not To Use It

If you don't want to be notified about modifying variables of class declarations, you can safely disable this rule.
4 changes: 4 additions & 0 deletions docs/src/rules/no-compare-neg-zero.md
Expand Up @@ -39,10 +39,14 @@ if (x === 0) {

:::

::: correct

```js
/* eslint no-compare-neg-zero: "error" */

if (Object.is(x, -0)) {
// doSomething()...
}
```

:::
16 changes: 16 additions & 0 deletions docs/src/rules/no-const-assign.md
Expand Up @@ -30,6 +30,8 @@ a = 1;

:::

::: incorrect

```js
/*eslint no-const-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -38,6 +40,10 @@ const a = 0;
a += 1;
```

:::

::: incorrect

```js
/*eslint no-const-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -46,6 +52,8 @@ const a = 0;
++a;
```

:::

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

::: correct
Expand All @@ -60,6 +68,8 @@ console.log(a);

:::

::: correct

```js
/*eslint no-const-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -69,6 +79,10 @@ for (const a in [1, 2, 3]) { // `a` is re-defined (not modified) on each loop st
}
```

:::

::: correct

```js
/*eslint no-const-assign: "error"*/
/*eslint-env es6*/
Expand All @@ -78,6 +92,8 @@ for (const a of [1, 2, 3]) { // `a` is re-defined (not modified) on each loop st
}
```

:::

## When Not To Use It

If you don't want to be notified about modifying variables that are declared using `const` keyword, you can safely disable this rule.
4 changes: 4 additions & 0 deletions docs/src/rules/no-continue.md
Expand Up @@ -46,6 +46,8 @@ for(i = 0; i < 10; i++) {

:::

::: incorrect

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

Expand All @@ -61,6 +63,8 @@ labeledLoop: for(i = 0; i < 10; i++) {
}
```

:::

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

::: correct
Expand Down
8 changes: 8 additions & 0 deletions docs/src/rules/no-eval.md
Expand Up @@ -146,20 +146,28 @@ this.eval("var a = 0");

:::

::: correct

```js
/*eslint no-eval: "error"*/
/*eslint-env browser*/

window.eval("var a = 0");
```

:::

::: correct

```js
/*eslint no-eval: "error"*/
/*eslint-env node*/

global.eval("var a = 0");
```

:::

## Known Limitations

* This rule is warning every `eval()` even if the `eval` is not global's.
Expand Down
4 changes: 4 additions & 0 deletions docs/src/rules/no-extra-strict.md
Expand Up @@ -55,9 +55,13 @@ Examples of **correct** code for this rule:

:::

::: correct

```js
(function () {
"use strict";
var foo = true;
}());
```

:::