Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[promise-function-async] Error line offset when using decoratorsΒ #751

@RecuencoJones

Description

@RecuencoJones

Repro

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "tsconfig.json"
  },
  "plugins": [
    "@typescript-eslint"
  ],
  "rules": {
    "@typescript-eslint/promise-function-async": "error"
  }
}
{
  "compilerOptions": {
    "target": "es2017",
    "experimentalDecorators": true
  },
  "files": [
    "index.ts"
  ]
}
const SomeFancyDecorator = (): MethodDecorator => (target) => target;

export class Foo {
  @SomeFancyDecorator()
  method() {
    return Promise.resolve('foo');
  }
}

Expected Result

/Users/recuedav/Workspace/GitHub/RecuencoJones/typescript-eslint-issue/index.ts
  5:3  error  Functions that return promises must be async  @typescript-eslint/promise-function-async

βœ– 1 problem (1 error, 0 warnings)

Actual Result

/Users/recuedav/Workspace/GitHub/RecuencoJones/typescript-eslint-issue/index.ts
  4:3  error  Functions that return promises must be async  @typescript-eslint/promise-function-async

βœ– 1 problem (1 error, 0 warnings)

Additional Info

Repository for reproduction: https://github.com/RecuencoJones/typescript-eslint-issue-751

Versions

package version
@typescript-eslint/eslint-plugin 1.11.0
@typescript-eslint/parser 1.11.0
TypeScript 3.4.3
ESLint 5.16.0
node 10.15.0
npm 6.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions