gpt4 book ai didi

javascript - 钩子(Hook) (`sails-eslint` ) 加载失败

转载 作者:太空宇宙 更新时间:2023-11-04 02:09:21 25 4
gpt4 key购买 nike

将其重新打开为最新的 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 将 lint 配置到项目

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?

最佳答案

您可以使用 sails-hook-eslint 插件。 sails-eslint 也不适合我。

https://github.com/Globegitter/sails-hook-eslint

npm install sails-hook-eslint

之后将 .eslintrc 文件添加到 sails 根目录。

现在,如果您启动 sails lift,则会执行 linting 任务。另外,如果你想要一个更新的 eslint。我为此做了一个公关。 https://github.com/Globegitter/sails-hook-eslint/pull/8

关于javascript - 钩子(Hook) (`sails-eslint` ) 加载失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42944128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com