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

feat(rome_js_analyzer): implement rule noRedeclaration, no-redeclare #4053

Merged
merged 2 commits into from
Mar 1, 2023

Conversation

edvardchen
Copy link
Contributor

@edvardchen edvardchen commented Dec 14, 2022

Summary

implement noRedeclaration https://eslint.org/docs/latest/rules/no-redeclare. Fixes #3990

Test Plan

have run

  1. just codegen
  2. just test-lintrule no_redeclaration
  3. just documentation
  4. just check-ready
running 2 tests
test specs::nursery::no_redeclaration::valid_jsonc ... ok
test specs::nursery::no_redeclaration::invalid_jsonc ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 249 filtered out; finished in 0.10s

Documentation

Caveats

  • Not handle the redeclaration of global variables and function parameters

@edvardchen edvardchen requested review from leops, ematipico, xunilrj and a team as code owners December 14, 2022 11:09
@netlify
Copy link

netlify bot commented Dec 14, 2022

Deploy Preview for docs-rometools canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit b832f75
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63ff69da3cf11c00087a775b

@edvardchen edvardchen marked this pull request as draft December 14, 2022 11:17
type Options = ();

fn run(ctx: &RuleContext<Self>) -> Self::Signals {
let mut duplicates = Duplicates::default();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Not sure there is value hiding that this is a HashMap here.

let mut duplicates = HashMap::default();

seems clearer to me.

@edvardchen edvardchen marked this pull request as ready for review December 17, 2022 14:52
@edvardchen edvardchen changed the title [WIP] implement rule noRedeclaration, no-redeclare implement rule noRedeclaration, no-redeclare Dec 17, 2022
@ematipico
Copy link
Contributor

@edvardchen could you please comment on #3990 so I can assign that to you?

@ematipico ematipico changed the title implement rule noRedeclaration, no-redeclare feat(rome_js_analyzer): implement rule noRedeclaration, no-redeclare Dec 20, 2022
let model = ctx.model();
let bindings = model.scope(ctx.query().syntax()).bindings();
for binding in bindings {
let name = binding.tree().text();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: you could use binding.tree().name_token().ok()?.text_trimmed() to use an &str as key and avoid allocating a String

@github-actions
Copy link

This PR is stale because it has been open 14 days with no activity.

@ematipico ematipico removed the S-Stale label Feb 14, 2023
@Conaclos Conaclos added the A-Linter Area: linter label Feb 15, 2023
Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we addressed all the comments. We can rebase the branch, generate the files again and merge it! 🚀

@Conaclos
Copy link
Contributor

@edvardchen Thanks for your contribution :) In order to merge your contribution, you have to rebase your branch on main in order to solve the current conflicts.

feat(rome_js_analyze): implement rule no_redeclaration

feat(rome_js_analyze): update document about noRedeclaration

feat(rome_js_analyze): link the first binding in diagnostic for rule no_redecleration

test(rome_js_analyze): add testcases for no_redeclaration

fix(rome_js_analyze): fix lint error

docs(rome_js_analyze): update document

feat(rome_js_analyze): don't handle shadow globals in no_redeclaration

feat(rome_js_analyze): create scope for static initialization blocks

feat(rome_js_analyze): remove duplicated warnings for rule no_redeclaration

chore(rome_js_analyze): rename the union type in no_redeclaration

docs(rome_js_analyze): add suggestions for no_redeclaration

refactor(rome_js_analyze): iterate all scopes for no_redeclaration

fix(rome_js_semantic): fix duplicated patterns
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

noRedeclaration, no-redeclare
5 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载