0

I'm using should.js for assertions, however, I am getting JSHint warnings for:

argObject.exists(dummyString1).should.be.true;
argObject.exists(dummyString2).should.be.true;

is throwing

Expected an assignment or function call and instead saw an expression.

for each line after the first.

BanksySan
  • 27,362
  • 33
  • 117
  • 216
  • 1
    yeah, it's weird syntax, nothing wrong with it though... were you having a specific problem? – dandavis May 13 '15 at 20:59
  • Is it actually an incompatibility with jshint then? I like jshint, I don't want to have to turn it off because it stops me doing idiotic and embarrassing things. – BanksySan May 13 '15 at 21:01
  • you don't have to turn it off. hint gives advice, but the programmer calls the shots. there's nothing wrong with code that hint complains about per se, it's just input, you do the processing, and in this particular case, know it's safe to ignore the advice. – dandavis May 13 '15 at 21:01
  • ... not when it's tied into the build process. – BanksySan May 13 '15 at 21:02
  • i'm not sure what you're getting at, but if you're using hint for anything besides advice to humans, you've gotta be mis-using it. it's just a tool, and not a perfect one. – dandavis May 13 '15 at 21:04
  • I used the yeoman node module build, it's defaulted to that. – BanksySan May 13 '15 at 21:05
  • hist is best used earlier in the process than upon build, i question it's value so late in the game. it's nice to see the errors in your editor as you type, where it's easy to fix (add the semi, parens, whatever). don't let lint/hint/etc get you hung up on it's pointless advice, use it find surprises you care about. – dandavis May 13 '15 at 21:08
  • Just tell jshint to ignore your unit test files. problem solved. create a file named `.jshintignore` and use it just like you would a `.gitignore` – Kevin B May 13 '15 at 21:09
  • @KevinB That would be a solution. – BanksySan May 13 '15 at 21:15

1 Answers1

1

The solution I went for is to avoid using that syntax (I don't really like it much anyway) and rewrite the assertions as:

argObject.exists(dummyString1).should.equal(true);
argObject.exists(dummyString2).should.equal(false);
BanksySan
  • 27,362
  • 33
  • 117
  • 216