Skip to content

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

@LakMoore

Description

@LakMoore
{
  "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

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: 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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy