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

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

Closed
3 tasks done
canac opened this issue Feb 10, 2021 · 0 comments · Fixed by #3051
Closed
3 tasks done
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@canac
Copy link

canac commented Feb 10, 2021

  • 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
@canac canac added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 10, 2021
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Feb 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants