codepunkt/gulp-jscs-stylish

Duplicate base path to error file causing incorrect path

peterkuiper opened this issue · 4 comments

Hi,

The following is causing the wrong filename (duplicate base path) to be outputted:

In index.js on line 26 the
file: file.base + error.filename,

The output is:

/Users/username/Sites/directory/src//Users/username/Sites/project/src/server/winston/winston.js

and should have been:

/Users/username/Sites/project/src/server/winston/winston.js

The filename passed into gulp-jscs-stylish already contains the full path. It might be better to check error.filename to see if file.base is already added, and if so, drop file.base. Or just don't add file.base at all.

Hey!

Which version of jscs and gulp-jscs are you using?

Hi!

Should be the latest versions:

"devDependencies": {
"gulp": "^3.9.0",
"gulp-jscs": "^3.0.2",
"gulp-jscs-stylish": "^1.2.1",
"gulp-jshint": "^2.0.0",
"gulp-notify": "^2.2.0",
"jscs": "^2.6.0",
"jshint": "^2.8.0",
"jshint-stylish": "^2.1.0"
}

The following patch removes the path problem (based off commit 6a44397):

diff --git index.js index.js
index bb384ec..4dec3e4 100644
--- index.js
+++ index.js
@@ -23,7 +23,7 @@ function toJshint (file) {
    // map errors to jshint format
    return errorList.map(function (error) {
        return {
-           file: file.base + error.filename,
+           file: error.filename,
            error: {
                character: error.column,
                code: 'W ' + error.rule,

I'm not sure if there are any side effects of doing this, that is why I proposed checking error.filename and add file.base if it is missing from error.filename.

I'm not sure when i'll find the time to look into this. Feel free to submit a PR! :)

I did some checking and it seems you can just use error.filename without file.base. Let me know if this works for you!