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

[no-unsafe-member-access] location of warning is swamping other warnings #2164

Closed
LakMoore opened this issue Jun 3, 2020 · 2 comments · Fixed by #7717
Closed

[no-unsafe-member-access] location of warning is swamping other warnings #2164

LakMoore opened this issue Jun 3, 2020 · 2 comments · Fixed by #7717
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@LakMoore
Copy link

LakMoore commented Jun 3, 2020

{
  "rules": {
      '@typescript-eslint/no-unsafe-member-access': 'error',
      '@typescript-eslint/no-unsafe-call': 'error',
  }
}
  public getObs$(): Observable<number> {
    return new Observable<number>();
  }

  public getPopularDepartments(): void {
    this.getObs$.pipe().subscribe((res) => {
      console.log(res);
    });
  }

Expected Result

  public getPopularDepartments(): void {
    this.getObs$.pipe().subscribe((res) => {
                 ~~~~   ~~~~~~~~~
      console.log(res);
    });
  }

Two separate warnings

Actual Result

  public getPopularDepartments(): void {
    this.getObs$.pipe().subscribe((res) => {
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      console.log(res);
    });
  }

By appearances, a single error, with the true error hidden within

Additional Info
The plugin could probably do with a 'loc' property to be returned to define exactly where to show the warning/error. In some paths, the code finds the name of the offending method (subscribe) in this example. It might be a case of finding that string within the source and returning that as the loc property.

Versions

package version
@typescript-eslint/eslint-plugin 3.0.2
@typescript-eslint/parser 3.0.2
TypeScript 3.8.3
ESLint 7.1.0
node 12.16.3
npm 6.14.4
@LakMoore LakMoore added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jun 3, 2020
@LakMoore
Copy link
Author

LakMoore commented Jun 3, 2020

shop_service_ts_—_Client

@bradzacher bradzacher added enhancement New feature or request and removed triage Waiting for maintainers to take a look labels Jun 3, 2020
@bradzacher
Copy link
Member

happy to accept a PR if you'd like to focus the report location!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants