Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.
This repository was archived by the owner on May 12, 2025. It is now read-only.

@typescript-eslint/no-redeclare is ignore block scope of const/let #319

@nigelsim

Description

@nigelsim

Treat this as more of a (possible) sign post.

I setup ESLint extending the plugin:import/recommended, airbnb-typescript and prettier configs.

{
    "parserOptions": {
        "ecmaVersion": "ES2019",
        "sourceType": "module",
        "project": "./tsconfig.json"
    },
    "extends": [
        "plugin:import/recommended",
        "airbnb-typescript",
        "prettier"
    ],
    "plugins": [
        "react"
    ],
    "settings": {
        "import/ignore": [
            "node_modules/react-native/index\\.js$"
        ]
    }
}

When doing this, code like:

function test(path: boolean) {
    if (path) {
        const name = 'path 1';
    } else {
        const name = 'path 2';
    }
} 

Would produce

error    'name' is already defined                                              @typescript-eslint/no-redeclare

After trying to reproduce with just ESLint and then just @typescript-eslint, I found that including airbnb-typescript in the extends was introducing the issue.

I've not traced further at this point, but this seemed to be a rarely reported issue, so hope the helps someone.

Node version: v14.21.1
npm version: v6.14.17
Local ESLint version: v8.38.0 (Currently used)
Global ESLint version: Not found
Operating System: linux 5.15.0-69-generic
eslint-config-airbnb-base@^15.0.0
eslint-config-airbnb-typescript@^17.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions