Output relative paths rather than absolute paths
See original GitHub issueThe 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:
/home/hubro/Dropbox/Company Foo Projects/Some Category/my-project-name/my-project-name-client/src/some-subdir/foo/bar/relay-env.ts
17:3 warning 'cacheConfig' is defined but never used @typescript-eslint/no-unused-vars
18:3 warning 'uploadables' is defined but never used @typescript-eslint/no-unused-vars
57:16 warning Missing return type on function @typescript-eslint/expl
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:
src/some-subdir/foo/bar/relay-env.ts
17:3 warning 'cacheConfig' is defined but never used @typescript-eslint/no-unused-vars
18:3 warning 'uploadables' is defined but never used @typescript-eslint/no-unused-vars
57:16 warning Missing return type on function @typescript-eslint/expl
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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@Hubro Our Node.js API has
cwd
option and users can give arbitrary path as cwd. ESLint uses the given cwd at all. But, currently, formatters cannot access that cwd. So we should support to access cwd from formatters.@kaicataldo I will write an RFC for that.
Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.
Thanks for contributing to ESLint and we appreciate your understanding.