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

'grunt jshint:server' ignores deep server/api files #463

Closed
bkapicka opened this issue Aug 20, 2014 · 12 comments · Fixed by #482
Closed

'grunt jshint:server' ignores deep server/api files #463

bkapicka opened this issue Aug 20, 2014 · 12 comments · Fixed by #482
Labels

Comments

@bkapicka
Copy link

Are files nested in the server/api purposefully excluded from jshint:serve?

If not, proposed minor updates outlined below:

Updated Gruntfile:

src: [ 'server/{,*/}*.js']

to

src: [ 'server/**/*.js']

This causes the boilerplate specs to fail on 'grunt jshint:server'. Two additional changes to address:

  1. Remove "latedef": true from Server .jshintrc
  2. Add /*global describe, it, before, beforeEach, after, afterEach */
    and /*jshint expr:true */ to thing.spec.js and user.spec.js
@kingcody
Copy link
Member

I agree with 2, but do you know the files/line numbers for the latedef issue?

@bkapicka
Copy link
Author

@kingcody
Server .jshintrc template file link
File Path: generator-angular-fullstack / app / templates / server / .jshintrc
Line Number: L7.

@kingcody
Copy link
Member

@bkapicka, sorry I actually meant: what were the offending files? The ones that had late definitions.

@bkapicka
Copy link
Author

@kingcody my mistake - it was line 87 of the template thing.controller.js:
output from generated app:

server/api/thing/thing.controller.js
  line 66  col 21  'handleError' was used before it was defined.

@kingcody
Copy link
Member

Ok, great. I'll see about getting a PR together to address that. Were there any other files that did not pass?

Btw; it's my 'opinion' that the less overrides in the linter the better, barring globals. Just my opinion though

@bkapicka
Copy link
Author

Thanks for the PR.

And my apologies - missed two latedef errors. The full set of problems pre changes to jshintrc are below.

Re overrides: Completely agree but since the grunt jshint:server mixes specs and api files, it was the quickest solution to add /*jshint expr:true */ to the specs. Perhaps it is worth a separate grunt task for server specs requiring a new .jshintrc.

server/api/thing/thing.controller.js
  line 66  col 21  'handleError' was used before it was defined.

server/api/thing/thing.socket.js
  line 18  col 16  'onSave' was used before it was defined.
  line 22  col 18  'onRemove' was used before it was defined.

server/api/thing/thing.spec.js
  line 7   col 1   'describe' is not defined.
  line 9   col 3   'it' is not defined.

server/api/user/user.model.spec.js
  line 54  col 45  Expected an assignment or function call and instead saw an expression.
  line 58  col 45  Expected an assignment or function call and instead saw an expression.
  line 14  col 1   'describe' is not defined.
  line 15  col 3   'before' is not defined.
  line 22  col 3   'afterEach' is not defined.
  line 28  col 3   'it' is not defined.
  line 35  col 3   'it' is not defined.
  line 45  col 3   'it' is not defined.
  line 53  col 3   'it' is not defined.
  line 57  col 3   'it' is not defined.

@kingcody
Copy link
Member

@bkapicka I think I see what you're saying. As in, it would not be advised to define describe, before, afterEach, it... as globals for non-spec files, to which I would agree.

@DaftMonk, @JaKXz any thoughts on this subject?

@JaKXz
Copy link
Collaborator

JaKXz commented Aug 21, 2014

I agree with @bkapicka's points, but I don't think latedef should be removed from the .jshintrc. I think a PR to fix these issues would be great guys, thanks!

@JaKXz JaKXz added the bug label Aug 21, 2014
@kingcody
Copy link
Member

@JaKXz I totally miss understood @bkapicka first point. I thought he was suggesting that we ADD latedef not remove it. I was under the impression it was NOT in the server .jshint. But I see now.

@DaftMonk
Copy link
Member

I wouldn't mind getting rid of latedef. Those functions are hoisted, so there shouldn't be any issues with it.

It makes sense to me to have the public api of a module closer to the top for easier scanning of a file, and private methods near the bottom.

@kingcody
Copy link
Member

@DaftMonk should we look at using latedef: nofunc? Just noticed it was an option. Not sure if that would be a good middle ground?

@DaftMonk
Copy link
Member

@kingcody Nice find! That sounds perfect.

kingcody added a commit to kingcody/generator-angular-fullstack that referenced this issue Aug 25, 2014
Changes:
- Update jshint task in `Gruntfile.js` to include `serverTest`
- Add `server/.jshintrc-spec` that extends `server/.jshintrc` with spec globals
- Use `"latedef": "nofunc"` instead of `"latedef": true` in `server/.jshintrc`
- Add assertion for `jshint` task in generator tests for `defaultOptions`
- Fix pre exsisting lint errors in `server` and `client`
- Change `getEmail()` in `client/app/account/settings/settings.controller` to use `user` arg and not `$scope.user`

Closes angular-fullstack#463, angular-fullstack#486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants