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

fix: improve indent for decorators #114

Merged
merged 1 commit into from Sep 19, 2022
Merged

fix: improve indent for decorators #114

merged 1 commit into from Sep 19, 2022

Conversation

zanminkian
Copy link
Contributor

Let's say we have code below:

import { Body, Inject, Param, Query } from '@nestjs/common'

export class Test {
  @Inject()
  name?: string
}

export class Controller {
  get(
    @Body()
    body: unknown,
    @Query()
    query: unknown,
    @Param()
    param: unknown,
  ) {
    JSON.stringify(body)
    JSON.stringify(query)
    JSON.stringify(param)
  }
}

Before accept this PR, eslint will format it below (ugly indent):

import { Body, Inject, Param, Query } from '@nestjs/common'

export class Test {
  @Inject()
    name?: string
}

export class Controller {
  get(
  @Body()
    body: unknown,
    @Query()
    query: unknown,
    @Param()
    param: unknown,
  ) {
    JSON.stringify(body)
    JSON.stringify(query)
    JSON.stringify(param)
  }
}

After accept this PR, eslint will format it below:

import { Body, Inject, Param, Query } from '@nestjs/common'

export class Test {
  @Inject()
  name?: string
}

export class Controller {
  get(
    @Body()
    body: unknown,
    @Query()
    query: unknown,
    @Param()
    param: unknown,
  ) {
    JSON.stringify(body)
    JSON.stringify(query)
    JSON.stringify(param)
  }
}

Some info you can get from eggjs/eslint-config-egg#61 and typescript-eslint/typescript-eslint#1232 and typescript-eslint/typescript-eslint#1824.

@antfu antfu changed the title fix: fix wrong indent when function params and class properties decor… fix: improve indent for decorators Sep 19, 2022
@antfu antfu merged commit ae4e44e into antfu:main Sep 19, 2022
@zanminkian zanminkian deleted the patch-3 branch September 19, 2022 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants