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.

bug caused by shelljs modifying the String.prototype

See original GitHub issue
  • ESLint Version: 3.6.1
  • Node Version: 6.7
  • npm Version:: 2.15.8

tldr: I’ve confirmed that this bug is fixed by updating to the latest version of shelljs.

What parser (default, Babel-ESLint, etc.) are you using?

I’m using gulp-eslint, but the bug is caused by shelljs 0.6.0, a dependency of eslint.

What’s happening

I don’t know why this is happening, but I can explain what is happening and what is causing it.

When I run gulp mocha, even though gulp eslint is never called, since shelljs v6.0.0 modifies the String.prototype AND it’s exported at the top level (e.g. regardless of whether or not shelljs is used, the String.prototype is modified), something is happening that is causing test results to be mutated.

As you can see in the attached gist, only tests with a .. in the expected result are being modified. It appears that .. is being replaced with function from shelljs, so .toString() is probably being called somewhere.

I don’t know where the replacement is happening specifically, but I tracked the root cause to this code in shelljs.

Also, for completeness, the mocha task in gulpfile.js consists of this code:

gulp.task('test', function() {
  return gulp.src('test/*.js')
    .pipe(mocha({reporter: 'spec'}))
});

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
gyandeepscommented, Oct 17, 2016

I am working on this. There was an accidental breaking change introduced in shellljs. Which I have fixed now. Will open a PR once shelljs makes a new release. Ref: https://github.com/shelljs/shelljs/pull/530

0reactions
jonschlinkertcommented, Oct 28, 2016

thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

web.mit.edu/kolya/.f/root/net.mit.edu/athena.mit.e...
... hack to work around the improper behavior (modifying of string prototype) of [shelljs](https://github.com/arturadib/shelljs) see: ...
Read more >
String prototype changing the string value - Stack Overflow
Closed 6 years ago. I'm trying to change the string value inside its protoype function: String.prototype ...
Read more >
string | Yarn - Package Manager
Originally, it modified the String prototype. But I quickly learned that in JavaScript, this is considered poor practice.
Read more >
node_modules/shelljs/CHANGELOG.md · 4.0.2 · verimag ...
Workaround codecov bug of miscalculation of coverage (#795) #838 (dwi2) ... causes LiveScript interpreter (lsc) to hang #160; Don't modify string prototype ......
Read more >
gist-charts/node_modules/shelljs/CHANGELOG.md - GitLab
Change Log. v0.8.0 (2018-01-12) ... Error output should be consistent across all platforms. ... Don't modify string prototype #159; exec\(.
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