Skip to content

Commit

Permalink
docs: add new omitLastInOneLineClassBody option to the semi rule (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jun 11, 2023
1 parent cb2560f commit 0e9980c
Showing 1 changed file with 48 additions and 25 deletions.
73 changes: 48 additions & 25 deletions docs/src/rules/semi.md
Expand Up @@ -80,7 +80,8 @@ String option:

Object option (when `"always"`):

* `"omitLastInOneLineBlock": true` ignores the last semicolon in a block in which its braces (and therefore the content of the block) are in the same line
* `"omitLastInOneLineBlock": true` disallows the last semicolon in a block in which its braces (and therefore the content of the block) are in the same line
* `"omitLastInOneLineClassBody": true` disallows the last semicolon in a class body in which its braces (and therefore the content of the class body) are in the same line

Object option (when `"never"`):

Expand Down Expand Up @@ -132,6 +133,52 @@ class Foo {

:::

#### omitLastInOneLineBlock

Examples of additional **correct** code for this rule with the `"always", { "omitLastInOneLineBlock": true }` options:

::: correct

```js
/*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */

if (foo) { bar() }

if (foo) { bar(); baz() }

function f() { bar(); baz() }

class C {
foo() { bar(); baz() }

static { bar(); baz() }
}
```

:::

#### omitLastInOneLineClassBody

Examples of additional **correct** code for this rule with the `"always", { "omitLastInOneLineClassBody": true }` options:

::: correct

```js
/*eslint semi: ["error", "always", { "omitLastInOneLineClassBody": true}] */

export class SomeClass{
logType(){
console.log(this.type);
console.log(this.anotherType);
}
}

export class Variant1 extends SomeClass{type=1}
export class Variant2 extends SomeClass{type=2; anotherType=3}
```

:::

### never

Examples of **incorrect** code for this rule with the `"never"` option:
Expand Down Expand Up @@ -190,30 +237,6 @@ class Foo {

:::

#### omitLastInOneLineBlock

Examples of additional **correct** code for this rule with the `"always", { "omitLastInOneLineBlock": true }` options:

::: correct

```js
/*eslint semi: ["error", "always", { "omitLastInOneLineBlock": true}] */

if (foo) { bar() }

if (foo) { bar(); baz() }

function f() { bar(); baz() }

class C {
foo() { bar(); baz() }

static { bar(); baz() }
}
```

:::

#### beforeStatementContinuationChars

Examples of additional **incorrect** code for this rule with the `"never", { "beforeStatementContinuationChars": "always" }` options:
Expand Down

0 comments on commit 0e9980c

Please sign in to comment.