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

(NodeJS Projects) Improve import verification #7

Open
mathieubes opened this issue Nov 21, 2024 · 0 comments
Open

(NodeJS Projects) Improve import verification #7

mathieubes opened this issue Nov 21, 2024 · 0 comments
Labels
good first issue Good for newcomers optimization A refacto that improve execution time. refacto

Comments

@mathieubes
Copy link
Owner

mathieubes commented Nov 21, 2024

Today, to check if the npm/yarn package is used in files we are only checking that the file contains the package name.

We'll need to modify thoses conditions to improve file dependencies checking.

For example, now we're using the string_exists_in_multiline_text function:

pub fn string_exists_in_multiline_text(term: &str, content: &str) -> bool {
    for line in content.lines() {
        if line.contains(term) {
            return true;
        }
    }
    false
}

NOTE: We are reading files line by line because generally import are matched in like 10-20 first lines.

I think that we should move and rename this function into the Project trait to handle multiple (project's relative) ways to check if the dependency is used in the file.

Example for NodeJS Projects that should detect lines like :

  • import foo from "bar";
  • import "foo";
  • import { Foo } from "bar";

Remember to handle CSS/Scss files too.
And in JSON file a think that we should only match the values and not the keys but I didn't thought too much of it.

@mathieubes mathieubes added enhancement New feature or request good first issue Good for newcomers refacto optimization A refacto that improve execution time. and removed enhancement New feature or request labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers optimization A refacto that improve execution time. refacto
Projects
None yet
Development

No branches or pull requests

1 participant