Skip to content

[promise-function-async] False positives for inline arrow funcs #778

Closed
@milesj

Description

@milesj

Noticed a lot of false positives for inline arrow functions that were returning non-promise values, yet were failing this rule. touchedFiles is a string[].

Screen Shot 2019-07-29 at 12 56 53 PM

Screen Shot 2019-07-29 at 12 57 15 PM

Screen Shot 2019-07-29 at 1 05 30 PM

Repro

{
  "rules": {
    "@typescript-eslint/promise-function-async": "warn"
  }
}
import path from 'path';

export function someExample() {
  ['foo', 'bar', 'baz'].some(value => path.basename(value));
}

Expected Result

Inline arrow functions that accept/return primitive values should not fail.

Actual Result

They currently fail.

Additional Info

Doesn't fail when checkArrowFunctions is false.

TS config:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "preserve",
    "lib": [
      "dom",
      "esnext"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "pretty": true,
    "removeComments": false,
    "strict": true,
    "target": "es2018",
    "declarationDir": "./lib",
    "outDir": "./lib"
  },
  "include": [
    "./src/**/*",
    "./types/**/*"
  ],
  "exclude": [
    "**/node_modules/*"
  ]
}

Versions

package version
@typescript-eslint/eslint-plugin 1.13.0
@typescript-eslint/parser 1.13.0
TypeScript 3.5.3
ESLint 5.16.0
node 10.14.0
npm 6.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions