question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Output relative paths rather than absolute paths

See original GitHub issue

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:

/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:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mysticateacommented, Jun 3, 2020

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

1reaction
eslint-deprecated[bot]commented, Jul 8, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Absolute and Relative Pathnames in UNIX - GeeksforGeeks
Relative path is defined as the path related to the present working directly(pwd). It starts at your current directory and never starts with...
Read more >
Paths explained: Absolute, relative, UNC, and URL—Help
A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a...
Read more >
Difference between Relative path and absolute path in javascript
The path with reference to root directory is called absolute. The path with reference to current directory is called relative.
Read more >
What are the differences between absolute and relative paths?
An absolute path makes no assumptions about your current location in relation to the location of the file or directory it's describing. An ......
Read more >
Classic SysAdmin: Absolute Path vs Relative Path in Linux/Unix
In other words we can say absolute path is a complete path from start of actual filesystem from / directory.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found