@blitz/eslint-plugin
Version:
An ESLint config to enforce a consistent code styles across StackBlitz projects
118 lines (92 loc) • 1.99 kB
Markdown
> Require empty lines around comments
This rule extends the base [`@stylistic/ts/lines-around-comment`](https://eslint.style/rules/ts/lines-around-comment) rule.
It adds support for allowing comments at the start and end of `switch` statements, and fixes a bug with enums, arrays, and object literals.
```cjson
{
"@blitz/lines-around-comment": ["error"]
}
```
See [`@stylistic/ts/lines-around-comment`](https://eslint.style/rules/ts/lines-around-comment#options) options.
This rule adds the following options:
```ts
interface Options extends BaseRuleOptions {
allowSwitchStart?: boolean;
allowSwitchEnd?: boolean;
allowMemberCallExpressionStart?: boolean;
}
```
It also overrides `allowObjectStart` and `allowObjectEnd` to work with type object literals.
Example of a correct code when `allowSwitchStart` is set to `true`:
```ts
switch (someValue) {
// some comment
case 'foo': {
// todo
}
}
switch (someValue) {
/* some comment */
case 'foo': {
// todo
}
}
switch (someValue) {
/**
* Some comment.
*/
case 'foo': {
// todo
}
}
```
Example of a correct code when `allowSwitchEnd` is set to `true`:
```ts
switch (someValue) {
case 'foo': {
// todo
}
// some comment
}
switch (someValue) {
case 'foo': {
// todo
}
/* some comment */
}
switch (someValue) {
case 'foo': {
// todo
}
/**
* Some comment.
*/
}
```
Example of a correct code when `allowMemberCallExpression` is set to `true`:
```ts
doSomething()
// some comment
.a.b.c.d.replace('', '');
doSomething()
.a // some comment
.b // some comment
.c // some comment
.d.replace('', '');
doSomething()
// some comment
.doSomeMore('', '')
// some comment
.doSomeMore('', '')
// some comment
.doSomeMore('', '');
someIdentifier
// some comment
.someFn('', '');
```