diff --git a/docs/src/rules/semi.md b/docs/src/rules/semi.md index 86c4e5d84fe..eca93a74700 100644 --- a/docs/src/rules/semi.md +++ b/docs/src/rules/semi.md @@ -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"`): @@ -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: @@ -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: