Skip to content

[no-unused-var] False positive for nested namespace declaration #2573

Closed
@hiranya911

Description

@hiranya911
  • 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

{
  root: true,
  parser: '@typescript-eslint/parser',
  plugins: [
    '@typescript-eslint',
  ],
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
  ],
  rules: {
    // Following checks are temporarily disabled. We shall incrementally enable them in the
    // future, fixing any violations as we go.
    '@typescript-eslint/no-non-null-assertion': 0,

    // Disabled checks
    '@typescript-eslint/no-explicit-any': 0,
    '@typescript-eslint/no-use-before-define': 0,

    // Required checks
    'indent': ['error', 2],
    'keyword-spacing': ['error'],
    'max-len': [
      'error',
      {
        'code': 120,
        'ignoreUrls': true
      }
    ],
    "object-curly-spacing": [2, "always"],
    '@typescript-eslint/explicit-function-return-type': [
      'error',
      {
        'allowExpressions': true,
        'allowTypedFunctionExpressions': true,
        'allowHigherOrderFunctions': true
      }
    ],
    'no-unused-vars': 'off', // Must be disabled to enable the next rule
    '@typescript-eslint/no-unused-vars': ['error']
  }
}
export namespace foo.bar {
  export interface User {
    name: string;
  }
}

Expected Result

No lint errors.

Actual Result

error  'bar' is defined but never used  @typescript-eslint/no-unused-vars

Additional Info

Following doesn't trigger the error as far as I can tell.

export namespace foo {
  export namespace bar {
    export interface User {
      name: string;
    }
  }
}

Versions

package version
@typescript-eslint/eslint-plugin 4.1.0
@typescript-eslint/parser 4.1.0
TypeScript 3.7.0
ESLint 7.9.0
node 10.22.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: scope-managerIssues related to @typescript-eslint/scope-managerpackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions