question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variables are incorrectly marked as shadowed

See original GitHub issue

Tell us about your environment

  • ESLint Version: v7.8.1

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?

@typescript-eslint/parser

Please show your full configuration:

Configuration
module.exports = {
  parser: "@typescript-eslint/parser",
  plugins: ["@typescript-eslint", "prettier"],
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "prettier",
    "prettier/@typescript-eslint",
    "prettier/standard"
  ],
  env: {
    browser: true,
    node: true
  },
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: "module"
  },
  rules: {
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/no-explicit-any": "off",
    "@typescript-eslint/prefer-for-of": "error",
    "@typescript-eslint/no-require-imports": "error",
    "@typescript-eslint/no-parameter-properties": "off",
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": [
      "error",
      {
        vars: "all",
        args: "none",
        ignoreRestSiblings: true
      }
    ],
    "@typescript-eslint/no-object-literal-type-assertion": "off",
    "@typescript-eslint/no-namespace": "off",
    "@typescript-eslint/no-non-null-assertion": "off",
    "max-len": ["error", { code: 120, tabWidth: 4 }],
    "linebreak-style": ["error", "unix"],
    "no-alert": "error",
    "prefer-const": "error",
    "no-return-assign": "error",
    "no-useless-call": "error",
    "no-shadow": "error",
    "no-useless-concat": "error",
    "no-undef": "off",
    "no-prototype-builtins": "off",
    "prettier/prettier": "error"
  }
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

export function foo(bar: number, baz: (bar: number) => void) {}

What did you expect to happen?

no error

What actually happened? Please include the actual, raw output from ESLint.

'bar' is already declared in the upper scope.eslintno-shadow

Are you willing to submit a pull request to fix this bug?

no

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

[@typescript-eslint/no-shadow] Variables are incorrectly ...
I have read the FAQ and my problem is not listed. ... [@typescript-eslint/no-shadow] Variables are incorrectly marked as shadowed #2469.
Read more >
What is the problem with shadowing names defined in outer ...
This inspection detects shadowing names defined in outer scopes. I know it is bad practice to access variable from the outer scope, but...
Read more >
C++ static code analysis: Variables should not be shadowed
Overriding or shadowing a variable declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of...
Read more >
Problem set 1 Mario variable issue - CS50 Stack Exchange
It's saying declaration shadows a local variable now when I type make mario. – Rayray94. May 1, 2020 at 19:11.
Read more >
Shadowing built-in functions - MATLAB Answers - MathWorks
It is a well known problem from the forums, that the name of a built-in function is used for a variable ... Never...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found