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

fix(rome_js_analyze): noRedeclaration declaration merging #4288

Merged
merged 1 commit into from
Mar 16, 2023
Merged

fix(rome_js_analyze): noRedeclaration declaration merging #4288

merged 1 commit into from
Mar 16, 2023

Conversation

Conaclos
Copy link
Contributor

@Conaclos Conaclos commented Mar 10, 2023

Summary

Fixes #4287.

While I was fixing the issue, I realized that noDuplicateParameters and noRedeclaration have some intersections. We could merge these two rules in another PR?

EDIT: this PR also allows duplicate parameters. To prevent duplicate parameters use noSuplicateParameters instead.

Test Plan

Extended.

Documentation

Updated.

  • The PR requires documentation
  • I will create a new PR to update the documentation

@netlify
Copy link

netlify bot commented Mar 10, 2023

Deploy Preview for docs-rometools canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 9b5131e
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/6412fa0bd548c5000820b678

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser labels Mar 10, 2023
crates/rome_js_syntax/src/binding_ext.rs Outdated Show resolved Hide resolved
crates/rome_js_syntax/src/binding_ext.rs Outdated Show resolved Hide resolved
@Conaclos Conaclos changed the title fix(rome_js_analyze): noRedeclaration declaration merging fix(rome_js_analyze): noRedeclaration declaration merging Mar 10, 2023
crates/rome_js_syntax/src/binding_ext.rs Outdated Show resolved Hide resolved
crates/rome_js_syntax/src/binding_ext.rs Outdated Show resolved Hide resolved
@Conaclos Conaclos requested a review from ematipico March 15, 2023 10:47
@ematipico
Copy link
Contributor

While I was fixing the issue, I realized that noDuplicateParameters and noRedeclaration have some intersections. We could merge these two rules in another PR?

The two rules have different scopes. noRedeclaration should catch cases like

let a;
let a;

Which causes a different error (runtime).

@Conaclos
Copy link
Contributor Author

Which causes a different error (runtime).

Good point.
It is a bit more complex than it. The rule also forbids var redeclaration that are not a runtime error.
However, it is a special case.

The rule must thus be reworked to avoid to report duplicate parameters.

@Conaclos Conaclos requested a review from ematipico March 15, 2023 22:08
@Conaclos
Copy link
Contributor Author

Conaclos commented Mar 15, 2023

Which causes a different error (runtime).

Note: the rule also reports function redeclarations which are allowed in JavaScript.

crates/rome_js_syntax/src/binding_ext.rs Outdated Show resolved Hide resolved
crates/rome_js_syntax/src/binding_ext.rs Outdated Show resolved Hide resolved
crates/rome_js_syntax/src/binding_ext.rs Outdated Show resolved Hide resolved
@Conaclos Conaclos merged commit 8af7cd1 into rome:main Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter A-Parser Area: parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 noRedeclaration reports mergeable declarations
2 participants