Closed Bug 999715 Opened 10 years ago Closed 10 years ago

A few errors/warnings reported via ESLint against loop-server

Categories

(Hello (Loop) :: Server, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: pdehaan, Assigned: tarek)

References

Details

Attachments

(1 file)

I was playing w/ ESLint (installed globally via npm) on my machine and created an .eslintrc file for the loop-server repo and got it down to the following errors/warnings. Not sure what that comment about `'crypto' is read only` means though. seems like a odd error since the instances I checked wasn't writing to the crypto variable/object, just using static methods. I'd need to investigate/google further.

```
$ eslint **/*.js


loop/authentication.js
  19:0   error    Missing JSDoc @returns for function  valid-jsdoc
  19:0   error    Missing JSDoc for parameter 'req'    valid-jsdoc
  19:0   error    Missing JSDoc for parameter 'res'    valid-jsdoc
  19:0   error    Missing JSDoc for parameter 'next'   valid-jsdoc
  58:25  warning  response is defined but never used   no-unused-vars

loop/config.js
    9:4  error  'crypto' is read only                             no-undef
   11:0  error  Missing JSDoc @returns for function               valid-jsdoc
   34:0  error  Missing JSDoc @returns for function               valid-jsdoc
  182:2  error  Don't use process.exit(); throw an error instead  no-process-exit

loop/index.js
   26:6   error    TokBox is already defined            no-redeclare
   12:4   error    'crypto' is read only                no-undef
  157:0   error    Missing JSDoc @returns for function  valid-jsdoc
  157:0   error    Missing JSDoc for parameter 'req'    valid-jsdoc
  157:0   error    Missing JSDoc for parameter 'res'    valid-jsdoc
  178:0   error    Missing JSDoc @returns for function  valid-jsdoc
  178:0   error    Missing JSDoc for parameter 'req'    valid-jsdoc
  178:0   error    Missing JSDoc for parameter 'res'    valid-jsdoc
  303:0   error    Missing JSDoc @returns for function  valid-jsdoc
  303:0   error    Missing JSDoc for parameter 'req'    valid-jsdoc
  303:0   error    Missing JSDoc for parameter 'res'    valid-jsdoc
  329:0   error    Missing JSDoc @returns for function  valid-jsdoc
  329:0   error    Missing JSDoc for parameter 'req'    valid-jsdoc
  329:0   error    Missing JSDoc for parameter 'res'    valid-jsdoc
  383:0   error    Missing JSDoc @returns for function  valid-jsdoc
  383:0   error    Missing JSDoc for parameter 'req'    valid-jsdoc
  383:0   error    Missing JSDoc for parameter 'res'    valid-jsdoc
  402:0   error    Missing JSDoc @returns for function  valid-jsdoc
  402:0   error    Missing JSDoc for parameter 'req'    valid-jsdoc
  402:0   error    Missing JSDoc for parameter 'res'    valid-jsdoc
  213:20  warning  record is defined but never used     no-unused-vars
  319:52  warning  record is defined but never used     no-unused-vars
  352:23  warning  record is defined but never used     no-unused-vars

loop/sessions.js
  6:4  error  'crypto' is read only  no-undef

loop/tokbox.js
   8:4   error    'crypto' is read only                no-undef
  50:20  warning  serverURL is defined but never used  no-unused-vars

loop/tokenlib.js
   7:4  error  'crypto' is read only                no-undef
  11:0  error  Missing JSDoc @returns for function  valid-jsdoc
  54:2  error  Missing JSDoc @returns for function  valid-jsdoc
  54:2  error  Missing JSDoc for parameter 'data'   valid-jsdoc

test/authentication_test.js
  66:25  warning  res is defined but never used  no-unused-vars

test/functional_test.js
   10:4   error    'crypto' is read only               no-undef
  147:15  error    Expected error to be handled        handle-callback-err
  197:17  error    Expected error to be handled        handle-callback-err
  277:13  error    Expected error to be handled        handle-callback-err
  293:15  error    Expected error to be handled        handle-callback-err
  425:15  error    Expected error to be handled        handle-callback-err
  600:36  error    Trailing comma                      no-comma-dangle
  610:36  error    Trailing comma                      no-comma-dangle
  630:38  error    Trailing comma                      no-comma-dangle
  437:29  warning  res is defined but never used       no-unused-vars
  537:39  warning  res is defined but never used       no-unused-vars
  611:41  warning  res is defined but never used       no-unused-vars
  631:43  warning  res is defined but never used       no-unused-vars
  688:40  warning  res is defined but never used       no-unused-vars
  899:42  warning  res is defined but never used       no-unused-vars
  937:38  warning  res is defined but never used       no-unused-vars
  853:10  warning  emptyReq is defined but never used  no-unused-vars

test/storage_test.js
    7:4   error  'crypto' is read only         no-undef
   86:12  error  Expected error to be handled  handle-callback-err
  124:14  error  Expected error to be handled  handle-callback-err
  122:63  error  Expected error to be handled  handle-callback-err
  201:44  error  Expected error to be handled  handle-callback-err
  211:44  error  Expected error to be handled  handle-callback-err
  210:45  error  Expected error to be handled  handle-callback-err
  222:47  error  Expected error to be handled  handle-callback-err

test/tokbox_test.js
   37:6   error    Do not use 'new' for side effects  no-new
  136:30  error    Expected error to be handled       handle-callback-err
  153:30  error    Expected error to be handled       handle-callback-err
   95:46  warning  info is defined but never used     no-unused-vars
  107:48  warning  info is defined but never used     no-unused-vars
  153:39  warning  err is defined but never used      no-unused-vars

test/tokenlib_test.js
    5:4   error  'crypto' is read only              no-undef
   45:8   error  Do not use 'new' for side effects  no-new
   53:8   error  Do not use 'new' for side effects  no-new
   61:8   error  Do not use 'new' for side effects  no-new
   68:8   error  Do not use 'new' for side effects  no-new
   80:8   error  Do not use 'new' for side effects  no-new
   82:30  error  Trailing comma                     no-comma-dangle
   93:8   error  Do not use 'new' for side effects  no-new
   95:43  error  Trailing comma                     no-comma-dangle
  148:19  error  Infix operators must be spaced     space-infix-ops

✖ 81 problems
```


And my .eslintrc file looks like this:

{
    "env": {
        "browser": true,
        "node": true,
        "amd": true,
        "mocha": true
    },

    "rules": {
        "no-alert": 2,
        "no-array-constructor": 2,
        "no-bitwise": 1,
        "no-caller": 2,
        "no-catch-shadow": 2,
        "no-comma-dangle": 2,
        "no-console": 0,
        "no-control-regex": 2,
        "no-debugger": 2,
        "no-delete-var": 2,
        "no-div-regex": 2,
        "no-dupe-keys": 2,
        "no-else-return": 0,
        "no-empty": 2,
        "no-empty-class": 2,
        "no-empty-label": 2,
        "no-eq-null": 2,
        "no-eval": 2,
        "no-ex-assign": 2,
        "no-fallthrough": 2,
        "no-floating-decimal": 2,
        "no-func-assign": 2,
        "no-global-strict": 0,
        "no-implied-eval": 2,
        "no-iterator": 2,
        "no-label-var": 2,
        "no-loop-func": 2,
        "no-mixed-requires": [0, false],
        "no-multi-str": 2,
        "no-native-reassign": 2,
        "no-new": 2,
        "no-new-func": 2,
        "no-new-object": 2,
        "no-new-wrappers": 2,
        "no-obj-calls": 2,
        "no-octal": 2,
        "no-octal-escape": 2,
        "no-plusplus": 0,
        "no-proto": 2,
        "no-redeclare": 2,
        "no-regex-spaces": 2,
        "no-return-assign": 2,
        "no-script-url": 2,
        "no-self-compare": 2,
        "no-shadow": 2,
        "no-sync": 0,
        "no-ternary": 0,
        "no-undef": 2,
        "no-undef-init": 2,
        "no-underscore-dangle": 0,
        "no-unreachable": 2,
        "no-unused-expressions": 1,
        "no-unused-vars": 1,
        "no-use-before-define": 0,
        "no-with": 2,
        "no-wrap-func": 2,
        "no-yoda": 0,

        "block-scoped-var": 0,
        "brace-style": 0,
        "camelcase": 0,
        "complexity": [0, 11],
        "consistent-return": 0,
        "consistent-this": [0, "that"],
        "curly": 0,
        "dot-notation": 0,
        "eqeqeq": 2,
        "guard-for-in": 0,
        "max-depth": [0, 4],
        "max-len": [0, 80, 4],
        "max-params": [0, 3],
        "max-statements": [0, 10],
        "new-cap": 2,
        "new-parens": 2,
        "one-var": 0,
        "quote-props": 0,
        "quotes": [0, "single"],
        "radix": 0,
        "semi": 0,
        "strict": 0,
        "unnecessary-strict": 0,
        "use-isnan": 2,
        "valid-jsdoc": 2,
        "wrap-iife": 2,
        "wrap-regex": 0
    }
}
We definitely should fix these and integrate this linting into the "make test" command.

Peter, do you want to add your files there or should I take action and to it?
Flags: needinfo?(pdehaan)
Sorry, I missed this, but I'll pull the latest changes and add my .eslintrc file and submit a PR and we can iterate from there and relax any rules we don't want.
Flags: needinfo?(pdehaan)
Oddly, I keep getting this message when trying to fork the mozilla-services/loop-server project in GitHub (which looks public now).

> **This repository is temporarily unavailable.**
> This repository is moving to a newer, better home. It'll be back in just a few minutes.
Yea, it seems like it has suddenly gone public.
How far in the fork process did you get before you saw that error?
I can hit fork and it asks me for a location....
I've had a private fork for a long time, but noticed it failing today when I tried pushing a PR. (although I admit I haven't been looking at this repo very much recently)

> $ git push origin eslint
> ERROR: Your repository is disabled. Please see https://github.com/pdehaan/loop-server for more information
> fatal: Could not read from remote repository.
> 
> Please make sure you have the correct access rights and the repository exists.

https://github.com/pdehaan/loop-server (my fork) just shows me a spinner, I haven't been able to get it to display files all day. I can't see anything in GitHub about when the private repo went public, but not sure I have access to that. Also not seeing anything in GitHub status page (https://status.github.com/) about outages or problems.
.eslintrc file and Make task added in https://github.com/mozilla-services/loop-server/pull/94

ESLint is currently disabled, but you can run the linter manually via `$ make eslint` or `$ npm run eslint` to see all the current warnings/errors.
Attached file Link to github PR
Attachment #8474484 - Flags: review?(alexis+bugs)
Assignee: nobody → tarek
Status: NEW → ASSIGNED
Comment on attachment 8474484 [details] [review]
Link to github PR

Clearing the r? on me.
Attachment #8474484 - Flags: review?(alexis+bugs)
https://github.com/mozilla-services/loop-server/commit/fed4501759cef4b7c247f8c03e2e27e71ec53d5c
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: