Skip to content

feat(linter): add no-redeclare rule.#683

Merged
Boshen merged 28 commits intooxc-project:mainfrom
eryue0220:feat/no-redeclare
Sep 23, 2023
Merged

feat(linter): add no-redeclare rule.#683
Boshen merged 28 commits intooxc-project:mainfrom
eryue0220:feat/no-redeclare

Conversation

@eryue0220
Copy link
Copy Markdown
Contributor

Close: #615 #520
Rule: Docs

Notes:

Currently, I still tried to implement the no-redeclare, Some tests doesn't pass now.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 3, 2023

CLA assistant check
All committers have signed the CLA.

@eryue0220 eryue0220 marked this pull request as draft August 3, 2023 15:32
@github-actions github-actions bot added A-linter Area - Linter A-semantic Area - Semantic labels Aug 3, 2023
@eryue0220 eryue0220 marked this pull request as ready for review September 7, 2023 06:48
Copy link
Copy Markdown
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

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

Nice! You understood the essence of the semantic builder!

Now to the cool part:

If you take a look at any other rules that report duplications or redeclarations, you can see the diagnostic points to both spans:

#[derive(Debug, Error, Diagnostic)]
#[error("Identifier `{0}` has already been declared")]
#[diagnostic()]
pub struct Redeclaration(
    pub Atom,
    #[label("`{0}` has already been declared here")] pub Span,
    #[label("It can not be redeclared here")] pub Span,
);

This gives the user the most intuitive way to see what is wrong with the code.

So let's give it a try and add this.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Sep 8, 2023

CodSpeed Performance Report

Merging #683 will not alter performance

Comparing eryue0220:feat/no-redeclare (5cc0289) with main (d700cf8)

Summary

✅ 18 untouched benchmarks

…t/no-redeclare

* 'feat/no-redeclare' of github.com:eryue0220/oxc: (22 commits)
  deps: remove default-features from codspeed-criterion-compat
  chore(deps): bump the dependencies group with 4 updates (oxc-project#893)
  chore(deps): bump actions/checkout from 3 to 4 (oxc-project#894)
  feat(minifier): constant addition expression folding (oxc-project#882)
  chore(benchmark): turn on all lints (oxc-project#892)
  feat(linter): eslint-plugin-import(no-cycle) (oxc-project#890)
  chore: fix typo (oxc-project#889)
  perf(linter): early bail out if not jest fn (oxc-project#885)
  feat(linter): add typescript/no-explicit-any (oxc-project#881)
  feat(website): Hide error panel when query view is shown (oxc-project#884)
  fix(website): fix run_query call arguments (oxc-project#880)
  feat(linter): eslint-plugin-import/no-self-import (oxc-project#878)
  feat(linter): implement re-exports (oxc-project#877)
  ci(benchmark): install toolchain first
  refactor(resolver): clean up `load_alias` (oxc-project#875)
  fix(parser): parse [+In] in object binding initializer (oxc-project#874)
  chore(fuzz): add --sanitizer none command
  chore(fuzz): add nightly instructions
  refactor: clean up fuzzer, move it to repo root (oxc-project#872)
  perf(resolver): avoid double hashing by memoizing the hash (oxc-project#871)
  ...
Copy link
Copy Markdown
Member

@Boshen Boshen 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 like the tests need to be fixed. We can merge once they are fixed.

@eryue0220
Copy link
Copy Markdown
Contributor Author

I think we can merge once if the ci pass. And some cases maybe fixed in later.

@Boshen Boshen merged commit 2453954 into oxc-project:main Sep 23, 2023
@Boshen
Copy link
Copy Markdown
Member

Boshen commented Sep 23, 2023

Thank you for being patient with me!

@eryue0220 eryue0220 deleted the feat/no-redeclare branch January 22, 2024 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter A-semantic Area - Semantic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(linter): eslint/no-redeclare

4 participants