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
Output relative paths rather than absolute paths #13376
Comments
This seems like a bug report/feature request for VS Code. Changing the default formatter for this specific case feels a bit like a kludge to me. I think we should stick with absolute paths in the default formatter because there's no ambiguity around which file the result is referring to, and we should always be striving for less ambiguity and less magic in the default happy path. ESLint allows for user-defined custom formatters. I would suggest taking the existing default formatter and tweaking it to your liking. |
Yes I wasn't suggesting anything should change by default, I was rather hoping that a setting existed that could affect this. After quickly skimming the custom formatters page you linked, it seems like options can be added to formatters through environment variables. Would you be opposed to add an option like |
I personally don't think we should be changing existing formatters at this point, particularly since custom formatters are already supported. Let's see what the rest of the team thinks. |
Actually, custom formatter cannot convert paths to relative because formatters cannot know the current working directory ( I wonder if we should support to access |
In what scenario would it not be safe to use I mean, if the user explicitly clears the environment before calling ESLint it would be unavailable:
But all shells (afaik) will always make PWD available to subprocesses, even when called with an empty environment and without any initialization scripts:
In any case it's a simple check in the formatter to run |
Ah, I didn't know this. That seems like information a formatter should have, given that filepaths are such an important part of reporting results. |
@Hubro Our Node.js API has @kaicataldo I will write an RFC for that. |
I have wrote: |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
The version of ESLint you are using.
v7.1.0
The problem you want to solve.
Currently when I run eslint on a directory, it groups the errors by file, and each group has the absolute path to the file at the top.
I would like to request that eslint prints the relative path to the file instead.
For example, when I run
eslint --ext ts,tsx src/
in my project root, I get several blocks like this:First of all the path is needlessly long, but more problematically the full path contains spaces, so VSCode fails to open the path using Ctrl+Click. This means I have to manually browse to each file with errors whenever I run eslint, which is frustrating.
I even tried to avoid the space issue by symlinking the project folder under
~/projects
but it doesn't matter, eslint apparently resolves the absolute path to the file anyway. This also causes the additional issue that even if VSCode could now open the path, I would now be opening the same files with 2 separate paths, meaning they would show up twice in my recent files list, which is also frustrating.Your take on the correct solution to problem.
I would like to configure eslint so it outputs something like this instead:
Or at the very least I would like to stop it from resolving links into absolute paths.
Is there any way this can be done currently? Would it be reasonable to add a setting to control this?
Are you willing to submit a pull request to implement this change?
If given some pointers to where to start, sure.
The text was updated successfully, but these errors were encountered: