Skip to content

fix(cli): relative file path formatting (#5565) #5568

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

Closed
wants to merge 2 commits into from

Conversation

mdevils
Copy link
Contributor

@mdevils mdevils commented Apr 3, 2025

Summary

Here is a potential fix for the issue #5565

Closes #5565

Test Plan

Here is new output format:

src/routes.tsx:128:35 lint/correctness/useHookAtTopLevel ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ This hook is being called from a nested function, but all hooks must be called unconditionally from the top-level component.

@github-actions github-actions bot added the A-CLI Area: CLI label Apr 3, 2025
@github-actions github-actions bot added the A-Diagnostic Area: diagnostocis label Apr 4, 2025
@mdevils mdevils force-pushed the fix/5565-file-path-formatting branch 2 times, most recently from 1f951cf to ad73ecd Compare April 5, 2025 16:00
@mdevils mdevils force-pushed the fix/5565-file-path-formatting branch from ad73ecd to 4752041 Compare April 5, 2025 16:57
@arendjr
Copy link
Contributor

arendjr commented Apr 7, 2025

I'm afraid that failing test indicates a regression...

Copy link
Member

@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.

Unfortunately, this approach doesn't work. There are a few things to keep in mind:

  • diagnostics aren't - and shouldn't - be aware of the concept of "relative" and "absolute" paths.

  • File paths are provided to the diagnostics at the source, when we create them, meaning we should avoid as much mutation as possible by the time we print them.

  • Some diagnostics are created during the crawling of the file system. These diagnostics say "Biome can't handle this file extension". This is the struct:

    pub struct SourceFileNotSupported {
    file_source: DocumentFileSource,
    path: String,
    extension: Option<String>,
    }

    We throw this error in a couple of places, and the tricky one is when we use this function, because it's a pure function used in few palces:

    pub fn extension_error(path: &BiomePath) -> WorkspaceError {
    let file_source = DocumentFileSource::from_path(path);
    WorkspaceError::source_file_not_supported(
    file_source,
    path.clone().to_string(),
    path.clone().extension().map(|p| p.to_string()),
    )
    }

@@ -119,7 +119,7 @@ impl ReporterVisitor for ConsoleReporterVisitor<'_> {
}

if diagnostic.severity() >= diagnostics_payload.diagnostic_level {
if diagnostic.tags().is_verbose() && diagnostics_payload.verbose {
Copy link
Member

Choose a reason for hiding this comment

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

Why was this changed? Both conditions must be checked

Comment on lines +144 to +148
let name = if verbose {
name
} else {
get_relative_file_path(name)
};
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this change. Can you explain it?

@mdevils mdevils closed this Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Diagnostic Area: diagnostocis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 2.0.0-beta.1: Prints file path as if they were absolute
3 participants