钩子(`sails-eslint`)无法加载

时间:2017-03-22 06:21:31

标签: javascript node.js sails.js eslint

重新打开此版本作为最新的sails-eslint版本,抛出同样的错误

"npm": "5.0.2"
"sails": "~0.12.13",
"sails-disk": "~0.10.9",
"sails-eslint": "^1.0.9",
"sails-hook-eslint": "^1.0.3",
"sails-mysql": "^0.11.5"

sails-hook-eslint is not helpful to resolve the error mentioned below:

通过安装sails-eslint

将项目配置为项目

eslint.js添加到config文件夹中:

module.exports.eslint = {
  active: true,
  usePolling: false,
  formatter: 'stylish',
  dirs: [
    "api",
    "config"
  ],
  ignored: [
    "api/policies"
  ]
};

但是当试图运行应用程序时,它会抛出错误,如下所示:

    info: ESlint watching...
error: A hook (`sails-eslint`) failed to load!
Code did not pass lint rules
c:\Projects\test\api\controllers\UsersController.js
  10:4   error  'Users' is not defined        no-undef
  10:22  error  Expected error to be handled  handle-callback-err
  15:4   error  'Users' is not defined        no-undef
  15:50  error  Expected error to be handled  handle-callback-err

c:\Projects\test\api\policies\sessionAuth.js
  10:25  error  Missing space before function parentheses  space-before-function-parentheses
  12:50  error  Trailing spaces not allowed                no-trailing-spaces

c:\Projects\test\api\responses\badRequest.js
  29:2   error  Expected { after 'else'                                                       curly
  30:64  error  A space is required after ','                                                 comma-spacing
  53:38  error  Expected literal to be on the right side of ==                                yoda
  57:4   error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  65:2   error  Expected { after 'else'                                                       curly
  71:96  error  Unexpected space before function parentheses                                  space-before-function-parentheses

c:\Projects\test\api\responses\created.js
  14:33  error  Unexpected space before function parentheses                                  space-before-function-parentheses
  38:38  error  Expected literal to be on the right side of ==                                yoda
  42:4   error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  50:2   error  Expected { after 'else'                                                       curly
  56:92  error  Unexpected space before function parentheses                                  space-before-function-parentheses

c:\Projects\test\api\responses\forbidden.js
  15:35   error  Unexpected space before function parentheses                                  space-before-function-parentheses
  26:2    error  Expected { after 'else'                                                       curly
  27:62   error  A space is required after ','                                                 comma-spacing
  50:38   error  Expected literal to be on the right side of ==                                yoda
  54:4    error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  62:2    error  Expected { after 'else'                                                       curly
  76:118  error  A space is required after ','                                                 comma-spacing
  79:11   error  Closing curly brace does not appear on the same line as the subsequent block  brace-style

c:\Projects\test\api\responses\notFound.js
  20:34   error  Unexpected space before function parentheses                                  space-before-function-parentheses
  31:2    error  Expected { after 'else'                                                       curly
  32:62   error  A space is required after ','                                                 comma-spacing
  55:38   error  Expected literal to be on the right side of ==                                yoda
  59:4    error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  67:2    error  Expected { after 'else'                                                       curly
  81:117  error  A space is required after ','                                                 comma-spacing
  84:11   error  Closing curly brace does not appear on the same line as the subsequent block  brace-style

c:\Projects\test\api\responses\ok.js
  14:32  error  Unexpected space before function parentheses                                  space-before-function-parentheses
  38:38  error  Expected literal to be on the right side of ==                                yoda
  42:4   error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  50:2   error  Expected { after 'else'                                                       curly
  56:87  error  Unexpected space before function parentheses                                  space-before-function-parentheses

c:\Projects\test\api\responses\serverError.js
  15:37   error  Unexpected space before function parentheses                                  space-before-function-parentheses
  26:2    error  Expected { after 'else'                                                       curly
  27:63   error  A space is required after ','                                                 comma-spacing
  50:38   error  Expected literal to be on the right side of ==                                yoda
  54:4    error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  62:2    error  Expected { after 'else'                                                       curly
  76:120  error  A space is required after ','                                                 comma-spacing
  79:11   error  Closing curly brace does not appear on the same line as the subsequent block  brace-style

✖ 46 problems (46 errors, 0 warnings)

Code did not pass lint rules
c:\Projects\test\config\bootstrap.js
  12:35  error  Missing space before function parentheses  space-before-function-parentheses

c:\Projects\test\config\connections.js
  47:18  error  Expected exception block, space or tab after // in comment  spaced-line-comment
  48:23  error  Expected exception block, space or tab after // in comment  spaced-line-comment
  52:3   error  Unexpected trailing comma                                   comma-dangle

c:\Projects\test\config\eslint.js
   6:4  error  Strings must use singlequote  quotes
   7:4  error  Strings must use singlequote  quotes
  10:4  error  Strings must use singlequote  quotes

c:\Projects\test\config\http.js
  80:3  error  Unexpected trailing comma  comma-dangle

c:\Projects\test\config\session.js
  24:44  error  Unexpected trailing comma  comma-dangle

c:\Projects\test\config\sockets.js
  54:0  error  Multiple blank lines not allowed  no-multiple-empty-lines
  71:0  error  Multiple blank lines not allowed  no-multiple-empty-lines

c:\Projects\test\config\views.js
  95:1  error  Newline required at end of file but not found  eol-last

✖ 12 problems (12 errors, 0 warnings)

error: TypeError: Expected `input` to be a `string`, got `number`
    at module.exports (c:\Projects\test\node_modules\repeating\index.js:6:9)
    at c:\Projects\test\node_modules\sails-eslint\pretty-formatter.js:95:17
    at Array.map (native)
    at module.exports (c:\Projects\test\node_modules\sails-eslint\pretty-formatter.js:84:21)
    at runLint (c:\Projects\test\node_modules\sails-eslint\index.js:28:7)
    at c:\Projects\test\node_modules\sails-eslint\index.js:52:7
    at Array.forEach (native)
    at processingQueue (c:\Projects\test\node_modules\sails-eslint\index.js:46:8)
    at Hook.initialize (c:\Projects\test\node_modules\sails-eslint\index.js:140:9)
    at Hook.wrapper [as initialize] (c:\Projects\test\node_modules\@sailshq\lodash\lib\index.js:3250:19)
    at c:\Projects\test\node_modules\sails\lib\hooks\index.js:88:16
    at c:\Projects\test\node_modules\sails\node_modules\async\lib\async.js:52:16
    at c:\Projects\test\node_modules\sails\node_modules\async\lib\async.js:548:17
    at c:\Projects\test\node_modules\sails\node_modules\async\lib\async.js:542:17
    at _arrayEach (c:\Projects\test\node_modules\sails\node_modules\async\lib\async.js:85:13)
    at Immediate.taskComplete (c:\Projects\test\node_modules\sails\node_modules\async\lib\async.js:541:13)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

代码出了什么问题?

另外,有没有可能使用babel-eslint?

0 个答案:

没有答案