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

Feature: no duplicates require #2931

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Pandemic1617
Copy link
Contributor

implements detection of duplicate require imports

resolves #2925

Note that auto fix isn't implemented

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Can we add some tests with a function that's called "require" but isn't the global one?

@ljharb ljharb marked this pull request as draft December 1, 2023 16:51
@Pandemic1617
Copy link
Contributor Author

Can we add some tests with a function that's called "require" but isn't the global one?

const require = (x) => {};

const a = require("./a.js");

This require would be detected as the global require even though it isn't.

This is indeed a limitation of my implementation but I thought it would be acceptable since the following rules also have the same limitation:

  • no-dynamic-require
  • no-amd
  • max-dependencies
  • no-self-import
  • no-relative-packages

@ljharb
Copy link
Member

ljharb commented Dec 4, 2023

Hmm - are there no rules that dont have the limitation?

@Pandemic1617
Copy link
Contributor Author

I am not aware of any and even the moduleVisitor util has that limitation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Disallow duplicate require
2 participants