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

Add fullPath option #34

Closed
ghost opened this issue Feb 24, 2016 · 4 comments
Closed

Add fullPath option #34

ghost opened this issue Feb 24, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 24, 2016

Hi,

The reporter currently prints relative paths to the console.
In some IDEs, the terminal only converts absolute paths into clickable links, which is really
useful for quickly navigating to the errors.

Could you add a 'fullPath' option to the reporter?

I guess all you would have to do is adding:

var path = require("path");

and replacing line 35 with:

headers[i] = (options.fullPath ? path.resolve(process.cwd(), el.file) : el.file);

Thanks :)

@sindresorhus
Copy link
Owner

This reporter just prints whatever it get's from JSHint. I think it would be better implemented there.

headers[i] = el.file;

@ghost
Copy link
Author

ghost commented Feb 25, 2016

Thanks.

For anyone interested, it seems they are already discussing the possibility of a --reporter:fullpath flag on jshint:
jshint/jshint#2752

@roscorcoran
Copy link

I found a quick fix solution for those using Gulp, you can pipe to your own reporter inline in your gulpfile and modify the file string:

    .pipe(jshint.reporter(
      module.exports = {
      reporter: function (results) {
        results.forEach(function (result) {
          result.file = process.cwd() + '/' + result.file  + ':' + result.error.line + ':' + result.error.character;
        });
      }
    }))

So you would place this between the jshint output and the jshint-stylish reporter. like this:

    .pipe(jshint())
    .pipe(jshint.reporter(
      module.exports = {
      reporter: function (results) {
        results.forEach(function (result) {
          result.file = process.cwd() + '/' + result.file  + ':' + result.error.line + ':' + result.error.character;
        });
      }
    }))
    .pipe(jshint.reporter('jshint-stylish', {verbose: true}));

Let me know if this works for anyone.

@ghost
Copy link
Author

ghost commented Mar 14, 2016

@roscorcoran nice approach, works for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants