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

Errors are reported twice #29

Closed
Turbo87 opened this issue Feb 12, 2016 · 7 comments · Fixed by #33 or #35
Closed

Errors are reported twice #29

Turbo87 opened this issue Feb 12, 2016 · 7 comments · Fixed by #33 or #35

Comments

@Turbo87
Copy link
Contributor

Turbo87 commented Feb 12, 2016

It seems that currently any error is reported twice:

  22 passing (13s)
  1 failing

  1) eslint should have no errors in lib:
     Code did not pass lint rules
/Users/tbn/Code/ember-cli/lib/utilities/reexport-template.js
  2:1  error  Use the global form of "use strict"  strict
  3:3  error  Use the global form of "use strict"  strict

✖ 2 problems (2 errors, 0 warnings)

  Error: Code did not pass lint rules
  lib/utilities/reexport-template.js
    2:1  error  Use the global form of "use strict"  strict
    3:3  error  Use the global form of "use strict"  strict

  ✖ 2 problems (2 errors, 0 warnings)

      at Context.<anonymous> (node_modules/mocha-eslint/index.js:27:13)

Interesting about this is that one of the outputs is using relative paths, while the other is using the absolute path of the file.

@IanVS
Copy link
Contributor

IanVS commented Feb 15, 2016

Really strange. I wonder if it had something to do with the way globs are resolved. I've just merged in some changes to the globbing, to allow multiple globs and negation. I plan to include it in the upcoming 2.0.0 release. Perhaps you could try running again with those changes, to see if the issue persists.

@Turbo87
Copy link
Contributor Author

Turbo87 commented Feb 25, 2016

I just tested it with [email protected] and the problem still exists unfortunately

@Turbo87
Copy link
Contributor Author

Turbo87 commented Feb 25, 2016

This bug is starting to get really weird... if the message in the Error object is containing the project path the message is duplicated with the project path removed. I have no idea yet where that magic happens but this seems really strange to me.

@Turbo87
Copy link
Contributor Author

Turbo87 commented Feb 25, 2016

It seems that this is actually not a bug in mocha-eslint but rather in mocha itself. There are several things happening here:

  1. mocha is using a stackTraceFilter() function to beautify the stacktrace output which converts absolute paths to relative paths by replacing process.cwd() with an empty string
  2. eslint is producing errors including the absolute paths to the problematic files
  3. the stack property of Error instances seems to include the error message and mocha is removing the message by checking if stack.indexOf(message) !== -1 and then removing the message at the beginning

The issue here is that mocha applies the stack beautifying before removing message from the stack property which is causing the message to differ from the prefixed message in stack because that one is now using a relative path.

What we could do is replace all absolute paths with relative paths in the message ourselves before throwing the Error instance, but ultimately this is a bug in mocha that should be addressed. I think that a workaround in this case might be beneficial as it has no real drawbacks and using relative paths is actually much nicer anyway.

@IanVS
Copy link
Contributor

IanVS commented Feb 25, 2016

Fix released in 2.0.1.

@Turbo87
Copy link
Contributor Author

Turbo87 commented Feb 26, 2016

@IanVS cool, thanks! I think you may have forgotten the git tag though 😉

@IanVS
Copy link
Contributor

IanVS commented Feb 26, 2016

Yep, fixed. Thanks.

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