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

Skip to content

[explicit-module-boundary-types] allowNames doesn't work on function and method expressions #3033

@canac

Description

@canac
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro
eslintrc.js:

{
  "rules": {
    "@typescript-eslint/explicit-module-boundary-types": ["error", { "allowedNames": ["foo1", "foo2"] }],
  }
}

main.ts:

export function foo1() {
  return 0;
}

export const object = {
  foo2() {
    return 0;
  },
};

tsconfig.json:

{
  "compilerOptions": {
    "strict": true
  }
}

Expected Result

I expect that allowedNames will whitelist those methods.

Actual Result

This rule generates an error for foo1 and foo2.

1:8  warning  Missing return type on function  @typescript-eslint/explicit-module-boundary-types
6:3  warning  Missing return type on function  @typescript-eslint/explicit-module-boundary-types

Additional Info

It works correctly when using arrow functions. This code gives no errors.

export const foo1 = () => 0;
export const foo2 = () => 0;
export const object = {
  foo2,
};

This still errors, however.

export const object = {
  foo2: () => 0,
};

Versions

package version
@typescript-eslint/eslint-plugin 4.15.0
@typescript-eslint/parser 4.15.0
TypeScript 4.1.5
ESLint 7.19.0
node 15.8.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