Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 lint/suspicious/noRedeclare - Index signatures still conflict with var names. #175

Closed
1 task done
lgarron opened this issue Sep 6, 2023 · 0 comments · Fixed by #594
Closed
1 task done
Assignees
Labels
A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@lgarron
Copy link

lgarron commented Sep 6, 2023

Environment information

CLI:
  Version:                      1.1.0
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.5.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/9.8.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    true
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Discovering running Biome servers...

What happened?

Consider the following code:

function process(
  input: { [type: string]: string },
  f: (s: string) => number
): ClipboardItemInterface {
  // biome-ignore lint/style/noVar: Need to use `var` for `esbuild` to target ES5.
  var output_: { [type: string]: number } = {};
  // biome-ignore lint/style/noVar: Need to use `var` for `esbuild` to target ES5.
  for (var type in items) {
    output[type] = f(input[type])
  }
  return output;
}

Due to the use of var, a version of rome/tools#4478 still occurs:

Shouldn't redeclare 'type'. Consider to delete it or rename it. [lint/suspicious/noRedeclare](https://biomejs.dev/lint/rules/noRedeclare)

The issue doesn't appear if the for loop uses const. Hoisting the var out of the loop declaration doesn't help.

As noted in the comments of the snippet, it is necessary to use var for code targeted at ES5 environments. See https://github.com/lgarron/clipboard-polyfill/blob/c24845e280262858cf40c5fce8443abf5a8dc51b/src/clipboard-polyfill/ClipboardItem/ClipboardItemPolyfill.ts#L19 for a real-world use case.

Expected result

No error.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico ematipico added A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug labels Oct 2, 2023
@Conaclos Conaclos self-assigned this Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants