Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

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

Open
nigelsim opened this issue Apr 18, 2023 · 0 comments
Open

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

nigelsim opened this issue Apr 18, 2023 · 0 comments

Comments

@nigelsim
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant